How to Debug NLM's with GDB  (was made for FreePascal but works with other compilers too)

I tried gdbserve.nlm (it is part of gdb) a year ago but with very limited succsess. It runs only on Netware 4.11 and often abends.

Then i figured out the protocol that Netware supports for remote debugging. (NDI) I wrote some pascal code to support that interface and thought about writing my own debugger but after writing some code for reading the stabs info i gave up. The difference and specials that differnt compilers generate are the hell on earth.

Then i read the gdb documentation and saw the fairly simple remote protocol, i got it: Write a protocol converter between gdb and ndi. I tried it and after a few hours i was able to load a test nlm (generated with FreePascal) and to single step instructions.

I did this using the ethernet transport build in to Netware (using ne2000 isa in the Server). As of Version 0.9, DBNet6 also works. Novell has changed the Portnumber. (it was ignored by Rdebug ne2000)
The serial protocol is also implemented but it is a little bit delicate to handle. In case a packet was send and answered by the server, you can not immediately send the next packet, the server will flush half of that packet and you get a lot of errors. Trying a lot got the result that the server needs about 100ms to become ready for the next packet. That makes the serial communication a little bit slow. (There is no problem with ethernet)

How it works

The converter is called gdb2ndi and runs under linux or win32. After starting, gdb2ndi connects to the Netware debugger serial or via udp and loads the specified nlm. The nlm will be executed to _Prelude.  Now gdb2ndi waits for the incomming tcp connection from gdb. As of version 1.0, there is an opetional nlm that can be loaded on the server. With that helper nlm, the debugger invocation as well as the nlm-load on netware 6.5 sp2 and sp3 beta can be automated.

Doumentation

see:  included man page

To Do

Floting Point Registers: I have not fully figured out the structure sent by NDI, only st0..st7 are currently send to gdb
Hardware Watchpoints: I have implemented them but gdb does not send the packets, does someone know how to enable Hardware watchpoints in gdb ?
Attaching to a process is not implemented (not complicated but up to now i had no need for it)
Screens: Can not displayed within gdb (does gdb have commands for that ?), could also be implemented by another port that can be connected with telnet
extended-remote: This is supported by gdb2ndi but current gdb versions have a problem here. Gdb assumes that the restarted program is loaded in the same address range and does not query for offsets. Gdb needs to be changed to query the offsets after a restart.

Changes from 1.00 to 1.01:


Changes from 0.91 to 1.0:


Changes from 0.9 to 0.91:

Download Version 1.01
 
gdb2ndi for Linux (binary)
gdb2ndi for Win32 (binary)
Source written in FreePascal

you  also need a gdb-version compiled with netware support. I have compiled gdb for Win32 and Linux:

gdb 5.3 for Linux (rpm for redhat 7.x, i think it is also usable for 8.x)
gdb 6.1.1 for Linux (rpm for redhat 9)
gdb 5.3 for win32

Links

GNU Visual Debugger (a graphical front-end to gdb for win32 and unix) (in action)
DDD (a graphical front-end for unix)
Insight (a gdb version with integrated gui written in Tcl/Tk)
I tried insight under Win32 cygwin and at least the last cvs version compiled. It was a little bit slow but it may work better under unix.
cgdb (a curses based textmode front-end for gdb, runs under linux, the current version (0.2.3) may or may not run under Win32, versions from 0.3 on should work under win32) (in action)
gdb
Bernd Herd's gcc with c++ support for Netware
Pavel Novy's site for gcc with netware support
Günter Knauf's Netware Links


comments: Mail