Commit Graph

20 Commits

Author SHA1 Message Date
Haibo Huang
a1d5d38249 [NDK] Add an option to gdbrunner to run lldb
Test: Run ndk-gdb on ndkgdbsample app
Change-Id: I29a892565693adec06d48570e92386e775c87e28
2019-12-10 00:45:43 +00:00
Ryan Prichard
5d1c3cb157 gdbclient: support various PT_INTERP values
gdb looks for an executable's dynamic linker using the PT_INTERP setting
from the executable. That value can be various things:
 - /system/bin/linker[64]
 - /system/bin/linker_asan[64]
 - /system/bin/bootstrap/linker[64]

Currently, only the bootstrap linker is available in the sysroot/symbols
directory. The ordinary and ASAN linkers are symlinks on the target and
are missing from the sysroot (aka symbols) directory.

Use the executable's PT_INTERP value to find the symbolized linker binary
and add it to the solib search path. If necessary, copy or pull a linker
binary.

Test: gdbclient.py -r ls
  "info sharedlib" shows $OUT/symbols/apex/com.android.runtime.debug/bin/linker64

Test: gdbclient.py -r /data/nativetest64/bionic-unit-tests/bionic-unit-tests
  "info sharedlib" shows $OUT/symbols/system/bin/bootstrap/linker64

Test: m asan_test
  gdbclient.py -r /data/nativetest64/asan_test/asan_test
  "info sharedlib" shows /tmp/gdbclient-linker-HunVs9/linker_asan64

Bug: http://b/134183407
Change-Id: I7f79943dcd9ec762d1aaf21178bb6ab3eff40617
2019-06-11 16:07:37 -07:00
André Keller
cc915e152f The "ps" command has changed in Android O
The gdbrunner script executes "ps" to list all running processes and
this needs to be changed to "ps -A" (toybox) for Android O instead of
"ps -w" (busybox) for custom ROMs or "ps" (toolbox) as default.

Test: manual
Change-Id: I99606cdf51b124369e4d0fcfe5917109cefe408c
2017-11-08 16:26:12 +01:00
Ryan Prichard
01fa9e488b gdbrunner: strip the newline off the result of "which executable"
Test: gdbclient.py -r echo foo
Change-Id: Id95d9f4e78c5e9dbd8ca8e30ffcfaff9bf5ef7c7
2017-10-11 17:45:20 -07:00
Kevin Rocard
258c89e9e4 Resolve gdbclient.py -r executable from target
gdbclient.py -r allows to provide an executable to be run on the target.
Before this patch the absolute path of the executable had to be
provided. This was inconvenient as the user has to first look up for the
exe on the target before debuging it.

With this patch, gdbclient.py will look for the executable on the
target if an absolute path is not provided.

Test: gdbserver -r ls
Change-Id: I610fd0a57b034ba8864874eeb1f7345d4a7daad9
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-07-12 18:48:16 -07:00
Elliott Hughes
89e1ecf9a1 Fix gdbclient.py -p.
Bug: http://b/26413900
Test: manually ran gdbserver on device, connected with -p
Change-Id: If58b95e52167c38263e77fe85bea14e0d7401bf4
2017-06-30 14:03:32 -07:00
Roland Levillain
d403f09a40 gdbrunner: Fix find_binary's named argument.
Rename it from `user` to `run_as_cmd` to match the use of this method
in handle_switches in scripts/gdbclient.py.

Test: Run scripts/gdbclient.py -p <PID> on suspended process having pid <PID>
Change-Id: I9820858b1f43d5cb25a9a59e9df618ed4e47f3f0
2017-06-05 13:07:27 +01:00
Josh Gao
057c2739fc gdbrunner: take a run-as/su command instead of a user.
Switch from assuming that "root" meant su to an explicit prepended
argument, to allow things like `gdbclient.py --user shell`.

Test: gdbclient.py --user shell -r /system/bin/ls
Change-Id: I9d02eea7c6d79898ed8b13817e009630b0f9536a
2017-05-24 18:32:25 -07:00
Josh Gao
095a4a276a gdbrunner: avoid using [ on older devices.
Bug: https://github.com/android-ndk/ndk/issues/78
Change-Id: I00cae89076d3b76ab3e29e884015ea3a2eabecb8
2016-05-04 16:04:18 -07:00
Josh Gao
f3532aedfa gdbrunner: decapitalize usage for --adb.
Change-Id: I36e84e2570d41c0723a35eab9cea329af4987006
2016-03-28 18:38:55 -07:00
Josh Gao
7f6e8ddb79 gdbrunner: expose adb.split_lines, use it.
Change-Id: I895aacaababf87c1e82ff5604c028cc475207304
2016-03-28 11:26:03 -07:00
Josh Gao
dc10068c64 gdbrunner: don't use getppid to name the log file.
Windows doesn't really have a concept of process parenthood.

Bug: https://github.com/android-ndk/ndk/issues/46
Change-Id: I1a47eb42a9eb5d94c95136bb73eac1caabb923c7
2016-03-28 11:26:03 -07:00
Josh Gao
a0f62495a4 gdbrunner: close the exec script before passing it to gdb.
Windows won't allow gdb to open to file while we have it open.

Bug: https://github.com/android-ndk/ndk/issues/46
Change-Id: I5dcee7c70a582e94c472d6d09bf79c2616ea76fa
2016-03-28 11:26:02 -07:00
Josh Gao
acc0ba81cc Add a gdb_flags argument to gdbrunner.start_gdb.
Change-Id: I35aae1290f97a33c55e9bddd2b986a7c3e93d1df
2015-10-28 15:20:57 -07:00
Josh Gao
2c7e952f1c Allow gdbrunner.start_gdbserver to not upload gdbserver.
Change-Id: I59239c3989ccd91755407e65b0d2f8183482564c
2015-10-28 14:22:03 -07:00
Josh Gao
aacbc2318d Add get_pids helper to gdbrunner.
Change-Id: Id685bf740bde382c62a02fa4d6f03717bae91f50
2015-10-28 14:22:02 -07:00
Josh Gao
44b84a8e03 Don't throw when we fail to find a device.
Instead, set it to None and let the caller handle things.

Change-Id: Ic4f27fdb52ebd6bc5b4048e4e688ec7bd2509bfa
2015-10-28 14:21:59 -07:00
Josh Gao
3fd43b5bf4 Allow selection of adb command.
This is useful for ndk-gdb.py on Windows.

Change-Id: I2a2b6b50ae00bcfc530c555f06c945b4f53f9999
2015-10-28 14:18:55 -07:00
David Pursell
639d1c491a gdb: allow gdbclient.py to find local files.
gdbclient.py is always downloading the stripped version of executable
files from the device. This CL first tries to find the unstripped local
file before falling back to the stripped version.

Bug: http://b/24947939
Change-Id: I7a49d0d8b28590ee99ce892d3e3476921f4ae974
2015-10-21 10:25:25 -07:00
Josh Gao
75b0383747 Add gdbrunner package for shared functionality.
This deduplicates code between gdbclient.py and ndk-gdb.py.

Bug: http://b/23715403
Change-Id: I6ee61b466aaf3cde8f6b26b11bfa95761821cb6d
2015-09-30 14:36:35 -07:00