This is an archive of the discontinued LLVM Phabricator instance.

llvm-objdump --section, -j section filtering
ClosedPublic

Authored by colinl on Jul 24 2015, 9:15 AM.

Details

Summary

This patch adds the --section and -j options to llvm-objdump to specify a section to dump.

One thing that needs to be addressed is the --section flag is in conflict with the MachO flag of the same name. We either need to change the name of the filtering flag which might be unexpected behavior for people coming from other toolchains or change the MachO flag which would change existing behavior.

My recommendation would be changing the machO flag to --macho-section.

Diff Detail

Repository
rL LLVM

Event Timeline

colinl updated this revision to Diff 30576.Jul 24 2015, 9:15 AM
colinl retitled this revision from to llvm-objdump --section, -j section filtering.
colinl updated this object.
colinl added reviewers: rafael, loladiro, majnemer.
colinl set the repository for this revision to rL LLVM.
colinl added a subscriber: llvm-commits.
colinl added a subscriber: colinl.Jul 24 2015, 1:00 PM

Using the same option is a possibility, as long as there's not a case where we'd want to use both at the same time. Looking in DumpInput it looks like if -macho is set it'll follow the ParseInputMachO path whereas otherwise it will dump it as an archive or object file so this seems like they're currently mutually exclusive.

Agreed on the test case, I'll prepare something and modify the patch.

colinl updated this revision to Diff 30713.Jul 27 2015, 11:44 AM

After discussing with Kevin Enderby it seemed like merging the usage of --section seemed feasible. This is the merged result as well as a test showing sections being filtered.

filcab added a subscriber: filcab.Jul 28 2015, 10:54 AM

Just some nitpicky details.
I also prefer to have empty lines before class definitions, but that might just be due to the way I use my editor.

Thank you,
Filipe

tools/llvm-objdump/llvm-objdump.cpp
204

We're *not* keeping the ones where the predicate returns true?
I'd prefer to call it FilterOut, or reverse this condition.

237

Is this an appropriate value to return?

243

return std::find(Sections.begin(), Sections.end(), String) == Sections.end();

(or != Sections.end() if you switch the predicate around)

tools/llvm-objdump/llvm-objdump.h
28

Please split this in two commits: Renaming (and moving between .cpp files) DumpSections to Sections, and the the functional change.

29

Are you changing whitespace in line 29? Adding \r? (The diff on phabricator looks weird)
If you're changing WS, please split that to another commit. If you're adding \r, please don't. :-)

For the time being I added this with just the -j flag. One concern I had with merging the --section flag was it looks like some MachODump operations iterate over all sections and people may want to filter those down which wouldn't be available since --section would mean something else when MachO dumping.

printMachOUnwindInfo, SegInfo, printObjc2_32bit_MetaData are things I was thinking of.

colinl accepted this revision.Jul 29 2015, 8:52 AM
colinl added a reviewer: colinl.

Submitted in r243526 with just the "j" flag and without MachO changes.

Still working on if we should do anything with the conflicting --section flag.

This revision is now accepted and ready to land.Jul 29 2015, 8:52 AM
colinl added inline comments.Jul 29 2015, 8:56 AM
tools/llvm-objdump/llvm-objdump.cpp
237

The only other alternative I considered was returning a bool, otherwise the return types match exactly, int. Is there another possibility to consider?

243

True, I'll make that change.

Merged MachO DumpSections in to FilterSections with 243556. Also simplifying the filtering logic as suggested. Leaving open though if more changes are wanted.

tools/llvm-objdump/llvm-objdump.cpp
204

I could see how that could be better, let me take a look at which way would make more sense.

tools/llvm-objdump/llvm-objdump.h
28

Sorry I didn't address this before submitting, that was unintentional I have to get better at phabricator.

29

I think I have SVN configured to make sure it only submits proper LF. This should just be an artifact of the diff upload.

colinl closed this revision.Aug 6 2015, 12:29 PM