This is an archive of the discontinued LLVM Phabricator instance.

Teach the llvm-readobj COFF dumper to dump debug line tables from object files
ClosedPublic

Authored by timurrrr on Dec 17 2013, 7:58 AM.

Details

Summary

[Extracted from D2232]

Diff Detail

Event Timeline

timurrrr updated this revision to Unknown Object (????).Dec 18 2013, 1:37 AM

Fix unused variable warning on Linux by adding an extra check

timurrrr updated this revision to Unknown Object (????).Dec 18 2013, 1:54 AM

Add some comments, checks and polish to the code

timurrrr updated this revision to Unknown Object (????).Dec 18 2013, 1:58 AM

Refined some boundary checks

echristo accepted this revision.Dec 18 2013, 1:36 PM

Not so fond of the formatting, but seems at least reasonable.

tools/llvm-readobj/COFFDumper.cpp
670

4? An enum maybe or something else?

695

Same here with F2, F3, F4...

788

Preceded? Awesome.

Do I read it correctly as "LGTM but please use enum here and here?"

It's probably reasonable to put the enum in some coff related header shared
between lib/AsmPrinter and lib/Tools
19 дек. 2013 г. 1:35 пользователь "Eric Christopher" <echristo@gmail.com>
написал:

Not so fond of the formatting, but seems at least reasonable.

Comment at: tools/llvm-readobj/COFFDumper.cpp:669
@@ +668,3 @@
+ W.printHex("Magic", Magic);
+ if (Magic != 4) {

+ error(object_error::parse_failed);

4? An enum maybe or something else?

Comment at: tools/llvm-readobj/COFFDumper.cpp:694
@@ +693,3 @@
+ switch (SubSectionType) {
+ case 0xF2: {
+ // F2 is a PC to file:line table. Some data to parse this

subsection is

Same here with F2, F3, F4...

Comment at: tools/llvm-readobj/COFFDumper.cpp:787
@@ +786,3 @@
+ StringTable.data()[FilenameOffsetInF3 - 1] != '\0') {
+ // Each string in an F3 subsection should be preceded by a null

+ // character.

Preceded? Awesome.

http://llvm-reviews.chandlerc.com/D2425

timurrrr updated this revision to Unknown Object (????).Dec 19 2013, 3:40 AM

Addressed the review comments

Going to land this now

tools/llvm-readobj/COFFDumper.cpp
670

Done

695

Good point - added an enum to include/llvm/Support/COFF.h

788

Yes, each string is both preceded (checked here) and succeeded (that's why we check for the EOL null) by a null character.
Two adjacent strings share the delimiting null character like so:
|0xF3|Size|0x0|String1|0x0|String2|0x0|...|0x0|StringLast|0x0|

timurrrr closed this revision.Dec 19 2013, 3:42 AM

r197674.

And thanks for the review!