Debug a shared library
For x86 and PowerPC Deos executables in ELF binary format, Deos can load shared libraries within a virtual address range that Deos finds convenient in preventing shared library collisions. In other words, Deos can perform "base relocation," loading shared libraries into areas of the process Virtual Address Space (VAS) such that they don't overlap each other. That's right. No more need to manage Dynamic Link Library link addresses manually. This feature always existed on the PowerPC Deos versions, and has been added for x86 versions in kernel version 7.1.0 ("Agave").
So, cool, no more having to manually manage where shared libraries are loaded into VAS. That's great when things are working, but during development/debug, things rarely are working so great. What happens when I experience a page fault (access violation) or some other processor exception in a shared library, and I need to know where Deos loaded the shared library? How can I use the debugger to query the appropriate virtual addresses and debug the problem? Enter the status monitor "R P E" command:
- The R P E command stands for "Report Process Executable load addresses." From the online help built into status monitor: "Report process executable load addresses. This shows load address for each [ELF] file in a process. This only works for ELF executables and shared object files. By default, only the executables for the process specified are included. '*' causes all processes to be reported."
If you get your DESK via the cygwin based installer <https://deos.ddci.com/extracted/desk/help/cygwin-howto.htm>, firing up the cygwin installer and refreshing your workstation to the latest package releases will get the latest status monitor (if you don't already have it.) You could then transfer it to your Deos target via FTP, or build a new hyperstart image containing it and Flash load to your target. Be sure to read the status monitor release notes for any integration or compatibility issues: <ftp://deos.ddci.com/deos-products/status-monitor/status-monitor/stable/release-notes-status-monitor.txt>
If you don't use the cygwin installer, you can manually download the status monitor package and install it at $DESKHOME: <ftp://deos.ddci.com/deos-products/status-monitor/status-monitor/stable>
Sometimes the shared library experiencing the exception could be one supplied by the Deos team (what?! No way!). If that happens, it may be handy to have access to the source code. With the Deos team's switch to Subversion <http://subversion.tigris.org/> as our SCM system, it is now a lot easier for you to get at Deos team supplied shared library code. You can use your web browser to view our SCM repository <https://deos.ddci.com/scm/Deos/products/>, or we currently allow anaonymous checkouts from our repository for all software components except for the Deos kernel. Use your favorite Subversion client to do that. The command line Subversion client is included in cygwin, so you may already have it and not even realize it. Steps for checking files out are documented in our online procedures at <https://deos.ddci.com/scm/Deos/docs/howto/configuration-management-howto/configuration-management-howto.htm#checkout-commit>
Some tips on getting a Subversion client are at <https://deos.ddci.com/scm/Deos/docs/howto/configuration-management-howto/configuration-management-howto.htm#client-installation>
Lastly, you may need linker map files for an upset shared library. Most of the Deos supplied shared libraries include linker map files in their distributions, but not all. It's a hit or miss as we've just recently made a process change to start including them in our builds. If you need one and can't find it in the DESK, contact us and we'll see if we can get you one from the archives. Alternatively, you might be able to use the 'objdump' command to dump the internals of the shared library binary. Oh, and don't forget that we also supply debug versions as well. Loading them and giving it another go may yield helpful additional error messages on your telnet system video stream window.
For a self-pace tutorial on using the GDB debugger with shared libraries, refer to the Insight Debugger How-to.