
GRMON3-UM
June 2019, Version 3.1.0
23
www.cobham.com/gaisler
2. Return values. The return value from GRMON is seldom the same as the information that is printed to
standard output, it's often the important data in a raw format. Return values can be used as input to other
commands or to be saved in variables. All TCL commands and many GRMON commands have return
values. The return values from commands are normally not printed. To print the return value to standard
output one can use the Tcl command puts. I.a. if the variable
::grmon::settings:echo_result
to 1, then GRMON will always print the result to stdout.
3. Return code. The return code from a command can be accessed by reading the variable
errorCode
or
by using the Tcl command catch. Both Tcl and GRMON commands will have an error message as return
value if it fails, which is also printed to standard output. More about error codes can be read about in the
Tcl tutorial or on the Tcler's Wiki [http://wiki.tcl.tk/].
For some of the GRMON commands it is possible to specify which core the commands is operation on. This is
implemented differently depending for each command, see the commands' syntax documentation in Appendix B,
Command syntax for more details. Some of these commands use a device name to specify which core to interact
with, see Appendix C, Tcl API for more information about device names.
3.5.3. API
It is possible to extend GRMON using Tcl. GRMON provides an API that makes it possible do write own device
drivers, implement hooks and to write advanced commands. See Appendix C, Tcl API for a detailed description
of the API.
3.6. Symbolic debug information
GRMON will automatically extract the symbol information from ELF-files, debug information is never read from
ELF-files. The symbols can be used to GRMON commands where an address is expected as below. Symbols are
tab completed.
grmon3> load v8/stanford.exe
40000000 .text 54.8kB / 54.8kB [===============>] 100%
4000DB30 .data 2.9kB / 2.9kB [===============>] 100%
Image /home/daniel/examples/v8/stanford.exe loaded
grmon3> bp main
Software breakpoint 1 at <main>
grmon3> dis strlen 5
0x40005b88: 808a2003 andcc %o0, 0x3, %g0 <0>
0x40005b8c: 12800012 bne 0x40005BD4 <4>
0x40005b90: 94100008 mov %o0, %o2 <8>
0x40005b94: 033fbfbf sethi %hi(0xFEFEFC00), %g1 <12>
0x40005b98: da020000 ld [%o0], %o5 <16>
The symbols command can be used to display all symbols, lookup the address of a symbol, or to read in symbols
from an alternate (ELF) file:
grmon3> symbols load v8/stanford.exe
grmon3> symbols lookup main
Found address 0x40004070
grmon3> symbols list
0x40005ab8 GLOBAL FUNC putchar
0x4000b6ac GLOBAL FUNC _mprec_log10
0x4000d9d0 GLOBAL OBJECT __mprec_tinytens
0x4000bbe8 GLOBAL FUNC cleanup_glue
0x4000abfc GLOBAL FUNC _hi0bits
0x40005ad4 GLOBAL FUNC _puts_r
0x4000c310 GLOBAL FUNC _lseek_r
0x4000eaac GLOBAL OBJECT piecemax
0x40001aac GLOBAL FUNC Try
0x40003c6c GLOBAL FUNC Uniform11
0x400059e8 GLOBAL FUNC printf
...
Reading symbols from alternate files is necessary when debugging self-extracting applications (MKPROM), when
switching between virtual and physical address space (Linux) or when debugging a multi-core ASMP system
where each CPU has its own symbol table. It is recommended to clear old symbols with symbols clear before
switching symbol table, otherwise the new symbols will be added to the old table.