aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-04-03[llvm-dwarfdump] Make --verify for .debug_names multithreaded. (#127281)Alexander Yermolovich1-1/+17
This PR makes verification of .debug_names acceleration table multithreaded. In local testing it improves verification of clang .debug_names from four minutes to under a minute. This PR relies on a current mechanism of extracting DIEs into a vector. Future improvements can include creating API to extract one DIE at a time, or grouping Entires into buckets by CUs and extracting before parallel step. Single Thread 4:12.37 real, 246.88 user, 3.54 sys, 0 amem,10232004 mmem Multi Thread 0:49.40 real, 612.84 user, 515.73 sys, 0 amem, 11226292 mmem
2025-03-17[NFC][DebugInfo] Wrap DILineInfo return type with std::optional to handle ↵Zequan Wu1-2/+6
missing debug info. (#129792) Currently, `DIContext::getLineInfoForAddress` and `DIContext::getLineInfoForDataAddress` returns empty DILineInfo when the debug info is missing for the given address. This is not differentiable with the case when debug info is found for the given address but the debug info is default value (filename:linenum is <invalid>:0). This change wraps the return types of `DIContext::getLineInfoForAddress` and `DIContext::getLineInfoForDataAddress` with `std::optional`.
2025-03-06[IR] Store Triple in Module (NFC) (#129868)Nikita Popov1-2/+1
The module currently stores the target triple as a string. This means that any code that wants to actually use the triple first has to instantiate a Triple, which is somewhat expensive. The change in #121652 caused a moderate compile-time regression due to this. While it would be easy enough to work around, I think that architecturally, it makes more sense to store the parsed Triple in the module, so that it can always be directly queried. For this change, I've opted not to add any magic conversions between std::string and Triple for backwards-compatibilty purses, and instead write out needed Triple()s or str()s explicitly. This is because I think a decent number of them should be changed to work on Triple as well, to avoid unnecessary conversions back and forth. The only interesting part in this patch is that the default triple is Triple("") instead of Triple() to preserve existing behavior. The former defaults to using the ELF object format instead of unknown object format. We should fix that as well.
2024-09-13[MC] Use std::optional<MCRegisters> for values returned by ↵Craig Topper1-1/+1
MCRegisterInfo::getLLVMRegNum. NFC I missed a few places when I changed the function return type in f2b71491d11355c0df0c92ef7cce7d610c894660.
2024-09-12[llvm-dwarfdump] Rename manaully-generate-unit-index. (#108399)rjmansfield1-1/+1
-manaully-generate-unit-index was misspelled.
2024-06-14[llvm] Use llvm::unique (NFC) (#95628)Kazu Hirata1-2/+2
2024-02-28llvm-dwarfdump --verify aggregated output to JSON file (#81762)Kevin Frei1-2/+12
In order to make tooling around dwarf health easier, I've added an `--verify-json` option to `llvm-dwarfdump --verify` that will spit out error summary data with counts to a JSON file. I've added the same capability to `llvm-gsymutil` in a [different PR.](https://github.com/llvm/llvm-project/pull/81763) The format of the json is: ``` json { "error-categories": { "<first category description>": {"count": 1234}, "<next category description>": {"count":4321} }, "error-count": 5555 } ``` for a clean run: ``` json { "error-categories": {}, "error-count": 0 } ``` --------- Co-authored-by: Kevin Frei <freik@meta.com>
2024-02-13[DWARFDump] Make --verify handle all sections by default (#81559)Felipe de Azevedo Piovezan1-1/+1
The current behavior of --verify is that it only verifies debug_info, debug_abbrev and debug_names. This seems fairly arbitrary and might have been unintentional, as originally the absence of any section flags implied "all". This patch changes the behavior so that the verifier now verifies everything by default. It revealed two tests that had potentially invalid DWARF: 1. dwarfdump-str-offsets.s is adding padding between two debug_str_offset contributions. The standard does not explicitly allow this behavior. See issue https://github.com/llvm/llvm-project/issues/81558 2. dwarf5-macro.test uses a checked-in binary that has invalid debug_str_offsets. One of its entries points to the _middle_ of the string section: error: .debug_str_offsets: contribution 0x0: index 0x4: invalid string offset *0x18 == 0x455D, is neither zero nor immediately following a null character If we look at the closest offset to 0x455D in debug_str: ``` 0x0000454e: "__SLONG32_TYPE int" ``` 0x455D points to "int".
2024-02-09[DWARFDump][nfc] Fix incorrect comment (#81276)Felipe de Azevedo Piovezan1-2/+3
It claimed to dump all sections by default, but this hasn't been true since 2017: https://reviews.llvm.org/D37717
2024-02-01Aggregate errors from llvm-dwarfdump --verify (#79648)Kevin Frei1-1/+25
The amount and format of output from `llvm-dwarfdump --verify` makes it quite difficult to know if a change to a tool that produces or modifies DWARF is causing new problems, or is fixing existing problems. This diff adds a categorized summary of issues found by the DWARF verifier, on by default, at the bottom of the error output. The change includes a new `--error-display` option with 4 settings: * `--error-display=quiet`: Only display if errors occurred, but no details or summary are printed. * `--error-display=summary`: Only display the aggregated summary of errors with no error detail. * `--error-display=details`: Only display the detailed error messages with no summary (previous behavior) * `--error-display=full`: Display both the detailed error messages and the aggregated summary of errors (the default) I changed a handful of tests that were failing due to new output, adding the flag to use the old behavior for all but a couple. For those two I added the new aggregated output to the expected output of the test. The `OutputCategoryAggregator` is a pretty simple little class that @clayborg suggested to allow code to only be run to dump detail if it's enabled, while still collating counts of the category. Knowing that the lambda passed in is only conditionally executed is pretty important (handling errors has to be done *outside* the lambda). I'm happy to move this somewhere else (and change/improve it) to be more broadly useful if folks would like. --------- Co-authored-by: Kevin Frei <freik@meta.com>
2024-01-12Allow the dumping of .dwo files contents to show up when dumping an ↵Greg Clayton1-4/+24
executable with split DWARF. (#66726) Allow the dumping of .dwo files contents to show up when dumping an executable with split DWARF. Currently if you run llvm-dwarfdump on a binary that has skeleton compile units, you only see the skeleton compile units. Since the main binary has the linked addresses it would be nice to be able to dump DWARF from the .dwo files and how the resolved addresses instead of showing the address index and "<unresolved>" in the output. This patch adds an option that can be specified to dump the non skeleton DIEs named --dwo. Added the ability to use the following options with split dwarf as well: --name <name> --lookup <addr> --debug-info <die-offset>
2023-09-27llvm/tools: Fix some performance-for-range-copy issues. NFCFangrui Song1-9/+9
Inspired by https://reviews.llvm.org/D139487 , but I apply manual fixes when clang-tidy does not provide the best fix.
2023-07-19AppleAcceleratorTable: Use MapVector to stabilize iteration order after D153066Fangrui Song1-1/+2
Use a MapVector to stabilize the order and simplify future changes like D142862 that change the StringMap hash function.
2023-06-21[AppleTables] Implement iterator over all entries in tableFelipe de Azevedo Piovezan1-1/+44
This commit adds functionality to the Apple Accelerator table allowing iteration over all elements in the table. Our iterators look like streaming iterators: when we increment the iterator we check if there is still enough data in the "stream" (in our case, the blob of data of the accelerator table) and extract the next entry. If any failures occur, we immediately set the iterator to be the end iterator. Since the ultimate user of this functionality is LLDB, there are roughly two iteration methods we want support: one that also loads the name of each entry, and one which does not. Loading names is measurably slower (one order the magnitude) than only loading DIEs, so we used some template metaprograming to implement both iteration methods. Depends on D153066 Differential Revision: https://reviews.llvm.org/D153066
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott1-1/+1
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.
2023-01-12[DWARFLibrary] Add support to re-construct cu-indexAlexander Yermolovich1-0/+8
According to DWARF5 specification and gnu specification for DWARF4 the offset entry in the CU/TU Index is 32 bits. This presents a problem when .debug_info.dwo in DWP file grows beyond 4GB. The CU Index becomes partially corrupted. This diff adds manual parsing of .debug_info.dwo/.debug_abbrev.dwo to reconstruct CU index in general, and TU index for DWARF5. This is a work around until DWARF6 spec is finalized. Next patch will change internal CU/TU struct to 64 bit, and change uses as necessary. The plan is to land all the patches in one go after all are approved. This patch originates from the discussion in: https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D137882
2023-01-11Revert "[DWARFLibrary] Add support to re-construct cu-index"Dmitri Gribenko1-8/+0
This reverts commit 73712c8790a93c29e513f5e201f92ac5b2370cf9. It causes a MemorySanitizer error in LLVM testsuite. See the discussion on https://reviews.llvm.org/D137882 for details.
2023-01-10[DWARFLibrary] Add support to re-construct cu-indexAlexander Yermolovich1-0/+8
According to DWARF5 specification and gnu specification for DWARF4 the offset entry in the CU/TU Index is 32 bits. This presents a problem when .debug_info.dwo in DWP file grows beyond 4GB. The CU Index becomes partially corrupted. This diff adds manual parsing of .debug_info.dwo/.debug_abbrev.dwo to reconstruct CU index in general, and TU index for DWARF5. This is a work around until DWARF6 spec is finalized. Next patch will change internal CU/TU struct to 64 bit, and change uses as necessary. The plan is to land all the patches in one go after all are approved. This patch originates from the discussion in: https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D137882
2022-12-15Remove the dependency between lib/DebugInfoDWARF and MC.Shubham Sandeep Rastogi1-15/+55
Differential Revision: https://reviews.llvm.org/D134817
2022-12-14Revert "Remove the dependency between lib/DebugInfoDWARF and MC."Shubham Sandeep Rastogi1-55/+15
This reverts commit 7dde94251e1c9e4634f5d51d41f2d4a191258fb3. Because of test failures: lldb-shell :: SymbolFile/DWARF/x86/DW_AT_loclists_base.s lldb-shell :: SymbolFile/DWARF/x86/debug_loc.s lldb-shell :: SymbolFile/DWARF/x86/debug_loc_and_loclists.s lldb-shell :: SymbolFile/DWARF/x86/debug_loclists-dwo.s lldb-shell :: SymbolFile/DWARF/x86/debug_loclists-dwp.s lldb-shell :: SymbolFile/DWARF/x86/dwp.s lldb-shell :: SymbolFile/DWARF/x86/unused-inlined-params.test lldb-shell :: SymbolFile/NativePDB/inline_sites.test lldb-shell :: SymbolFile/NativePDB/local-variables-registers.s lldb-shell :: SymbolFile/NativePDB/nested-blocks-same-address.s
2022-12-14Remove the dependency between lib/DebugInfoDWARF and MC.Shubham Sandeep Rastogi1-15/+55
Differential Revision: https://reviews.llvm.org/D134817
2022-12-07Revert "[DWARFLibrary] Add support to re-construct cu-index"Alexander Yermolovich1-8/+0
This reverts commit a5bd76a6e3119af9dd9c1d8af89e2b89f5267deb.
2022-12-07[DWARFLibrary] Add support to re-construct cu-indexAlexander Yermolovich1-0/+8
Summary: According to DWARF5 specification and gnu specification for DWARF4 the offset entry in the CU/TU Index is 32 bits. This presents a problem when .debug_info.dwo in DWP file grows beyond 4GB. The CU Index becomes partially corrupted. This diff adds manual parsing of .debug_info.dwo/.debug_abbrev.dwo to reconstruct CU index in general, and TU index for DWARF5. This is a work around until DWARF6 spec is finalized. Next patch will change internal CU/TU struct to 64 bit, and change uses as necessary. The plan is to land all the patches in one go after all are approved. This patch originates from the discussion in: https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 Differential Revision: https://reviews.llvm.org/D137882
2022-12-05[DebugInfo] llvm::Optional => std::optionalFangrui Song1-7/+6
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-10-06Revert "Remove the dependency between lib/DebugInfoDWARF and MC."Shubham Sandeep Rastogi1-55/+15
This reverts commit d96ade00c3c96bd451c60e34a17e613cdd5fdc38.
2022-10-06Remove the dependency between lib/DebugInfoDWARF and MC.Shubham Sandeep Rastogi1-15/+55
This patch had to be reverted because on gcc 7.5.0 we see an error converting from std::unique_ptr<MCRegisterInfo> to Expected<std::unique_ptr<MCRegisterInfo>> as the return type for the function createRegInfo. This has now been fixed.
2022-10-06Revert "Remove the dependency between lib/DebugInfoDWARF and MC."Shubham Sandeep Rastogi1-54/+15
This reverts commit 0008990479a2daf587c2a4f274384b2fb87247fb.
2022-10-06Remove the dependency between lib/DebugInfoDWARF and MC.Shubham Sandeep Rastogi1-15/+54
Differential Revision: https://reviews.llvm.org/D134817
2022-07-23Use the range-based overload of llvm::sort where possibleDmitri Gribenko1-1/+1
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D130403
2022-06-30[llvm-dwarfdump] --show-sources option to show all sourcesDaniel Thornburgh1-0/+89
This option allows printing all sources used by an object file. Reviewed By: dblaikie, jhenderson Differential Revision: https://reviews.llvm.org/D87656
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song1-1/+1
2022-02-15Cleanup LLVMDWARFDebugInfoserge-sans-paille1-0/+2
As usual with that header cleanup series, some implicit dependencies now need to be explicit: llvm/DebugInfo/DWARF/DWARFContext.h no longer includes: - "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" - "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" - "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" - "llvm/DebugInfo/DWARF/DWARFDebugAranges.h" - "llvm/DebugInfo/DWARF/DWARFDebugFrame.h" - "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" - "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" - "llvm/DebugInfo/DWARF/DWARFGdbIndex.h" - "llvm/DebugInfo/DWARF/DWARFSection.h" - "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" - "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" Plus llvm/Support/Errc.h not included by a bunch of llvm/DebugInfo/DWARF/DWARF*.h files Preprocessed lines to build llvm on my setup: after: 1065629059 before: 1066621848 Which is a great diff! Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D119723
2021-12-15[dwarf][NFC] Move expandBundle() to MachO.hEllis Hoag1-38/+15
The function `expandBundle()` is defined both in `llvm-dwarfdump.cpp` and `llvm-gsymutil.cpp` in the exact same way. Reduce code duplication by moving this function to the `MachOObjectFile` class. Reviewed By: jhenderson, clayborg Differential Revision: https://reviews.llvm.org/D115418
2021-12-13DWARFVerifier: Verbosely dump DIEs in verifier reportsDavid Blaikie1-1/+3
Seems helpful when you're dealing with invalid/problematic DWARF. Some diagnostic messages are probably redundant with the verbose dumping and could be simplified with this.
2021-09-27[llvm-dwarfdump][docs] Add missing options to the help output and the ↵gbreynoo1-6/+7
command guide This change is to add some missing details to the help text and command guide: - Added a note to the command guide that --debug-macro also dumps .debug_macinfo. - Added a note to the command guide that --debug-frame and --eh_frame are aliases, and in cases where both sections are present one command outputs both. - Changed the wording in the help output for --ignore-case and --regex to closer match the command guide.
2021-08-02[DWARF] Don't process .debug_info relocations for DWO ContextAlexander Yermolovich1-4/+6
When we build with split dwarf in single mode the .o files that contain both "normal" debug sections and dwo sections, along with relocaiton sections for "normal" debug sections. When we create DWARF context in DWARFObjInMemory we process relocations and store them in the map for .debug_info, etc section. For DWO Context we also do it for non dwo dwarf sections. Which I believe is not necessary. This leads to a lot of memory being wasted. We observed 70GB extra memory being used. I went with context sensitive approach, flag is passed in. I am not sure if it's always safe not to process relocations for regular debug sections if Obj contains .dwo sections. If it is alternatvie might be just to scan, in constructor, sections and if there are .dwo sections not to process regular debug ones. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D106624
2021-07-16Use ManagedStatic and lazy initialization of cl::opt in libSupport to make ↵Mehdi Amini1-1/+2
it free of global initializer We can build it with -Werror=global-constructors now. This helps in situation where libSupport is embedded as a shared library, potential with dlopen/dlclose scenario, and when command-line parsing or other facilities may not be involved. Avoiding the implicit construction of these cl::opt can avoid double-registration issues and other kind of behavior. Reviewed By: lattner, jpienaar Differential Revision: https://reviews.llvm.org/D105959
2021-07-16Revert "Use ManagedStatic and lazy initialization of cl::opt in libSupport ↵Mehdi Amini1-2/+1
to make it free of global initializer" This reverts commit af9321739b20becf170e6bb5060b8d780e1dc8dd. Still some specific config broken in some way that requires more investigation.
2021-07-16Use ManagedStatic and lazy initialization of cl::opt in libSupport to make ↵Mehdi Amini1-1/+2
it free of global initializer We can build it with -Werror=global-constructors now. This helps in situation where libSupport is embedded as a shared library, potential with dlopen/dlclose scenario, and when command-line parsing or other facilities may not be involved. Avoiding the implicit construction of these cl::opt can avoid double-registration issues and other kind of behavior. Reviewed By: lattner, jpienaar Differential Revision: https://reviews.llvm.org/D105959
2021-07-16Revert "Use ManagedStatic and lazy initialization of cl::opt in libSupport ↵Mehdi Amini1-2/+1
to make it free of global initializer" This reverts commit 42f588f39c5ce6f521e3709b8871d1fdd076292f. Broke some buildbots
2021-07-16Use ManagedStatic and lazy initialization of cl::opt in libSupport to make ↵Mehdi Amini1-1/+2
it free of global initializer We can build it with -Werror=global-constructors now. This helps in situation where libSupport is embedded as a shared library, potential with dlopen/dlclose scenario, and when command-line parsing or other facilities may not be involved. Avoiding the implicit construction of these cl::opt can avoid double-registration issues and other kind of behavior. Reviewed By: lattner, jpienaar Differential Revision: https://reviews.llvm.org/D105959
2021-07-02[llvm-dwarfdump] Add comment saying where DumpDebugFrame comes fromNico Weber1-0/+1
2021-06-23clang-format llvm-dwarfdump.cppAdrian Prantl1-5/+5
2021-06-23Improve error handling in llvm-dwarfdump.Adrian Prantl1-8/+12
Without this patch we're only showing a generic error message derived from the error code to the end user. rdar://79378794 Differential Revision: https://reviews.llvm.org/D104483
2021-06-01[llvm-dwarfdump][test] Add missing dedicated tests for some optionsgbreynoo1-1/+1
This change adds tests specifically for --parent-recurse-depth, --quiet and -o. The test for -o found a typo in an error message which is also fixed in this change. Differential Revision: https://reviews.llvm.org/D103250
2021-05-07[llvm-dwarfdump] Help option output should be consistent with the command guidegbreynoo1-18/+24
The dwarfdump command guide shows the short options used as aliases but these are not found in the help text unless --show-hidden is used. Investigating other tools some follow this pattern, others like llvm-objdump show aliases with --help. This change fixes the help output to be consistent with the command guide. This includes updating alias descriptions in the help output to use "--". As part of this change I updated cmdline.test, including some options that were missing testing. Differential Revision: https://reviews.llvm.org/D101646
2021-04-06[SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag ↵Abhina Sreeskantharajan1-1/+1
instead of OF_Text Problem: On SystemZ we need to open text files in text mode. On Windows, files opened in text mode adds a CRLF '\r\n' which may not be desirable. Solution: This patch adds two new flags - OF_CRLF which indicates that CRLF translation is used. - OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and uses CRLF translation. Developers should now use either the OF_Text or OF_TextWithCRLF for text files and OF_None for binary files. If the developer doesn't want carriage returns on Windows, they should use OF_Text, if they do want carriage returns on Windows, they should use OF_TextWithCRLF. So this is the behaviour per platform with my patch: z/OS: OF_None: open in binary mode OF_Text : open in text mode OF_TextWithCRLF: open in text mode Windows: OF_None: open file with no carriage return OF_Text: open file with no carriage return OF_TextWithCRLF: open file with carriage return The Major change is in llvm/lib/Support/Windows/Path.inc to only set text mode if the OF_CRLF is set. ``` if (Flags & OF_CRLF) CrtOpenFlags |= _O_TEXT; ``` These following files are the ones that still use OF_Text which I left unchanged. I modified all these except raw_ostream.cpp in recent patches so I know these were previously in Binary mode on Windows. ./llvm/lib/Support/raw_ostream.cpp ./llvm/lib/TableGen/Main.cpp ./llvm/tools/dsymutil/DwarfLinkerForBinary.cpp ./llvm/unittests/Support/Path.cpp ./clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp ./clang/lib/Frontend/CompilerInstance.cpp ./clang/lib/Driver/Driver.cpp ./clang/lib/Driver/ToolChains/Clang.cpp Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D99426
2021-01-05[tools] Use llvm::append_range (NFC)Kazu Hirata1-1/+1
2020-10-14llvm-dwarfdump: Exit non-zero on an error pathDavid Blaikie1-1/+1
2020-06-24[llvm] Remove full stop frome error messageJonas Devlieghere1-2/+2
Address post-commit feedback from James Henderson in D80959.