This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Determining loaded libraries from a core file?
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Kevin Langman <langman at earthling dot net>
- Cc: gdb at sources dot redhat dot com
- Date: Tue, 25 Nov 2003 23:12:04 -0500
- Subject: Re: Determining loaded libraries from a core file?
- References: <20031126005031.27726.qmail@iname.com>
On Tue, Nov 25, 2003 at 07:50:31PM -0500, Kevin Langman wrote:
> I know this is a bit off topic but I hope someone on this list can help.
>
> I have build a debugging tool that is very specific to the code that I support. This debugger works directly with core files on other OSs and I have been working to port this debugger to Linux for a verity of platforms but I have hit a road block.
>
> My problem is this.. I need to determine what libraries were used by the process that crashed and where they were mapped into memory so that I can virtually map the library to the same address space for my debugger. GDB manages to find the libraries so I know it's possible but I can't see where in the core file this information is located?
>
> It had occurred to me that GDB might be looking at the executable (supplied as a parameter to GDB) and some how finding a way to map the libraries linked in to the executable to the PT_LOAD segments found in the core file defined with a 0 length file size. This seems very unlikely to me as this would mean that GDB would have no information about libraries that are programmatically loaded at run-time.
>
> Short and sweet version: Given a core file that crashes while executing code in library lib123.so, how do I determine that lib123.so was used by the process that crashed and how do I determine what memory address lib123.so was mapped to for that process.
>
> Any help would be much appreciated.
You need to walk the _DYNAMIC section of the executable. Take a look
at <link.h>. The code in GDB that you're interested in is probably
solib-svr4.[ch].
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer