LLDB: Only specify triple on target create when platform is given (#3137)

* Only specify triple on target create when platform is given

* Update pwndbg/dbg/lldb/repl/__init__.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
pull/3140/head
Matt. 6 months ago committed by GitHub
parent df12edc0d5
commit 338fb988a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -891,27 +891,31 @@ def target_create(args: List[str], dbg: LLDB) -> None:
if args.arch:
dbg.debugger.SetDefaultArchitecture(args.arch)
triple = _get_target_triple(dbg.debugger, args.filename)
if not triple:
print_error(f"could not detect triple for '{args.filename}'")
return
if args.platform == "qemu-user":
arch = triple.split("-")[0]
# Without setting it qemu-user don't work ;(
dbg._execute_lldb_command(f"settings set platform.plugin.qemu-user.architecture {arch}")
if args.platform:
dbg.debugger.SetCurrentPlatform(args.platform)
if args.sysroot:
dbg.debugger.SetCurrentPlatformSDKRoot(args.sysroot)
# Create the target with the debugger.
error = lldb.SBError()
target: lldb.SBTarget = dbg.debugger.CreateTarget(
args.filename, triple, args.platform, True, error
)
if args.platform:
dbg.debugger.SetCurrentPlatform(args.platform)
# Having the platform specified requires that we specify the triple.
triple = _get_target_triple(dbg.debugger, args.filename)
if not triple:
print_error(f"could not detect triple for '{args.filename}'")
return
if args.platform == "qemu-user":
arch = triple.split("-")[0]
# Without setting it qemu-user don't work ;(
dbg._execute_lldb_command(f"settings set platform.plugin.qemu-user.architecture {arch}")
target: lldb.SBTarget = dbg.debugger.CreateTarget(
args.filename, triple, args.platform, True, error
)
else:
# Let LLDB figure out both the triple and the platform automatically.
target = dbg.debugger.CreateTarget(args.filename, None, None, True, error)
if not error.success or not target.IsValid():
print_error(f"could not create target for '{args.filename}': {error.description}")
return

Loading…
Cancel
Save