summaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
AgeCommit message (Collapse)Author
2024-08-05[Symbolizer] Support for Missing Line Numbers. (#82240)Amit Kumar Pandey
LLVM Symbolizer attempt to symbolize addresses of optimized binaries reports missing line numbers for some cases. It maybe due to compiler which sometimes cannot map an instruction to line number due to optimizations. Symbolizer should handle those cases gracefully. Adding an option '--skip-line-zero' to symbolizer so as to report the nearest non-zero line number. --------- Co-authored-by: Amit Pandey <amit.pandey@amd.com>
2023-11-06[DebugInfo] Use StringRef::starts_with/ends_with instead of ↵Simon Pilgrim
startswith/endswith. NFC. startswith/endswith wrap starts_with/ends_with and will eventually go away (to more closely match string_view)
2023-11-01[symbolizer] Support symbol lookupSerge Pavlov
Recent versions of GNU binutils starting from 2.39 support symbol+offset lookup in addition to the usual numeric address lookup. This change adds symbol lookup to llvm-symbolize and llvm-addr2line. Now llvm-symbolize behaves closer to GNU addr2line, - if the value specified as address in command line or input stream is not a number, it is treated as a symbol name. For example: llvm-symbolize --obj=abc.so func_22 llvm-symbolize --obj=abc.so "CODE func_22" This lookup is now supported only for functions. Specification with offset is not supported yet. This is a recommit of 2b27948783e4bbc1132d3220d8517ef62607b558, reverted in 39fec5457c0925bd39f67f63fe17391584e08258 because the test llvm/test/Support/interrupts.test started failing on Windows. The test was changed in 18f036d0105589c3175bb51a518c5d272dae61e2 and is also updated in this commit. Differential Revision: https://reviews.llvm.org/D149759
2023-10-02Revert "[symbolizer] Support symbol lookup"Serge Pavlov
This reverts commit 2b27948783e4bbc1132d3220d8517ef62607b558. On some buildbots the test LLVM::interrupts.test start failing.
2023-10-02[symbolizer] Support symbol lookupSerge Pavlov
Recent versions of GNU binutils starting from 2.39 support symbol+offset lookup in addition to the usual numeric address lookup. This change adds symbol lookup to llvm-symbolize and llvm-addr2line. Now llvm-symbolize behaves closer to GNU addr2line, - if the value specified as address in command line or input stream is not a number, it is treated as a symbol name. For example: llvm-symbolize --obj=abc.so func_22 llvm-symbolize --obj=abc.so "CODE func_22" This lookup is now supported only for functions. Specification with offset is not supported yet. Differential Revision: https://reviews.llvm.org/D149759
2023-08-30[symbolizer] Change reaction on invalid inputSerge Pavlov
If llvm-symbolizer finds a malformed command, it echoes it to the standard output. New versions of binutils (starting from 2.39) allow to specify an address by a symbols. Implementation of this feature in llvm-symbolizer makes the current reaction on invalid input inappropriate. Almost any invalid command may be treated as a symbol name, so the right reaction should be "symbol not found" in such case. The exception are commands that are recognized but have incorrect syntax, like "FILE:FILE:". The utility must produce descriptive diagnostic for such input and route it to the stderr. This change implements the new reaction on invalid input and is a prerequisite for implementation of symbol lookup in llvm-symbolizer. Differential Revision: https://reviews.llvm.org/D157210
2023-08-12Revert "[symbolizer] Change reaction on invalid input"Douglas Yung
This reverts commit a5fe6c7f5e2d1d265bd7c312ef55259fee7a68f9. This change is causing problems with Windows build bots due to a hanging zombie llvm-symbolizer.exe process.
2023-08-12[symbolizer] Change reaction on invalid inputSerge Pavlov
If llvm-symbolizer finds a malformed command, it echoes it to the standard output. New versions of binutils (starting from 2.39) allow to specify an address by a symbols. Implementation of this feature in llvm-symbolizer makes the current reaction on invalid input inappropriate. Almost any invalid command may be treated as a symbol name, so the right reaction should be "symbol not found" in such case. The exception are commands that are recognized but have incorrect syntax, like "FILE:FILE:". The utility must produce descriptive diagnostic for such input and route it to the stderr. This change implements the new reaction on invalid input and is a prerequisite for implementation of symbol lookup in llvm-symbolizer. Differential Revision: https://reviews.llvm.org/D157210
2023-04-23[symbolizer] Change error message if module not found (recommit)Serge Pavlov
This is a recommit of 75f1f158812d, reverted in 7a443b1c493d, because it caused compilation error in compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp. The error was fixed by Kasimir Georgiev in de4c038c7ba2, but this commit was reverted in de088dd3a0aa, because the initial commit was reverted. This commit reverts both the reverting commits, 7a443b1c493d and de088dd3a0aa. Original commit message is below. If llvm-symbolize did not find module, the error looked like: LLVMSymbolizer: error reading file: No such file or directory This message does not follow common practice: LLVMSymbolizer is not an utility name. Also the message did not not contain the name of missed file. With this change the error message looks differently: llvm-symbolizer: error: 'abc': No such file or directory This format is closer to messages produced by other utilities and allow proper coloring. Differential Revision: https://reviews.llvm.org/D148032
2023-04-14Revert "[symbolizer] Change error message if module not found"Serge Pavlov
This reverts commit 75f1f158812dabc03e70697b6b9c272230bce63d. It caused fail on https://lab.llvm.org/buildbot#builders/37/builds/21461
2023-04-14[symbolizer] Change error message if module not foundSerge Pavlov
If llvm-symbolize did not find module, the error looked like: LLVMSymbolizer: error reading file: No such file or directory This message does not follow common practice: LLVMSymbolizer is not an utility name. Also the message did not not contain the name of missed file. With this change the error message looks differently: llvm-symbolizer: error: 'abc': No such file or directory This format is closer to messages produced by other utilities and allow proper coloring. Differential Revision: https://reviews.llvm.org/D148032
2023-04-13Revert "[symbolizer] Treat invalid address as addr2line does"Serge Pavlov
This reverts commit 27c4777f41d2ab204c1cf84ff1cccd5ba41354da. It created problems for testing on Gentoo, see: https://reviews.llvm.org/rG27c4777f41d2ab204c1cf84ff1cccd5ba41354da#1190273 Reverted until https://reviews.llvm.org/D147652 has been landed.
2023-03-29[symbolizer] Factor out conversion DILineInfo->JSON. NFCSerge Pavlov
Move the conversion of DILineInfo to JSON into a separate function, so it can be used in other places too. This is a prerequisite patch for implementation of symbol+offset lookup. Differential Revision: https://reviews.llvm.org/D147112
2023-03-29[symbolizer] Treat invalid address as addr2line doesSerge Pavlov
llvm-symbolizer echoed input if it was not recognized as a valid address. This behavior was extended to llvm-addr2line as well. GNU addr2line in this case optputs "??:0". This difference prevents implementation of symbol+offset lookup available in the recent versions of GNU binutils. In that case a string that is not an address may be a symbol. This change make reaction of llvm-addr2line on unrecognized input closer to GNU addr2line.
2022-12-05[DebugInfo] llvm::Optional => std::optionalFangrui Song
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02[DebugInfo] Use std::nullopt instead of None (NFC)Kazu Hirata
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-08-20Remove redundant initialization of Optional (NFC)Kazu Hirata
2022-05-23[symbolizer] Parse DW_TAG_variable DIs to show line info for globalsMitch Phillips
Currently, llvm-symbolizer doesn't like to parse .debug_info in order to show the line info for global variables. addr2line does this. In the future, I'm looking to migrate AddressSanitizer off of internal metadata over to using debuginfo, and this is predicated on being able to get the line info for global variables. This patch adds the requisite support for getting the line info from the .debug_info section for symbolizing global variables. This only happens when you ask for a global variable to be symbolized as data. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D123538
2022-02-24Cleanup include: DebugInfo/Symbolizeserge-sans-paille
Estimation of the impact on preprocessor output after: 1067349756 before:1067487786 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D120433
2021-12-27[DebugInfo] Drop unnecessary const from return types (NFC)Kazu Hirata
Identified with readability-const-return-type.
2021-05-20Add support for DWARF embedded source to llvm-symbolizer.Alex Orlov
This patch adds DWARF embedded source printout to llvm-symbolizer. Reviewed By: jhenderson, dblaikie Differential Revision: https://reviews.llvm.org/D102355
2021-05-19[symbolizer] Added StartAddress for the resolved function.Alex Orlov
In many cases it is helpful to know at what address the resolved function starts. This patch adds a new StartAddress member to the DILineInfo structure. Reviewed By: jhenderson, dblaikie Differential Revision: https://reviews.llvm.org/D102316
2021-05-15NFC. Refactored DIPrinter for support embedded source.Alex Orlov
This patch introduces source loading and pruning functions. It will allow to use the DWARF embedded source and use the same code for JSON printout. No functional changes. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D102539
2021-05-11[symbolizer] Fix leak after D96883Vitaly Buka
2021-05-11* Add support for JSON output style to llvm-symbolizerAlex Orlov
This patch adds JSON output style to llvm-symbolizer to better support CLI automation by providing a machine readable output. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D96883
2021-04-05* NFC. Refactored DIPrinter for better support of new print styles.Alex Orlov
This patch introduces a DIPrinter interface to implement by different output style printer implementations. DIPrinterGNU and DIPrinterLLVM implement the GNU and LLVM output style printing respectively. No functional changes. This refactoring clarifies and simplifies the code, and makes a new output style addition easier. Reviewed By: jhenderson, dblaikie Differential Revision: https://reviews.llvm.org/D98994
2020-09-08llvm-symbolizer: Add optional "start file" to match "start line"David Blaikie
Since a function might have portions of its code coming from multiple different files, "start line" is ambiguous (it can't just be resolved relative to the file/line specified). Add start file to disambiguate it.
2020-03-20Cleanup the plumbing for DILineInfoSpecifier. [NFC - Try 2]Sterling Augustine
2020-03-19Revert "Cleanup the plumbing for DILineInfoSpecifier. [NFC]"Sterling Augustine
This broke lldb. Will fix and resubmit. This reverts commit 98ff6eb679cd5a2556d990d3d629e6c03c1da6a0.
2020-03-19Cleanup the plumbing for DILineInfoSpecifier. [NFC]Sterling Augustine
Summary: 1. FileLineInfoSpecifier::Default isn't the default for anything. Rename to RawValue, which accurately reflects its role. 2. Most functions that take a part of a FileLineInfoSpecifier end up constructing a full one later or plumb two values through. Make them all just take a complete FileLineInfoSpecifier. 3. Printing basenames only was handled differently from all other variants, make it parallel to all the other variants. Reviewers: jhenderson Subscribers: hiraditya, MaskRay, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76394
2020-01-29Print discriminators when printing .debug_line in GNU style.Sterling Augustine
Summary: gnu addr2line prints DWARF line table discriminators like so: <file>:<line> (discriminator <Number>) This matches that behavior. Document how and when --output-style=GNU prints discriminators Add test for new GNU-style discriminator printing. Reviewers: rupprecht, labath, jhenderson Subscribers: aprantl, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73318
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-11-25llvm-symbolizer: Fix FRAME handling of missing AT_name.Evgenii Stepanov
Summary: llvm-symbolizer protocol is empty string means end-of-output. Do not emit empty string when a function or a variable do not have a name for any reason. Emit "??". Reviewers: pcc, vitalybuka, jdoerfert Subscribers: srhines, hiraditya, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70626
2019-08-15[llvm-objdump] Add warning messages if disassembly + source for problematic ↵Michael Pozulp
inputs Summary: Addresses https://bugs.llvm.org/show_bug.cgi?id=41905 Reviewers: jhenderson, rupprecht, grimar Reviewed By: jhenderson, grimar Subscribers: RKSimon, MaskRay, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62462 llvm-svn: 368963
2019-08-05Revert "[llvm-objdump] Re-commit r367284."Michael Pozulp
This reverts r367776 (git commit d34099926e909390cb0254bebb4b7f5cf15467c7). My changes to llvm-objdump tests caused them to fail on windows: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/27368 llvm-svn: 367816
2019-08-04[llvm-objdump] Re-commit r367284.Michael Pozulp
Add warning messages if disassembly + source for problematic inputs Summary: Addresses https://bugs.llvm.org/show_bug.cgi?id=41905 Reviewers: jhenderson, rupprecht, grimar Reviewed By: jhenderson, grimar Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62462 llvm-svn: 367776
2019-07-30Revert "[llvm-objdump] Add warning messages if disassembly + source for ↵Michael Pozulp
problematic inputs" This reverts r367284 (git commit b1cbe51bdf44098c74f5c74b7bcd8c041a7c6772). My changes to LLVMSymbolizer caused a test to fail: http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/29488 llvm-svn: 367286
2019-07-30[llvm-objdump] Add warning messages if disassembly + source for problematic ↵Michael Pozulp
inputs Summary: Addresses https://bugs.llvm.org/show_bug.cgi?id=41905 Reviewers: jhenderson, rupprecht, grimar Reviewed By: jhenderson, grimar Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62462 llvm-svn: 367284
2019-06-24llvm-symbolizer: Add a FRAME command.Peter Collingbourne
This command prints a description of the referenced function's stack frame. For each formal parameter and local variable, the tool prints: - function name - variable name - file/line of declaration - FP-relative variable location (if available) - size in bytes - HWASAN tag offset This information will be used by the HWASAN runtime to identify local variables in UAR reports. Differential Revision: https://reviews.llvm.org/D63468 llvm-svn: 364225
2019-04-04[llvm-symbolizer] Add `--output-style` switch.Igor Kudrin
In general, llvm-symbolizer follows the output style of GNU's addr2line. However, there are still some differences; in particular, for a requested address, llvm-symbolizer prints line and column, while addr2line prints only the line number. This patch adds a new switch to select the preferred style. Differential Revision: https://reviews.llvm.org/D60190 llvm-svn: 357675
2019-01-22[llvm-symbolizer] Add support for --basenames/-sJames Henderson
This fixes https://bugs.llvm.org/show_bug.cgi?id=40068. --basenames is a GNU addr2line switch which strips the directory names from the file path in the output. Reviewed by: ruiu Differential Revision: https://reviews.llvm.org/D56919 llvm-svn: 351795
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
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
2017-02-06Get function start line number from DWARF infoDavid Blaikie
DWARF info contains info about the line number at which a function starts (DW_AT_decl_line). This patch creates a function to look up the start line number for a function, and returns it in DILineInfo when looking up debug info for a particular address. Patch by Simon Que! Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D27962 llvm-svn: 294231
2017-01-31Add a verbose/human readable mode to llvm-symbolizer to investigate ↵David Blaikie
discriminators and other line table/backtrace features Patch by Simon Que! Differential Revision: https://reviews.llvm.org/D29094 llvm-svn: 293697
2016-06-08Apply most suggestions of clang-tidy's performance-unnecessary-value-paramBenjamin Kramer
Avoids unnecessary copies. All changes audited & pass tests with asan. No functional change intended. llvm-svn: 272190
2016-05-09Fix some Clang-tidy modernize-deprecated-headers and Include What You Use ↵Eugene Zelenko
warnings; other minor fixes. Differential revision: http://reviews.llvm.org/D20042 llvm-svn: 268989
2016-01-09fixing type.Mike Aizatsky
llvm-svn: 257238
2016-01-09llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp: Fix build in -m32. 1L is ↵NAKAMURA Takumi
incompatible to int64_t. llvm-svn: 257237
2016-01-09[llvm-symbolizer] -print-source-context-lines option to print source code ↵Mike Aizatsky
around the line. Differential Revision: http://reviews.llvm.org/D15909 llvm-svn: 257236
2015-11-11[Symbolizer]: Add -pretty-print optionHemant Kulkarni
Differential Revision: http://reviews.llvm.org/D13671 llvm-svn: 252798