[RFC] new substitute path when loading feature
Aleksandar Ristovski
aristovski@qnx.com
Tue May 13 18:56:00 GMT 2008
Hello,
For us who deal with mixed-platform development environment it is common to debug binaries built on a different machine, often different OS. A real-life example:
development environment (sdk) is setup on a win32 machine, with headers and all. When compiled, binaries are being debugged on a linux-hosted gdb. Linux machine has the same development environment (sdk) only in different root directories. Where win32 may have C:/foo, linux will have /opt/foo, etc...
To properly translate the paths it is useful to be able to tell gdb to translate such paths into new environment. Existing "substitute-path" functionality seems like the most logical choice, and the diff exploits this to add new feature - rewriting source paths at readin time.
The difference can be observed if a binary built on a win32 system is loaded in gdb on linux. For example
(gdb) maint info symtabs
....
{ symtab C:/QNX632/target/qnx6/usr/include/sys/compiler_gnu.h
((struct symtab *) 0x8390808)
dirname c:/Temp/dirs/debug
fullname (null)
blockvector ((struct blockvector *) 0x8392f24)
linetable ((struct linetable *) (nil))
debugformat unknown
}
{ symtab ../main.c ((struct symtab *) 0x83907b0)
dirname c:/Temp/dirs/debug
fullname (null)
blockvector ((struct blockvector *) 0x8392f24) (primary)
linetable ((struct linetable *) 0x8392f9c)
debugformat DWARF 2
}
...
while with the patch:
(gdb) set substitute-path-at-source 1
(gdb) set substitute-path C:/QNX632 /opt/qnx632
(gdb) set substitute-path c:/Temp /tmp
(gdb) symbol-file /tmp/dirs/debug/main
Load new symbol table from "/tmp/dirs/debug/main"? (y or n) y
Reading symbols from /tmp/dirs/debug/main...done.
(gdb) maint info symtabs
....
{ symtab /opt/qnx632/target/qnx6/usr/include/sys/compiler_gnu.h
((struct symtab *) 0x8379c10)
dirname /tmp/dirs/debug
fullname (null)
blockvector ((struct blockvector *) 0x837c32c)
linetable ((struct linetable *) (nil))
debugformat unknown
}
{ symtab ../main.c ((struct symtab *) 0x8379bb8)
dirname /tmp/dirs/debug
fullname (null)
blockvector ((struct blockvector *) 0x837c32c) (primary)
linetable ((struct linetable *) 0x837c390)
debugformat DWARF 2
}
...
Thanks,
Aleksandar Ristovski
QNX Software Systems
ChangeLog:
2008-05-13 Aleksandar Ristovski <aristovski@qnx.com>
* Makefile.in (buildsym.o): Add new dependency.
* buildsym.c (source.h): New include.
(start_subfile): Rewrite path is substitute-path-at-source is set.
* source.c (substitute_pat_at_source): New variable.
(rewrite_source_path): Make external.
(_initialize_source): Add new set/show variable
'substitute-path-at-source'.
* source.h (rewrite_source_path substitute_pat_at_source): New
declarations.
* symfile.c (start_psymtab_common): Rewrite file name if
substitute-path-at-source is set.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: substitute-path-at-source.diff
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080513/40266178/attachment.ksh>
More information about the Gdb-patches
mailing list