WDB Support for GNU gdb-5.0
by Till Straumann <strauman@slac.stanford.edu>
Last modified: May 2nd, 2001
Introduction
gdb is an open-source debugger which is released under the GNU
general public license. gdb supports many different platforms,
both as a native and as a cross debugger.
One among the supported targets is the vxWorks
(tm) real-time kernel. vxWorks features a so called "remote agent",
which, among other things can be used for remote debugging. gdb
(running on a host computer) talks to the remote agent speaking a dedicated
network protocol. Until version 5.3 of vxWorks, there were two different
agents and protocols: RDB and WDB. WindRiver had written and released to
the public, the RDB client for gdb which enabled the debugger to
connect to vxWorks targets. However, as of version 5.4, vxWorks no longer
supports RDB and the RDB server is no longer present.
This page describes a patch for gdb which provides WDB (the newer
protocol) support.
WDB Support
WindRiver removed the RDB server as of vxWorks 5.4. The patch which is
downloadable from this page implements support for the newer WDB protocol
and target agent. Note that you need additional software for running gdb
with the vxworks target:
-
small architecture specific piece of code (read/write registers), see:
'remote-vx<arch>.c'. Currently, I have only implemented remote-vxppc.c
(PowerPC); however adding support for other architectures should be straightforward
(you'd need to tweak the config/<arch>/vxworks.h, configure.in and maybe
Makefile.in file also.)
-
the wdb library source code (distributed by WindRiver with vxWorks). We
should ask them if they are willing to release this code to the public...
-
my 'tillRdb' package. There is some functionality lacking in WDB. Therefore,
I created code that implements the necessary subset of the RDB protocol.
You need to compile it for and load it to the target. Then issue 'startRdb'
(on the target).
Note: you can still use vxgdb without my rdb server but some functionality
will be missing (i.e. essentially everything that deals with files: uploading
files, guessing path names etc.) Without tillRdb, you have to specify an
additional parameter to the "target vxworks" command if you want to use
symbols exported by vxWorks:
target vxworks <vxworks_image_file_path>
also, you have to tell gdb explicitely what modules are loaded (because
it connot ask the target):
file <path_to_my_module>
New Features / TODO
attach 0
command. If you set a breakpoint and attach to task id 0, the first task
that hits the breakpoint will stop, i.e. you don't have to know its id
in advance.
semantics of the 'run' command: 'run' takes (almost) the same arguments
like the target shell's 'taskSpawn', i.e.
run <name> <priority> <options> <stack_size> <arg> <arg> ...
(note that no task name can be given; <name> is the text-symbol of the
code you want to run). If you omit parameters, vxgdb uses default values
(prio=100, options=0, stack=20000), hence
run helloWorld 50
starts 'helloWord' in a new task context on the target with a priority
of 50, no options and a stack size of 20000.
IMPORTANT: you can _only_ pass integer arguments to the created task,
i.e.
run printf 100 0 20000 "hello world\n"
does not work. (vxgdb does not allocate a string on the target and
pass its address to the created task but creates a string locally [on the
host] passing the local address to the target).
Lacking functionality: WDB does not allow for multiple (simultaneous) connections.
Therefore, it is currently not possible to concurrently run multiple vxgdb
sessions (connected to the same target). However, I heard of somebody having
created a "WDB multiplexor" for this purpose. I do not know whether it
would be hard to integrate it with my software.
Notes
GUI Front End
I strongly recommend the excellent GUI frontend "ddd"
for use with gdb.
Object File Path
gdb searches for object files in all directories specified in the PATH
environment variable. Note that the relevant variable connot be changed
from within gdb. The "set environ PATH"
command only affects the environment of processes created by gdb (perhaps
pointless for the vxworks target) and not the environment of gdb itself!
You must set the PATH variable to point to the directories holding
any vxWorks objects before starting gdb.
Installation
What you need
-
gdb-5.0 source distribution
-
this patch file
-
the WDB host interface. This consists of a couple of source and header
files distributed by WindRiver with vxWorks. In vxWorks-5.4 the necessary
files are located in <WIND_HOME>/share/src/agents/wdb
-
native compiler and utilites for compiling gdb.
-
cross-compiler and utilities for building the mini-RDB server that runs
on the target. (see README.wdb).
Building the Package
-
unpack the sources for gdb-5.0
-
'cd' to the <TOP>/gdb subdirectory.
-
create a directory 'vx-wdb' and copy or symlink the following files from
the vxworks tree (at WIND_HOME/share/src/agents/wdb) to the new directory
'vx-wdb': ctx.c ctxstep.c evtpoint.c memory.c rpccksum.c xdrcore.c ctxcreat.c
evtdata.c regs.c wrapper.c wdb.h wdbP.h
-
'cd' to the gdb-5.0 top directory and apply the patch:
patch -p1 < patch_file
Note that the -p1 option is important.
create a directory for the build e.g.
mkdir build-powerpc-vxgdb
'cd' to the build directory and configure the package:
../configure --target=powerpc-vxworks --enable-vxwdb
(NOTE: by default WDB support is not enabled).
'make' and 'make install' etc...
Building the RDB Server
unpack the tillRdb.tgz archive, cd to the topdir and follow the instructions
in the README file.
Download
-
tillRdb, a tiny RDB server which implements
the functionality lacking in WDB
-
patch for gdb-5.0 which implements
WDB support