This is the simplest case. Both the DLL and the program have GDB
compatible debugging information. It is then possible to break anywhere in
the process. Let's suppose here that the main procedure is named
ada_main
and that in the DLL there is an entry point named
ada_dll
.
The DLL (see Introduction to Dynamic Link Libraries (DLLs)) and program must have been built with the debugging information (see GNAT -g switch). Here are the step-by-step instructions for debugging it:
GDB
on the main program.
$ gdb -nw ada_main
(gdb) break ada_main (gdb) run
This step is required to be able to set a breakpoint inside the DLL. As long as the program is not run, the DLL is not loaded. This has the consequence that the DLL debugging information is also not loaded, so it is not possible to set a breakpoint in the DLL.
(gdb) break ada_dll (gdb) run
At this stage a breakpoint is set inside the DLL. From there on you can use the standard approach to debug the whole program (see Running and Debugging Ada Programs).
To break on the DllMain
routine it is not possible to follow
the procedure above. At the time the program stop on ada_main
the DllMain
routine as already been called. Either you can use
the procedure below see Debugging the DLL Directly or this procedure:
GDB
on the main program.
$ gdb -nw ada_main
(gdb) add-sym api.dll
(gdb) break ada_dll.adb:45
Note that at this point it is not possible to break using the routine symbol directly as the program is not yet running. The solution is to break on the proper line (break in ada_dll.adb line 45).
(gdb) run