Mangling, Controlling the console channel – Comtrol eCos User Manual

Page 315

Advertising
background image

Chapter 11. Porting Guide

Having two separate channels allows, e.g., for simple logging without conflicts with the debugger or interactive IO
which some debuggers do not allow.

Mangling

As debuggers usually have a protocol using specialized commands when communicating with the stub on the
target, sending out text as raw ASCII from the target on the same channel will either result in protocol errors (with
loss of control over the target) or the text may just be ignored as junk by the debugger.

To get around this, some debuggers have a special command for text output. Mangling is the process of encoding
diagnostic ASCII text output in the form specified by the debugger protocol.

When it is necessary to use mangling, i.e. when writing console output to the same port used for debugging, a
mangler function is installed on the console channel which mangles the text and passes it on to the debugger
channel.

Controlling the Console Channel

Console output configuration is either inherited from the ROM monitor launching the application, or it is speci-
fied by the application. This is controlled by the new option

CYGSEM_HAL_VIRTUAL_VECTOR_INHERIT_CONSOLE

which defaults to enabled when the configuration is set to use a ROM monitor.

If the user wants to specify the console configuration in the application image, there are two new options that are
used for this.

Defaults

are

to

direct

diagnostic

output

via

a

mangler

to

the

debugging

channel

(

CYGDBG_HAL_DIAG_TO_DEBUG_CHAN

enabled).

The

mangler

type

is

controlled

by

the

option

CYGSEM_HAL_DIAG_MANGLER

. At present there are only two mangler types:

GDB

This causes a mangler appropriate for debugging with GDB to be installed on the console channel.

None

This causes a NULL mangler to be installed on the console channel. It will redirect the IO to/from the debug

channel without mangling of the data. This option differs from setting the console channel to the same IO port
as the debugging channel in that it will keep redirecting data to the debugging channel even if that is changed
to some other port.

Finally, by disabling

CYGDBG_HAL_DIAG_TO_DEBUG_CHAN

, the diagnostic output is directed in raw form to the

specified console IO port.

In summary this results in the following common configuration scenarios for RAM startup configurations:

For regular debugging with diagnostic output appearing in the debugger, mangling is enabled and stubs disabled.

Diagnostic output appears via the debugging channel as initiated by the ROM monitor, allowing for correct
behavior whether the application was launched via serial or Ethernet, from the RedBoot command line or from
a debugger.

211

Advertising