Commit Graph

214 Commits

Author SHA1 Message Date
Jim Ingham 723a1caa37 Fix the crashlog.py script's use of the load_address property.
This property is explicitly for use only in the interactive editor,
and NOT in commands.  It's use worked until we got more careful about
not leaving lldb.target lying around in the script interpreter.

I also added a quick sniff test for the save_crashlog command.

<rdar://problem/60350620>
Differential Revision: https://reviews.llvm.org/D80680
2020-05-28 09:55:40 -07:00
Kazuaki Ishizaki e9264b746b [lldb] NFC: Fix trivial typo in comments, documents, and messages
Differential Revision: https://reviews.llvm.org/D77460
2020-04-07 01:06:16 +09:00
Pavel Labath cb6c9f731b [lldb] Make gdbremote.py utility py2and3 compatible 2020-02-13 09:18:55 +01:00
Jonas Devlieghere b6ae524cd2 [Examples] Move structured-data unpacking out of the loop. (NFC)
There's no need to repeat this work in the loop.
2019-11-22 15:43:39 -08:00
Jonas Devlieghere 1b099c1df0 [Examples] Add in_call_stack breakpoint function.
The in_call_stack Python script makes it possible to modify the last
breakpoint to only stop if a given function is present in the call
stack. It will check both the symbol name and the function name (coming
from the debug info, in case the binary is stripped).

To use this, you have to:

1. Import the script into lldb.

(lldb) command script import in_call_stack.py

2. Set a breakpoint and use the in_call_stack alias.

(lldb) b foo
(lldb) in_call_stack bar

Note that this alias operates on the last set breakpoint. You can re-run
the in_call_stack command to modify the condition.
2019-11-22 15:36:42 -08:00
Adrian Prantl ff9d732887 crashlog.py: Improve regular expressions
This is yet another change to the regular expressions in crashlog.py
that fix a few edge cases, and attempt to improve the readability
quite a bit in the process. My last change to support spaces in
filenames introduced a bug that caused the version/archspec field to
be parsed as part of the image name.

For example, in "0x1111111 - 0x22222 +MyApp Pro arm64 <01234>", the
name of the image was recognized as "MyApp Pro arm64" instead of
"MyApp Pro" with a "version" of arm64.

The bugfix makes the space following an optional field mandatory
*inside* the optional group.

rdar://problem/56883435

Differential Revision: https://reviews.llvm.org/D69871
2019-11-07 10:52:06 -08:00
Davide Italiano 9a5fbc8163 [Symbolication] Remove some dead code. Nothing exciting.
llvm-svn: 367262
2019-07-29 21:25:51 +00:00
Davide Italiano f80c72be20 [Symbolication] Remove a duplicate assignment.
llvm-svn: 367261
2019-07-29 21:25:45 +00:00
Davide Italiano acc626bc57 [Symbolication] Fix unicode compatibility between 2 and 3.
Triples are always ASCII for now, but we were handed out a
unicode object.

<rdar://problem/53592772>

llvm-svn: 367260
2019-07-29 21:25:37 +00:00
Davide Italiano 68946d10ad [crashlog] Fix a mismatch between bytes and strings.
The functions in read_plist() want bytes as input, not
strings.

<rdar://problem/52600712>

llvm-svn: 365416
2019-07-09 01:05:12 +00:00
Jason Molenda ddf025e8dc Use the // integer divide operator in these
target definition files, like Davide's change to x86_64_target_definition.py.

llvm-svn: 364481
2019-06-26 21:41:07 +00:00
Davide Italiano 4201ed2ea3 [x86-64] Use `//` for integer division in the target definition.
This forces integer division and works with python 2 and python 3.

<rdar://problem/52073911>

llvm-svn: 364465
2019-06-26 19:51:57 +00:00
Adrian Prantl 573ffd88a0 Python 3: decode string as utf-8 to avoid type mismatch.
rdar://problem/51464644

Differential Revision: https://reviews.llvm.org/D63311

llvm-svn: 363413
2019-06-14 15:39:14 +00:00
Adrian Prantl 38be2c65b6 Make crashlog.py less noisy
For end-users there is no point in printing dSYM load errors for
system frameworks, since they will all fail and there's nothing they
can do about it. This patch hides them by default and shows them when
--verbose is present.

Differential Revision: https://reviews.llvm.org/D63310

llvm-svn: 363412
2019-06-14 15:39:11 +00:00
Stefan Granitz 61a7ab7fdb [lldb] Ignore null frames in lldb.macosx crashlog
llvm-svn: 363172
2019-06-12 14:46:37 +00:00
Davide Italiano 192dd7df2f [crashlog] Add a missing call to decode.
<rdar://problem/51139357>

