New feature "source-id"

Gerhard Gappmeier
2014-03-15T10:49:40Z

[-- Attachment #1: Type: text/plain, Size: 3067 bytes --]

Hi all,

I've implemented a new feature that I call "source-id" analogous to the
existing "build-id" functionality. Unlike fetching debug symbols automatically
using build-ids this feature can fetch the correct source code from a version
control system when debugging.
The idea is that when you need to debug an executable or opening a coredump of
an executable that was built with "source-id" and "build-id" enabled it just
works. You don't need to care about how and where to get debug symbols and the
correct sources.

How does this works? The technical details are explained in the README.md
hosted in my test repository: https://github.com/gergap/source-id
(The content of README.md is shown on this site nicely formatted)
This repository contains an example that I used to test the new feature.
It also contains example "source-fetch-scripts" that are used by GDB to fetch
the source code. This should probably be bundled with GDB itself. Just give me
a hint where the best location would be to add these files in the GDB repo.

The GDB patches you find here: https://github.com/gergap/binutils-gdb
on the branch gergap/source-id-feature

What has been changed in GDB:
* add support for a new .note section ".note.gnu.source-id" to be able to
store and retrieve the VCS data from an ELF file.
* add new gdb commands: "set source-lookup ", "unset source-lookup",
"show source-lookup". This way the source-lookup functionality can be enabled.
* change function open_source_file to fetch the source file using the external
fetch script.
* disable mtime check when source-lookup is enabled to avoid the warning
"Source file is more recent than executable". It is normal that the timestamp
is newer when it was just fetched using a VCS like git.

What I need from you guys:
* Feedback if you like the feature or not. I really hope this feature can make
it into mainline as it is really useful.
* Feedback on the implementation: Security, CodingStyle, etc.
* We need to make the new section ".note.gnu.source-id" official. I don't know
who maintains this and this needs to be registered somewhere.

Future work:
* adding file hashes (SHA1) for each source file to the debug info. This way
we can completely remove the mtime check and replace it with a check of the
SHA1 sum. When we can replace the existing warning with a message like "The
source file does not match the executable."
* this hash can also be used to implement reliable caching for the "fetch-
scripts"

--
mit freundlichen Grüßen / best regards

Gerhard Gappmeier
ascolab GmbH - automation systems communication laboratory
Tel.: +49 9131 691 123
Fax: +49 9131 691 128
Web: http://www.ascolab.com
GPG-KeyId: 5AAC50C4
GPG-Fingerprint: 967A 15F1 2788 164D CCA3 6C46 07CD 6F82 5AAC 50C4

--
ascolab GmbH
Geschäftsführer: Gerhard Gappmeier, Matthias Damm, Uwe Steinkrauß
Sitz der Gesellschaft: Am Weichselgarten 7 • 91058 Erlangen • Germany
Registernummer: HRB 9360
Registergericht: Amtsgericht Fürth

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]