ChorusOS 5.0 Debugging Guide

Loading and Executing the Application

To debug an application with GDB, use the file command to specify its executable pathname on the host. Because GDB for ChorusOS systems is a cross-debugging tool, the debugged process is created remotely on the target by the target itself. The target view of files is different from the host view (the target root directory is usually a subdirectory on the host filesystem). It is therefore necessary to translate the host pathname of the executable file into its corresponding target form. GDB for ChorusOS includes a path translation mechanism for this purpose.

A default path translation (provided by RDBC) is established when you connect to a target using the NFS mount point information. It is possible to change this default translation, if necessary, using the rdbpathtranslate hostpath targetpath command. If a host pathname starts with hostpath, this portion of the pathname is replaced with targetpath. The default target path is /.

The following examples show how an application is executed for a debugging session with and without the use of rdbpathtranslate.


Example 2-1 Loading and Executing Normally

In the following example, the pathname of the executable matches the default path translation, so there is no need to change the path.


(chgdb) file root_dir/bin/examples/timers_u
Reading symbols from root_dir/bin/examples/timers_u...done.
(chgdb) run
Starting program: root_dir/bin/examples/timers_u
Program exited normally.
(chgdb)



Example 2-2 Loading and Executing With rdbpathtranslate

In the following example, the default path translation does not match the pathname of the executable.


(chgdb) file build_dir/build-EXAMPLES/progov/timers_u
Reading symbols from build_dir/build-EXAMPLES/progov/timers_u...done.
(chgdb) rdbpathtranslate
Syntax is: rdbpathtranslate <host-path> [target-path]
Currently 'build_dir/root' '/'
(chgdb) run
Starting program: build_dir/build-EXAMPLES/progov/timers_u
Warning: executable path 'build_dir/build-EXAMPLES/progov/timers_u'
does not match the path translation set with 'rdbpathtranslate'
(from 'build_dir/root' to '/').
It will be used without translation.
Unable to create remote process (remote problem): 
File not found (maybe / has changed).
(chgdb)

In the preceding example, the pathname of the executable is build_dir/build-EXAMPLES/progov/timers_u. It does not start with hostpath, which is build_dir/root. However, the build_dir directory has been mounted as /tests on the target:


(chgdb) i rdbmounted
TYPE     MOUNTPOINT        NAME
pdevfs   /                 root_device
pdevfs   /dev              pdevfs
pdevfs   /image            pdevfs
msdos    /image/sys_bank   /dev/bd01
nfs      /                 local_host_ip:/build_dir/root
nfs      /tests            local_host_ip:build_dir
(chgdb)

You can execute the program successfully by redefining the path translation as follows:


(chgdb) rdbpathtranslate build_dir /tests
(chgdb) run
Starting program: build_dir/build-EXAMPLES/progov/timers_u
Program exited normally.
(chgdb)

To Analyze a Process Dump

This procedure shows how a process is executed for a process dump rather than a standard debugging session.

  1. Load the executable.


    (chgdb) file root_dir/bin/examples/timers_u
    Reading symbols from root_dir/bin/examples/timers_u...done.
  2. Examine the available process dumps.

    The available process dumps appear as stopped processes in the process list. Use the info command to display the process list.


    (chgdb) info rdbprocesses
    PID  STATE  OWNERS  UID  PRIVLGE  THREADS  NAME (PATH)
    1    Stop   0       0    Usr      2        core_timers_u
  3. Attach to the selected process.

    Use the attach command to attach to the selected process id:


    (chgdb) attach 1
    Attaching program: root_dir/bin/examples/timers_u pid 1.
    [Switching to Thread 6 ()] 
    0xeffe41b8 in sampleThread () at root_dir/opt/examples/progov/timers.c:93
    
    93 res = timerThreadPoolWait(&samplePool, &cookie, &overrun, K_NOTIMEOUT); 
    (chgdb) 

Note -

When analyzing process dumps, certain standard commands (cont, next, step, run), and certain ChorusOS commands do not work.