llvm-svn: 362044
2019-05-30 00:35:43 +00:00
Davide Italiano 8803124d23 [crashlog] Use loads() instead of readPlistFromString() for python 3.
<rdar://problem/50903413>

llvm-svn: 361087
2019-05-18 01:57:12 +00:00
Davide Italiano 185de8eeaa [Python] Simplify the code. NFCI.
llvm-svn: 358721
2019-04-18 23:24:54 +00:00
Davide Italiano 085626a873 [crashlog] Strip trailing `\n` from check_output return.
Generally having spurious `\n` doesn't matter, but here the
returning string is a command which is executed, so  we want
to strip it. Pointed out by Jason.

llvm-svn: 358717
2019-04-18 21:32:36 +00:00
Davide Italiano e3b5eba1ba [crashlog] Use the right path for dsymforUUID and remove an unnecessary import.
<rdar://problem/49925960>

llvm-svn: 358615
2019-04-17 21:51:55 +00:00
Serge Guelton 1a12dd70c0 python 2/3 compat: commands vs subprocess
Differential Revision: https://reviews.llvm.org/D59584

llvm-svn: 356995
2019-03-26 14:46:15 +00:00
Serge Guelton 3a22c3cc2b Python 2/3 compat: StringIO
Differential Revision: https://reviews.llvm.org/D59582

llvm-svn: 356910
2019-03-25 15:23:34 +00:00
Serge Guelton 6ee3804613 Python 2/3 compat: tkinter
Differential Revision: https://reviews.llvm.org/D59586

llvm-svn: 356909
2019-03-25 15:22:41 +00:00
Serge Guelton 525cd59f5a Python 2/3 compatibility: from __future__ import print_function
Differential Revision: https://reviews.llvm.org/D59580

llvm-svn: 356695
2019-03-21 18:27:40 +00:00
Serge Guelton ce54fa1855 Workaround items/iteritems difference between Python2 and Python3
Differential Revision: https://reviews.llvm.org/D59588

llvm-svn: 356673
2019-03-21 14:47:40 +00:00
Serge Guelton bfb779188f Portable int/long conversion across Python 2 / Python 3
Differential Revision: https://reviews.llvm.org/D59585

llvm-svn: 356671
2019-03-21 14:41:34 +00:00
Serge Guelton 3577da7667 Portable exception value access across Python 2 / Python 3
Differential Revision: https://reviews.llvm.org/D59583

llvm-svn: 356670
2019-03-21 14:39:55 +00:00
Jason Molenda 2d5e7adf26 A target definition file that may work for
Aarch32 Cortex-M target processor debugging.

<rdar://problem/48448564> 

llvm-svn: 356416
2019-03-18 21:39:54 +00:00
Adrian Prantl f4d2fa3fa0 crashlog.py: Catch exception from subprocess.
llvm-svn: 355572
2019-03-07 00:41:51 +00:00
Davide Italiano 9a8e777f8c [Python] Unbreak the recently modified tests for python 2.
llvm-svn: 355566
2019-03-06 23:50:36 +00:00
Davide Italiano a658ab9f55 [testsuite] Port crashlog to python 3, second attempt.
llvm-svn: 355562
2019-03-06 22:54:11 +00:00
Davide Italiano 814ad73452 Revert "[testsuite] Port crashlog and dependencies to Python 3."
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 01:34:47 +00:00
Davide Italiano fc188448fa [testsuite] Port crashlog and dependencies to Python 3.
Fixes three tests in the testsuite.

llvm-svn: 355359
2019-03-05 00:53:38 +00:00
Shafik Yaghmour d03bf06883 Fix use of non-existing variable in crashlog.py
Summary:
The method find_matching_slice(self) uses uuid_str on one of the paths but the variable does not exist and so this results in a NameError exception if we take that path.

Differential Revision: https://reviews.llvm.org/D57467

llvm-svn: 352772
2019-01-31 17:33:17 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
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
2019-01-19 08:50:56 +00:00
Adrian Prantl f700c8b253 Make crashlog.py work or binaries with spaces in their names
This is a little dangerous since the crashlog files aren't 100%
unambiguous, but the risk is mitigated by using a non-greedy +?
pattern.

rdar://problem/38478511

Differential Revision: https://reviews.llvm.org/D55608

llvm-svn: 349367
2018-12-17 17:26:04 +00:00
Adrian Prantl fb5aa932b1 Make crashlog.py work when a .dSYM is present, but a binary is missing
Often users have a crash log an d a .dSYM bundle, but not the original
application binary. It turns out that for crash symbolication, we can
safely fall back to using the binary inside the .dSYM bundle.

