aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-06-24[llvm] Remove full stop frome error messageJonas Devlieghere1-2/+2
Address post-commit feedback from James Henderson in D80959.
2020-06-11[Support] Don't tie errs() to outs() by defaultFangrui Song1-0/+4
This reverts part of D81156. Accessing errs() concurrently was safe before and racy after D81156. (`errs() << 'a'` is always racy) Accessing outs() and errs() concurrently was safe before and racy after D81156. Don't tie errs() to outs() by default to fix the fallout. llvm-dwarfdump is single-threaded and opting in the tie behavior is safe.
2020-06-02[llvm-dwarfdump] Print [=<offset>] after --debug-* options in help output.Jonas Devlieghere1-9/+33
Some of the --debug-* options can take an optional offset. Although the man page does a good job of making that clear, it's much harder to discover from the help output. Currently the only reference to this is the following sentence: > Where applicable these parameters take an optional =<offset> argument > to dump only the entry at the specified offset. This patch changes the help output from to print [=<offset>] after the options that take an offset. --debug-info[=<offset>] - Dump the .debug_info section rdar://problem/63150066 Differential revision: https://reviews.llvm.org/D80959
2020-05-14[llvm-dwarfdump] Make commandline arguments consistent.Xing GUO1-4/+1
Currently, llvm-dwarfdump's help message has two issues. 1. Most long options are printed in `--long-option`, except for some section dumping options, e.g., `-apple-names`, `-debug-addr`. 2. Most options are printed with consistent indention, except for some section dumping options. This patch helps resolve these two issues. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D79618
2020-04-19llvm-dwarfdump: Fix UB (unsequenced writes) introduced in e0fd87cc64d5David Blaikie1-3/+6
Unsequenced write due to "x &= f()" where 'f()' modifies 'x'. Detected by the llvm-clang-x86_64-expensive-checks-win buildbot. Investigated/identified by Galina - thanks!
2020-04-14Reapply "llvm-dwarfdump: Report errors when failing to parse ↵David Blaikie1-7/+10
loclist/debug_loc entries"" Originally committed as 416fa7720e30750939c53935051c6c750dfad2c2 Reverted (due to buildbot failure - breaking lldb) in 7a45aeacf3a23449039ef2efcf476995ae1c7007. I still can't seem to build lldb locally, but Pavel Labath has kindly provided a potential fix to preserve the old behavior in lldb by registering a simple recoverable error handler there that prints to the desired stream in lldb, rather than stderr.
2020-04-11Revert "llvm-dwarfdump: Report errors when failing to parse ↵David Blaikie1-10/+7
loclist/debug_loc entries" Broke an LLDB build bot & I can't seem to build LLDB locally to fix forward... http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/15567/steps/test/logs/stdio This reverts commit 416fa7720e30750939c53935051c6c750dfad2c2.
2020-04-10llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entriesDavid Blaikie1-7/+10
This probably isn't ideal - the error was being printed specifically inline with the dumping that was more legible - but then the error wasn't reported to stderr and didn't produce a non-zero exit code. Probably the error message could be improved by adding more context now that it isn't printed in-situ of the DIE dumping as much.
2020-04-10[llvm-dwarfdump] Interface cleanup. NFCFangrui Song1-9/+7
This patch moves interface declarations into llvm-dwarfdump.h and wrap declarations in anonymous namespaces as appropriate. At the same time, the externals are moved into the `llvm::dwarfdump` namespace`. Reviewed By: djtodoro Differential Revision: https://reviews.llvm.org/D77848
2020-04-09llvm-dwarfdump: Return non-zero on errorDavid Blaikie1-12/+17
Makes it easier to test "this doesn't produce an error" (& indeed makes that the implied default so we don't accidentally write tests that have silent/sneaky errors as well as the positive behavior we're testing for) Though the support for applying relocations is patchy enough that a bunch of tests treat lack of relocation application as more of a warning than an error - so rather than me trying to figure out how to add support for a bunch of relocation types, let's degrade that to a warning to match the usage (& indeed, it's sort of more of a tool warning anyway - it's not that the DWARF is wrong, just that the tool can't fully cope with it - and it's not like the tool won't dump the DWARF, it just won't follow/render certain relocations - I guess in the most general case it might try to render an unrelocated value & instead render something bogus... but mostly seems to be about interesting relocations used in eh_frame (& honestly it might be nice if we were lazier about doing this relocation resolution anyway - if you're not dumping eh_frame, should we really be erroring about the relocations in it?))
2020-04-02[llvm-dwarfdump] Add the --show-sections-sizes optionDjordje Todorovic1-2/+14
Add an option to llvm-dwarfdump to calculate the bytes within the debug sections. Dump this numbers when using --statistics option as well. This is an initial patch (e.g. we should support other units, since we only support 'bytes' now). Differential Revision: https://reviews.llvm.org/D74205
2020-03-10[NFC][llvm-dwarfdump] Always use 'const Twine &'Djordje Todorovic1-6/+6
According to the Twine.h comment, the Twines should only be used as const references in arguments. Differential Revision: https://reviews.llvm.org/D75727
2019-12-09[llvm/dwarfdump] Use the architecture string to filter.Jonas Devlieghere1-1/+1
Currently dwarfdump uses the ArchType to filter out architectures, which is problematic for architectures like arm64e and x86_64h that map back to arm64 and x86_64 respectively. The result is that the filter doesn't work for these architectures because it matches all the variants. This is especially bad because usually these architectures are the reason to use the filter in the first place. Instead, we should match the architecture based on the string name. This means the filter works for the values printed by dwarfdump. It has the unfortunate side effect of not working for aliases, like AArch64, but I think that's worth the trade-off. rdar://53653014 Differential revision: https://reviews.llvm.org/D71230
2019-10-08[Tools] Mark output of tools as text if it is textKai Nacke1-1/+1
Several LLVM tools write text files/streams without using OF_Text. This can cause problems on platforms which distinguish between text and binary output. This PR adds the OF_Text flag for the following tools: - llvm-dis - llvm-dwarfdump - llvm-mca - llvm-mc (assembler files only) - opt (assembler files only) - RemarkStreamer (used e.g. by opt) Reviewers: rnk, vivekvpandya, Bigcheese, andreadb Differential Revision: https://reviews.llvm.org/D67696 llvm-svn: 374024
2019-06-21[binutils] Add response file option to help and docsJames Henderson1-0/+2
Many LLVM-based tools already support response files (i.e. files containing a list of options, specified with '@'). This change simply updates the documentation and help text for some of these tools to include it. I haven't attempted to fix all tools, just a selection that I am interested in. I've taken the opportunity to add some tests for --help behaviour, where they were missing. We could expand these tests, but I don't think that's within scope of this patch. This fixes https://bugs.llvm.org/show_bug.cgi?id=42233 and https://bugs.llvm.org/show_bug.cgi?id=42236. Reviewed by: grimar, MaskRay, jkorous Differential Revision: https://reviews.llvm.org/D63597 llvm-svn: 364036
2019-06-21[llvm-dwarfdump] Remove unnecessary explicit -h behaviourJames Henderson1-7/+0
--help and -h are automatically supported by the command-line parser, unless overridden by the tool. The behaviour of the PrintHelpMessage being used for -h prior to this patch is subtly different to that provided by --help automatically (it omits certain elements of help text and options, such as --help-list), so overriding the default is not desirable, without good reason. This patch removes the explicit specification of -h and its behaviour, so that the default behaviour is used. Reviewed by: hintonda Differential Revision: https://reviews.llvm.org/D63565 llvm-svn: 364029
2019-06-14[docs][llvm-dwarfdump] Make the --show-parents and --show-children help text ↵James Henderson1-2/+2
and docs more consistent and correct The docs and help text for --show-parents and --show-children were a bit inconsistent. The help text claimed they had an effect when "=<offset>" was used, whereas the doc said it had an effect when "--find" or "--name" were used. This change changes the doc to mention "=<offset>" and removes this reference from the help text, to avoid having a very long description in the help text (it still says "when selectively printing entries"). Reviewed by: JDevlieghere, aprantl Differential Revision: https://reviews.llvm.org/D63275 llvm-svn: 363380
2019-06-11[llvm-dwarfdump] Simplify --ignore-case help text and documentationJames Henderson1-4/+3
There was a typo in the --ignore-case help text that was copied into the llvm-dwarfdump command-guide. Additionally, this patch simplifies the wording, since it was unnecessarily verbose: the switch applies for searching in general and doesn't need explicitly stating different search modes (which might go out-of-date as options are added or removed). Reviwed by: JDevlieghere Differential Revision: https://reviews.llvm.org/D63133 llvm-svn: 363066
2019-06-11[llvm-dwarfdump] Add -o to help text and remove --out-file from docJames Henderson1-5/+4
-o is in the documentation, but not in the llvm-dwarfdump help text. This patch adds it by inverting the -o and --out-file aliasing. It also removes --out-file from the documentation, since we don't really want people to be using this switch in practice. Reviewed by: aprantl, JDevlieghere, dblaikie Differential Revision: https://reviews.llvm.org/D63013 llvm-svn: 363044
2019-05-24[dwarfdump] Add flag to limit the number of parents DIEsJonas Devlieghere1-9/+15
This adds `-parent-recurse-depth` which limits the number of parent DIEs being dumped. Differential revision: https://reviews.llvm.org/D62359 llvm-svn: 361671
2019-04-24[CommandLine] Provide parser<unsigned long> instantiation to allow ↵Fangrui Song1-1/+2
cl::opt<uint64_t> on LP64 platforms Summary: And migrate opt<unsigned long long> to opt<uint64_t> Fixes PR19665 Differential Revision: https://reviews.llvm.org/D60933 llvm-svn: 359068
2019-04-04llvm-dwarfdump: Support alternative architecture names in the -arch filterAdrian Prantl1-7/+4
<rdar://problem/47918606> llvm-svn: 357706
2019-03-27[llvm-dwarfdump] Simplify -o handlingFangrui Song1-15/+10
ToolOutputFile handles '-' so no need to specialize here. Also, we neither reassign the variable nor pass it around, thus no need to use std::unique_ptr<ToolOutputFile>. exit(1) -> return 1; to call the destructor of raw_fd_stream llvm-svn: 357051
2019-02-27[DebugInfo] add SectionedAddress to DebugInfo interfaces.Alexey Lapshin1-3/+11
That patch is the fix for https://bugs.llvm.org/show_bug.cgi?id=40703 "wrong line number info for obj file compiled with -ffunction-sections" bug. The problem happened with only .o files. If object file contains several .text sections then line number information showed incorrectly. The reason for this is that DwarfLineTable could not detect section which corresponds to specified address(because address is the local to the section). And as the result it could not select proper sequence in the line table. The fix is to pass SectionIndex with the address. So that it would be possible to differentiate addresses from various sections. With this fix llvm-objdump shows correct line numbers for disassembled code. Differential review: https://reviews.llvm.org/D58194 llvm-svn: 354972
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-11-23Revert r347490 as it breaks address sanitizer buildsLuke Cheeseman1-0/+2
llvm-svn: 347499
2018-11-23Revert r343341Luke Cheeseman1-2/+0
- Cannot reproduce the build failure locally and the build logs have been deleted. llvm-svn: 347490
2018-10-24Make llvm-dwarfdump -name work on type units.Paul Robinson1-2/+2
Differential Revision: https://reviews.llvm.org/D53672 llvm-svn: 345203
2018-10-23[dwarfdump] Make incompatibility between -diff and -verbose explicit.Jonas Devlieghere1-1/+9
Using -diff and -verbose together doesn't work today. We should audit where these two options interact and fix them. In the meantime we error out when the user try to specify both. llvm-svn: 345084
2018-10-19Use llvm::{all,any,none}_of instead std::{all,any,none}_of. NFCFangrui Song1-1/+1
llvm-svn: 344774
2018-10-09llvm-dwarfdump: Extend --name to also search DW_AT_linkage_name.Adrian Prantl1-19/+32
rdar://problem/45132695 llvm-svn: 344079
2018-10-09Add missing spaceAdrian Prantl1-1/+1
llvm-svn: 344064
2018-09-28Revert r343317Luke Cheeseman1-0/+2
- asan buildbots are breaking and I need to investigate the issue llvm-svn: 343341
2018-09-28Reapply changes reverted by r343235Luke Cheeseman1-2/+0
- Add fix so that all code paths that create DWARFContext with an ObjectFile initialise the target architecture in the context - Add an assert that the Arch is known in the Dwarf CallFrameString method llvm-svn: 343317
2018-09-27Revert r343192 as an ubsan build is currently failingLuke Cheeseman1-1/+1
llvm-svn: 343235
2018-09-27Reapply changes reverted in r343114, lldb patch to follow shortlyLuke Cheeseman1-1/+1
llvm-svn: 343192
2018-09-27llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)Fangrui Song1-1/+1
Summary: The convenience wrapper in STLExtras is available since rL342102. Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits Differential Revision: https://reviews.llvm.org/D52573 llvm-svn: 343163
2018-09-26Revert r343112 as CallFrameString API change has broken lldb buildsLuke Cheeseman1-1/+1
llvm-svn: 343114
2018-09-26[AArch64] - Return address signing dwarf supportLuke Cheeseman1-1/+1
- Reapply r343089 with a fix for DebugInfo/Sparc/gnu-window-save.ll llvm-svn: 343112
2018-09-26Revert r343089 "[AArch64] - Return address signing dwarf support"Hans Wennborg1-1/+1
This caused the DebugInfo/Sparc/gnu-window-save.ll test to fail. > Functions that have signed return addresses need additional dwarf support: > - After signing the LR, and before authenticating it, the LR register is in a > state the is unusable by a debugger or unwinder > - To account for this a new directive, .cfi_negate_ra_state, is added > - This directive says the signed state of the LR register has now changed, > i.e. unsigned -> signed or signed -> unsigned > - This directive has the same CFA code as the SPARC directive GNU_window_save > (0x2d), adding a macro to account for multiply defined codes > - This patch matches the gcc implementation of this support: > https://patchwork.ozlabs.org/patch/800271/ > > Differential Revision: https://reviews.llvm.org/D50136 llvm-svn: 343103
2018-09-26[AArch64] - Return address signing dwarf supportLuke Cheeseman1-1/+1
Functions that have signed return addresses need additional dwarf support: - After signing the LR, and before authenticating it, the LR register is in a state the is unusable by a debugger or unwinder - To account for this a new directive, .cfi_negate_ra_state, is added - This directive says the signed state of the LR register has now changed, i.e. unsigned -> signed or signed -> unsigned - This directive has the same CFA code as the SPARC directive GNU_window_save (0x2d), adding a macro to account for multiply defined codes - This patch matches the gcc implementation of this support: https://patchwork.ozlabs.org/patch/800271/ Differential Revision: https://reviews.llvm.org/D50136 llvm-svn: 343089
2018-08-02[DebugInfo/DWARF] Remove redundant iterator type. NFCPaul Robinson1-2/+2
llvm-svn: 338759
2018-06-13Fix "Optional" is ambiguous error on some botsPavel Labath1-1/+1
llvm-svn: 334580
2018-06-13[DWARF/AccelTable] Remove getDIESectionOffset for DWARF v5 entriesPavel Labath1-16/+45
Summary: This method was not correct for entries in DWO files as it assumed it could just add up the CU and DIE offsets to get the absolute DIE offset. This is not correct for the DWO files, as here the CU offset will reference the skeleton unit, whereas the DIE offset will be the offset in the full unit in the DWO file. Unfortunately, this means that we are not able to determine the absolute DIE offset using the information in the .debug_names section alone, which means we have to offload some of this work to the users of this class. To demonstrate how this can be done, I've added/fixed the ability to lookup entries using accelerator tables in DWO files in llvm-dwarfdump. To make this happen, I've needed to make two extra changes in other classes: - made the DWARFContext method to lookup a CU based on the section offset public. I've needed this functionality to lookup a CU, and this seems like a useful thing in general. - made DWARFUnit::getDWOId call extractDIEsIfNeeded. Before this, the DWOId was filled in only if the root DIE happened to be parsed before we called the accessor. Since the lazy parsing is supposed to happen under the hood, calling extractDIEsIfNeeded seems appropriate. Reviewers: JDevlieghere, aprantl, dblaikie Subscribers: mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D48009 llvm-svn: 334578
2018-05-31DWARFAcceleratorTable: fix equal_range iteratorsPavel Labath1-25/+29
Summary: Both (Apple and DWARF5) implementations of the iterators had bugs which resulted in crashes if one attempted to iterate through the accelerator tables all the way. For the Apple tables, the issue was that we did not clear the DataOffset field when we reached the end, which made our iterator compare unequal to the "end" iterator. For the Dwarf5 tables, the problem was that we incremented the CurrentIndex pointer and then used the incremented (possibly invalid) pointer to check whether we have reached the end of the index list. The reason these bugs went undetected is because their only user (dwarfdump) only ever searched for the first match. Besides allowing us to test this fix, changing llvm-dwarfdump --find to display all matches seems like a good improvement (it makes the behavior consistent with the --name option), so I change llvm-dwarfdump to do that. The existing tests would be sufficient to test this fix with the new llvm-dwarfdump behavior, but I add a special test that demonstrates that the tool indeed displays multiple results. The find.test test needed to be tweaked a bit as the tool now does not print the ".debug_info contents" header (also consistent with how --name works). Reviewers: JDevlieghere, aprantl, dblaikie Subscribers: mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D47543 llvm-svn: 333635
2018-05-24[Support] Add color cl category.Jonas Devlieghere1-1/+2
This commit adds a color category so tools can document this option and enables it for dwarfdump and dsymuttil. rdar://problem/40498996 llvm-svn: 333176
2018-05-08[DebugInfo] Accept `S` in augmentation strings in CIE.Fangrui Song1-1/+1
glibc libc.a(sigaction.o) compiled from sysdeps/unix/sysv/linux/x86_64/sigaction.c uses "zRS". llvm-svn: 331738
2018-04-13Define InitLLVM to do common initialization all at once.Rui Ueyama1-7/+2
We have a few functions that virtually all command wants to run on process startup/shutdown. This patch adds InitLLVM class to do that all at once, so that we don't need to copy-n-paste boilerplate code to each llvm command's main() function. Differential Revision: https://reviews.llvm.org/D45602 llvm-svn: 330046
2018-03-09[DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementationsPavel Labath1-1/+1
Summary: Even though the getDIEOffset offset function was common for the two accelerator table implementations, it was doing two different things: for the Apple tables, it was returning the die offset relative to the start of the section, whereas for DWARF v5 tables, it was relative to the start of the CU. I resolve this by renaming the function to getDIESectionOffset to make it obvious what the function returns, and change the DWARF implementation to return the section offset. I also keep the CU-relative accessor, but only in the DWARF implementation (there is no way to get this information for the Apple tables). This was not caught by existing tests because the hand-written inputs also erroneously used section offsets instead of CU-relative ones. While looking at this, I noticed that the Apple implementation was not fully correct either -- the header contains a DIEOffsetBase field, which should be added to offsets encoded with the DW_FORM_ref*** family, but this was not being used. This went unnoticed because all current writers set this field to zero anyway. I fix this as well and add a hand-written test which demonstrates the issue. Reviewers: JDevlieghere, dblaikie Subscribers: aprantl, llvm-commits Differential Revision: https://reviews.llvm.org/D44202 llvm-svn: 327116
2018-02-24Fix build breakage from r326003Pavel Labath1-2/+2
- an ambiguous reference to Optional<T> in llvm-dwarfdump.cpp (fixed with an explicit prefix). - a missing base class initialization in Entry copy constructor (fixed by using the implicitly default constructor, which is possible after some changes which were done during review). llvm-svn: 326006