summaryrefslogtreecommitdiff
path: root/lldb/examples/python/symbolication.py
AgeCommit message (Collapse)Author
2025-02-28[lldb] fix(lldb/**.py): fix invalid escape sequences (#94034)Eisuke Kawashima
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2023-08-11[lldb/crashlog] Skip images with empty path and 0 UUID from loadingMed Ismail Bennani
This patch skips images with an empty path or a 0 UUID from loading as a SymbolFileJSON. rdar://112107986 Differential Revision: https://reviews.llvm.org/D157137 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-11[lldb/crashlog] Fix sticky image parsing logicMed Ismail Bennani
Prior to this patch, when a user loaded multiple crash report in lldb, they could get in a situation where all the targets would keep the same architecture and executable path as the first one that we've created. The reason behind this was that even if we created a new CrashLog object, which is derived from a Symbolicator class that has a newly constructoted image list as a default argument, because that default argument is only created once when the function is defined, every CrashLog object would share the same list. That will cause use to append newly parsed images to the same Symbolicator image list accross multiple CrashLog objects. To address this, this patch changes the default argument value for the image parameter to `None` and only initialize it as an empty list when no argument was passed. This also removes the image list stored in each CrashLog parsers since they shouldn't have any state and should be re-usable. So now, the only source of truth is stored in the CrashLog object. rdar://84984949 Differential Revision: https://reviews.llvm.org/D157044 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-25[NFC][Py Reformat] Reformat python files in lldbJonas Devlieghere
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black` (23.1.0). If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run `git checkout --ours <yourfile>` and then reformat it with black. RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Differential revision: https://reviews.llvm.org/D151460
2023-05-22[lldb/crashlog] Remove tempfile prefix from inlined symbol object fileMed Ismail Bennani
This patch changes the way we generate the ObjectFileJSON files containing the inlined symbols from the crash report to remove the tempfile prefix from the object file name. To do so, instead of creating a new tempfile for each module, we create a temporary directory that contains each module object file with the same name as the module. This makes the backtraces only contain the module name without the temfile prefix which makes it look like a regular stackframe. Differential Revision: https://reviews.llvm.org/D151045 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-04-28[lldb/crashlog] Fix JSON ObjectFile module loading issueMed Ismail Bennani
In 27f27d15f6c9, we added a new way to use textual (JSON) object files and symbol files with the interactive crashlog command, using the inlined symbols from the crash report. However, there was a missing piece after successfully adding the textual module to the target, we didn't mark it as available causing the module loading to exit early. This patch addresses that issue by marking the module as available when added successfully to the target. Differential Revision: https://reviews.llvm.org/D149477 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-04-13[lldb] Use ObjectFileJSON to create modules for interactive crashlogsJonas Devlieghere
Create an artificial module using a JSON object file when we can't locate the module and dSYM through dsymForUUID (or however locate_module_and_debug_symbols is implemented). By parsing the symbols from the crashlog and making them part of the JSON object file, LLDB can symbolicate frames it otherwise wouldn't be able to, as there is no module for it. For non-interactive crashlogs, that never was a problem because we could simply show the "pre-symbolicated" frame from the input. For interactive crashlogs, we need a way to pass the symbol information to LLDB so that it can symbolicate the frames, which is what motivated the JSON object file format. Differential revision: https://reviews.llvm.org/D148172
2022-08-15[LLDB] Remove __future__ imports from examplesDavid Spickett
Not needed now that we require python 3. Reviewed By: kastiglione, JDevlieghere Differential Revision: https://reviews.llvm.org/D131772
2021-09-20[lldb][crashlog] Avoid specifying arch for image when a UUID is presentVedant Kumar
When adding an image to a target for crashlog purposes, avoid specifying the architecture of the image. This has the effect of making SBTarget::AddModule infer the ArchSpec for the image based on the SBTarget's architecture, which LLDB puts serious effort into calculating correctly (in TargetList::CreateTargetInternal). The status quo is that LLDB randomly guesses the ArchSpec for a module if its architecture is specified, via: ``` SBTarget::AddModule -> Platform::GetAugmentedArchSpec -> Platform::IsCompatibleArchitecture -> GetSupportedArchitectureAtIndex -> {ARM,x86}GetSupportedArchitectureAtIndex ``` ... which means that the same crashlog can fail to load on an Apple Silicon Mac (due to the random guess of arm64e-apple-macosx for the module's ArchSpec not being compatible with the SBTarget's (correct) ArchSpec), while loading just fine on an Intel Mac. I'm not sure how to add a test for this (it doesn't look like there's test coverage of this path in-tree). It seems like it would be pretty complicated to regression test: the host LLDB would need to be built for arm64e, we'd need a hand-crafted arm64e iOS crashlog, and we'd need a binary with an iOS deployment target. I'm open to other / simpler options. rdar://82679400 Differential Revision: https://reviews.llvm.org/D110013
2020-12-03[lldb] Refactor the Symbolicator initializerJonas Devlieghere
We found out that we have clients relying on the old signature of the Symbolicator initializer. Make the signature compatible again and provide a factory method to initialize the class correctly based on whether you have a target or want the symbolicator to create one for you. Differential revision: D92601
2020-11-04[crashlog] Pass the debugger around instead of relying on lldb.debuggerJonas Devlieghere
The lldb.debugger et al convenience variables are only available from the interactive script interpreter. In all other scenarios, they are None (since fc1fd6bf9fcfac412b10b4193805ec5de0e8df57) before that they were default initialized. The crashlog script was hacking around that by setting the lldb.debugger to a newly created debugger instance when running outside of the script interpreter, which works fine until lldb creates a script interpreter instance under the hood and clears the variables. This was resulting in an AttributeError when invoking the script directly (from outside of lldb): AttributeError: 'NoneType' object has no attribute 'GetSourceManager' This patch fixes that by passing around the debugger instance. rdar://64775776 Differential revision: https://reviews.llvm.org/D90706
2020-07-16Harmonize Python shebangserge-sans-paille
Differential Revision: https://reviews.llvm.org/D83857
2019-07-29[Symbolication] Remove some dead code. Nothing exciting.Davide Italiano
llvm-svn: 367262
2019-07-29[Symbolication] Remove a duplicate assignment.Davide Italiano
llvm-svn: 367261
2019-07-29[Symbolication] Fix unicode compatibility between 2 and 3.Davide Italiano
Triples are always ASCII for now, but we were handed out a unicode object. <rdar://problem/53592772> llvm-svn: 367260
2019-03-06[Python] Unbreak the recently modified tests for python 2.Davide Italiano
llvm-svn: 355566
2019-03-06[testsuite] Port crashlog to python 3, second attempt.Davide Italiano
llvm-svn: 355562
2019-03-05Revert "[testsuite] Port crashlog and dependencies to Python 3."Davide Italiano
This revert the commit because it broke the bots. I need to find a way that works with both versions. llvm-svn: 355364
2019-03-05[testsuite] Port crashlog and dependencies to Python 3.Davide Italiano
Fixes three tests in the testsuite. llvm-svn: 355359
2016-09-06*** This commit represents a complete reformatting of the LLDB source codeKate Stone
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
2016-06-10Fixed a few places that were building a regex from an identifier without ↵Greg Clayton
escaping the identifier text. <rdar://problem/26090553> llvm-svn: 272423
2015-09-22Fix typos.Bruce Mitchener
Summary: Another round of minor typo fixes. Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D13026 llvm-svn: 248243
2015-03-05symbolicate the application specific backtraces that are in MacOSX crash log ↵Greg Clayton
files. <rdar://problem/20039160> llvm-svn: 231415
2014-05-28Allow classes to be intialized using current lldb::SB objects. This can help ↵Greg Clayton
to import/export the current process state. llvm-svn: 209702
2013-06-26Update the platform options help strings.Greg Clayton
llvm-svn: 185028
2013-04-04<rdar://problem/13477795>Greg Clayton
crashlog.py was always subtracting 1 to point to the previous instruction when symbolicating ARM backtraces. Many times the backtraces will include bit zero set to 1 to indicate thumb, so we need to make sure we mask the address and then backup one for non frame zero frames. llvm-svn: 178812
2013-02-25Added missing lldb module namespace.Greg Clayton
llvm-svn: 176049
2013-02-25<rdar://problem/13286937> Greg Clayton
Make sure to not look in self.images when we have a symbolicator with a live process. llvm-svn: 176040
2012-08-29<rdar://problem/11757916>Greg Clayton
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes: - Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file". - modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly - Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was. - modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile() Cleaned up header includes a bit as well. llvm-svn: 162860
2012-07-07Make const result value objects able to return dynamic types.Greg Clayton
Modified the heap.py to be able to correctly indentify the exact ivar for the "ptr_refs" command no matter how deep the ivar is in a class hierarchy. Also fixed the ability for the heap command to symbolicate the stack backtrace when MallocStackLogging is set in the environment and the "--stack" option was specified. llvm-svn: 159883
2012-06-28Listen to the "--verbose" flag when running "crashlog" and if verbose is ↵Greg Clayton
enabled, then dump full paths to source files and modules. Changed much of the output that was coming out with "--verbose" over to use the new "--debug" flag. llvm-svn: 159363
2012-06-04Cleaned up some stuff in symbolication where we can now lazily get images ↵Greg Clayton
when symbolicating after loading a crash log file. Added colorization to the gdbremote.py output and also added the ability to symbolicate the addresses in registers. llvm-svn: 157965
2012-05-11Modified the symbolication.Image object to store its uuid as a uuid.UUID ↵Greg Clayton
object and made an accessor for getting a normalized UUID value out of the image object. Modified the crashlog darwin module to always create a uuid.UUID object when making the symbolication.Image objects. Also modified it to handle some more types of crash log files and improved the register reading for thread registers of crashed threads. llvm-svn: 156596
2012-05-04Added an interactive mode to the "crashlog" command so that we can look at ↵Greg Clayton
multiple crash logs at once and do some data mining. Added an interactive command prompt that allows you to do: % PYTHONPATH=./build/Debug/LLDB.framework/Resources/Python ; ./build/Debug//LLDB.framework/Resources/Python/lldb/macosx/crashlog.py -i ~/Downloads/crashes2/*.crash ) then you get an interactive prompt where you can search for data within all crash logs. For example you can do: % list which will list all crash logs And you can search for all images given an image basename, or full path: % image LLDB % image /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB % image LLDB.framework Which would all produce an output listing like: 40CD4430-7D27-3248-BE4C-71B1F36FC5D0 (1.132 - 132) /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB, __TEXT=[0x000000011f8bc000 - 0x0000000120d3efbf) B727A528-FF1F-3B20-9E4F-BBE96C7D922D (1.136 - 136) /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB, __TEXT=[0x000000011e7f7000 - 0x000000011fc7ff87) 4D6F8DC2-5757-39C7-96B0-1A5B5171DC6B (1.137 - 137) /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB, __TEXT=[0x000000012bd7f000 - 0x000000012d1fcfef) FBF8786F-92B9-31E3-8BCD-A82148338966 (1.137 - 137) /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB, __TEXT=[0x0000000122d78000 - 0x00000001241f5fd7) 7AE082E3-3BB7-3F64-A308-063E559DFC45 (1.143 - 143) /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB, __TEXT=[0x0000000119b8d000 - 0x000000011b02ef5f) 7AE082E3-3BB7-3F64-A308-063E559DFC45 (1.143 - 143) /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB, __TEXT=[0x0000000111497000 - 0x0000000112938f5f) 7AE082E3-3BB7-3F64-A308-063E559DFC45 (1.143 - 143) /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB, __TEXT=[0x0000000116680000 - 0x0000000117b21f5f) llvm-svn: 156201
2012-04-25Remove the "-x" from the finish-swig-Python-LLDB.sh shell options so it ↵Greg Clayton
doesn't print out all of the commands when executing the shell script. Cleaned up the lldb.utils.symbolication, lldb.macosx.heap and lldb.macosx.crashlog. The lldb.macosx.heap can now build a dylib for the current triple into a temp directory and use it from there. llvm-svn: 155577
2012-04-20Fixed some issues with symbolicating things. Fixed ↵Greg Clayton
symbolication.add_module() to not use the resolved_path before we have tried to locate it. Fixed crashlog.locate_module_and_debug_symbols() to return true and false correctly. llvm-svn: 155255
2012-04-03Added a platform agnostic symbolication python module that can be used by ↵Greg Clayton
any targets. Then modified the darwin "crashlog.py" to use this agnostic info and the new functionality and classes. llvm-svn: 153969