Differential Revision: https://reviews.llvm.org/D55607

llvm-svn: 349366
2018-12-17 17:25:57 +00:00
Greg Clayton 141f208e12 Fixes for GDB remote packet disassembler:
- Add latency timings to GDB packet log summary if timestamps are on log
- Add the ability to plot the latencies for each packet type with --plot
- Don't crash the script when target xml register info is in wierd format

llvm-svn: 343243
2018-09-27 17:55:36 +00:00
Greg Clayton 95c23f6643 Add an interactive mode to BSD archive parser.
llvm-svn: 343242
2018-09-27 17:45:14 +00:00
Greg Clayton ef115de629 Update cmdtemplate.py to use best pratices.
Fixes include:
- fix all lint errors
- add code that will automatically register and LLDB command classes by detecting the classes and any classes that have a "register_lldb_command" function
  - automatically fill in the correct module name when registering commands
  - automatically fill in the class name when registering command

llvm-svn: 335401
2018-06-22 23:34:24 +00:00
Greg Clayton de01668b14 Added a BSD archive tool.
This is a combination stand alone BSD archive tool that can dump BSD archives:

% bsd.py /path/to/foo.a

Search archives for an object file:

% bsd.py --object foo.o bar.a

Dump the symbol definitions found in the __.SYMDEF objects:

% bsd.py --symdef bar.a

Find symbols by name that are listed in the __.SYMDEF objects:

% bsd.py --symbol _Z123 bar.a

Extract objects from BSD archives:

% bsd.py --object foo.o bar.a --extract
% bsd.py --object foo.o bar.a --extract --outfile /tmp/foo.o
% bsd.py --object foo.o bar.a --extract --mtime 0x1234556

It also has installs a new LLDB command line command when imported into LLDB:

(lldb) command script import ~/Dropbox/bin/bsd.py
The "verify-debug-map-objects" command has been installed, type "help verify-debug-map-objects" for detailed help.
(lldb) verify-debug-map-objects a.out

This will iterate through all object files and verify the modification times match for any .o files, it will verify any .o files from BSD archives are found and have matching modification times and print out errors if any are found.

llvm-svn: 328990
2018-04-02 17:20:21 +00:00
Greg Clayton 84a7333a61 Fixed up to use a class for the commands, renamed the commands and added a way to just dump the compile unit full paths and optionally their support files with the new "dump-files"command.
llvm-svn: 318424
2017-11-16 17:14:48 +00:00
Jim Ingham dccb1db1af Modernize the example cmdtemplate.py.
This version relies on a newer and more convenient way
to use a class to implement a command.  It has been in place
since early 2015, so it should be pretty safe to use.

llvm-svn: 317043
2017-10-31 22:38:24 +00:00
Jim Ingham 8bebdff49e The save_crashlog command was still looking at lldb.target and
lldb.process.  That hasn't worked for a long time.  Convert it
to the form that takes an SBExecutionContext and use that instead.

llvm-svn: 315549
2017-10-12 02:21:41 +00:00
Jim Ingham a6976269bd Another silly little thing you can do with Python commands.
Sometimes you want to step along and print a local each time as you go.
You can do that with stop hooks, but that's a little heavy-weight.  This
is a sketch of a command that steps and then does "frame variable" on all
its arguments.

llvm-svn: 314958
2017-10-05 00:49:49 +00:00
Jim Ingham f77bb46dc0 Add an example command to toggle between disassembly-only and source mode.
Sometimes you are debugging in source, but you really only want to see
the disassembly.  That's easy to do but you have to set a few variables.
This command toggles between your old values, and a disassembly only mode.

llvm-svn: 300902
2017-04-20 21:51:27 +00:00
Greg Clayton db1550ab66 Fixed to disassemble new packets and fixed the dumping of the 'x' packets.
llvm-svn: 300341
2017-04-14 17:05:21 +00:00
Jim Ingham 9f44d460d9 Print the error if dsymForUUID sometimes produces bad plists.
Not much we can do about it but at least we can print the bad
plist and the error.

llvm-svn: 298958
2017-03-28 23:25:34 +00:00
Greg Clayton e04e5b954a Improve crashlog.py so it can handle more iOS crashlog files.
<rdar://problem/29191857>

llvm-svn: 289006
2016-12-08 00:22:45 +00:00
Kate Stone b9c1b51e45 *** This commit represents a complete reformatting of the LLDB source code
*** 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-09-06 20:57:50 +00:00