diff options
author | Med Ismail Bennani <medismail.bennani@gmail.com> | 2022-08-03 14:11:43 -0700 |
---|---|---|
committer | Med Ismail Bennani <medismail.bennani@gmail.com> | 2022-08-09 21:01:37 -0700 |
commit | a633c5e11b4443000aa199a2df41eda4e2c6851b (patch) | |
tree | 92ed6cefc61ded435e46b2451a20a99d7f92e098 /lldb/examples/python/crashlog.py | |
parent | d44f8a50d50909e67f28f91511045404261dbcbf (diff) | |
download | llvm-a633c5e11b4443000aa199a2df41eda4e2c6851b.zip llvm-a633c5e11b4443000aa199a2df41eda4e2c6851b.tar.gz llvm-a633c5e11b4443000aa199a2df41eda4e2c6851b.tar.bz2 |
[lldb/crashlog] Add '-t|--target' option to interactive mode
This patch introduces a new flag for the interactive crashlog mode, that
allow the user to specify, which target to use to create the scripted
process.
This can be very useful when lldb already have few targets created:
Instead of taking the first one (zeroth index), we will use that flag to
create a new target. If the user didn't provide a target path, we will rely
on the symbolicator to create a targer.If that fails and there are already
some targets loaded in lldb, we use the first one.
rdar://94682869
Differential Revision: https://reviews.llvm.org/D129611
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/examples/python/crashlog.py')
-rwxr-xr-x | lldb/examples/python/crashlog.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index c30a0ec..b6b3efe 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -1017,11 +1017,22 @@ def load_crashlog_in_scripted_process(debugger, crash_log_file, options): crashlog = CrashLogParser().parse(debugger, crashlog_path, False) - if debugger.GetNumTargets() > 0: - target = debugger.GetTargetAtIndex(0) - else: + target = lldb.SBTarget() + # 1. Try to use the user-provided target + if options.target_path: + target = debugger.CreateTarget(options.target_path) + if not target: + result.PutCString("error: couldn't create target provided by the \ + user ({})".format(options.target_path)) + return + # 2. If the user didn't provide a target, try to create a target using the symbolicator + if not target or not target.IsValid(): target = crashlog.create_target() - if not target: + # 3. If that didn't work, and a target is already loaded, use it + if (target is None or not target.IsValid()) and debugger.GetNumTargets() > 0: + target = debugger.GetTargetAtIndex(0) + # 4. Fail + if target is None or not target.IsValid(): result.PutCString("error: couldn't create target") return @@ -1183,6 +1194,12 @@ def CreateSymbolicateCrashLogOptions( action='store_true', help='dump symbolicated stackframes without creating a debug session', default=True) + option_parser.add_option( + '--target', + '-t', + dest='target_path', + help='the target binary path that should be used for interactive crashlog (optional)', + default=None) return option_parser |