Re: [patch] Add Logging Support for SID Components
Dave Brolley <[email protected]>
| Newsgroups | gmane.comp.emulators.sid.devel |
|---|---|
| Message-ID | <[email protected]> |
I forgot to explain what the new options actually do ......
o To use the logging facility a component inherits from
fixed_attribute_map_with_logging_component
o The component's methods may then call the method
log (sid::host_int_4 level, const char *fmt, ...)
o The component's ulog_out_pin will then be driven, once character at a
time with the log message under the following conditions:
- If the component's 'ulog-mode' attribute is "less" then the
message will be output of the 'level' on the call to 'log' is less than
or equal to the value of the component's 'ulog-level' attribute
- If the component's 'ulog-mode' attribute is "equal" or "match"
then the message will be output of the 'level' on the call to 'log' is
equal to the value of the component's 'ulog-level' attribute
The command line option settings are stored in SessionCfg (specified
before --board) and BoardCfg (specified after --board) and can be used
to set these attributes for components using logging. If a sid-io-stdio
component is connected to the component's ulog_out_pin, then
--ulog-filename can be used to set its 'filename' attribute.
By default, a component inheriting from
fixed_attribute_map_with_logging_component is set up for --ulog-level==0
and --ulog-mode=less. By default a sid-io-stdout component writes to
stdout. So, the default settings are for logging to stdout for log
messages with a level of 0.
Dave
Dave Brolley wrote:
> Hi,
>
> The attached patch adds logging support for sid components in 3 stages:
>
> 1) Add a new level to the sid component heirarchy
>
> o fixed_attribute_map_with_logging_component inherits
> fixed_attribute_map_component and provides the logging capability
> o An output pin, ulog_out_pin, is defined here through which the
> log data is output.
> o printf-like logging (my immediate need) is provided via the 'void
> log (level, const char *fmt, ...)' method
> o Attributes record the logging settings (see options below)
> o A nice future addition would be a 'log (level)' method which
> would return some kind of stream object.
>
> 2) Add capability to sid-io-stdio (sid/consoles/stdio.cxx) for writing
> output to a file.
>
> o This provides logging to stdout or to a via via the component's
> ulog_out_pin
>
> 3) Expand the command line interface for sid
>
> o 3 new options control logging behavior
> --ulog-level=INTEGER
> --ulog-mode={less|match|equal}
> --ulog-file=FILENAME
> o As with many options, these relate to the previous --board
> specified or provide settings for all boards if specified before the
> first --board option.
> o The board level settings are kept in BoardCfg
> (sid/main/dynamic/commonCfg.h) by inhereting a new UlogCfg
> o The global level settings are kept in SessionCfg also by
> inherting from UlogCfg
> o Configuration may then use this info to set attributes and
> connect pins in the desired components to activate the logging feature.
>
> NOTES:
> o I needed to use vsnprintf or vasprintf if available and so I added
> checks for them in sid/component/configure.in
> o I needed to define _ISOC99_SOURCE for vsnprintf or _GNU_SOURCE for
> vasprintf and so we now also have to define _BSD_SOURCE and
> _SVID_SOURCE which are normally defined by default if no _XXXXX_SOURCE
> is defined.
> o I included the regenerated sid/component/config.h in the patch so
> you can see the new macros.
>
> I'm requesting review of this patch, especially the placement of the
> new functionality in the component heirarchy and the configury changes
> to sid/component.
>
> Thanks,
> Dave