Commit Graph

91 Commits

Author SHA1 Message Date
Dan Albert
808c90cf8d Fix tests.
Bug: None
Test: pytest
Change-Id: Ibe4259750a8d6f1800b5f659a80b301226d6929d
2023-01-13 14:30:19 -08:00
Dan Albert
91e796d227 Make this a proper python package.
Python is picky about directory structure. Ever since python 3 the tests
have not been able to run because the import won't work. This fixes that
problem.

Bug: None
Test: None
Change-Id: I4a626f130e4ca3cd2c9b69804083dfe6daffb5f7
2023-01-13 14:30:19 -08:00
Dan Albert
ac3c9fd05e Remove python 2 garbage.
This code hasn't worked since the python 3 switch, because `unicode`
doesn't exist any more. The problems that this code worked around were
all python 2 problems as well, so it's no longer needed.

Bug: None
Test: ran test.py on windows and mac
Change-Id: Ifacaed5cddc6c9ee9d9d9872c2f2851150ace468
2023-01-13 14:30:18 -08:00
Dan Albert
316dbf5332 Add type information to adb module.
mypy still complains about a few things here, but that looks to be
mostly coming from code that is very, very dead in python 3.

The tests don't run, and haven't since the python 3 switch. Will try to
revive those next, but it likely requires moving files around to fix the
package structure (source needs to go in a subdirectory to make a real
package, as do the tests).

Bug: None
Test: mypy . && pylint .
Change-Id: Ide55a41babecbd6684b73787b17e7f5fdb81c090
2023-01-13 14:30:18 -08:00
Dan Albert
16a9f493c9 Add py.typed file to export types to dependents.
There isn't any type info yet, but this is a prereq for exporting that
data.

https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-library-stubs-or-py-typed-marker

Bug: None
Test: None
Change-Id: I9fa7a540a57ff76a4f8dcded92456b8c4be09dad
2022-12-16 11:59:17 -08:00
Dan Albert
034e7e2827 Add logcat APIs.
Bug: None
Test: Using this in the NDK
Change-Id: I8becab8a0697f2378f1ce472091be497ba13c848
2022-10-20 17:03:10 -07:00
Treehugger Robot
9a0d8d75f0 Merge "Add riscv binary recognition in gdb script" 2022-10-12 18:04:03 +00:00
Xia Lifang
8d2ff19bc3 Add riscv binary recognition in gdb script
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Change-Id: I61793c3c1e32828ac4196a20f85b4fe2832c4992
2022-10-12 19:36:09 +08:00
Inseob Kim
7b29d05387 gdbrunner: Make sure remote lldb-server has +x
Because 'adb push' often misses the executable permission, lldbserver
can fail without any meaningful error messages. This may happen when the
users are on Windows. To fix that, explicitly chmod remote lldbserver
after push.

Bug: 185210505
Test: manual
Change-Id: I88defd4905a9b902424ae8ef4b38a16932b31f02
2022-10-12 09:40:14 +09:00
Cole Faust
d7b3122a24 Remove py2 usages
Bug: 203436762
Test: m nothing
Change-Id: I1ab26c5cfc28032700cb9d5454cbee1b7fd8cbd7
2022-09-12 12:32:22 -07:00
Dan Albert
22902078f1 Remove obsolete OWNER.
Test: None
Bug: None
Change-Id: I0bbaafb392b5283edd0ec49de3d15a3dd7834173
2022-03-24 12:22:59 -07:00
Peter Collingbourne
ba5482675f gdbclient.py: Implement --chroot argument.
This allows executables to be debugged inside a chroot (such as the ART
testing chroot).

Change-Id: I1b790c3c2307e240d37ed0afb9a930d00957acec
2022-03-03 12:33:26 -08:00
Bob Badour
082705bfb3 Fix license texts.
Push specific licenses down the tree toward the leaf directories.

Remove extra Apache 2.0 license texts--just use Android-Apache-2.0

Test: m nothing
Change-Id: Ibee25f75f5933699d6f43acdc192b2ada6823757
2022-01-20 19:04:52 +00:00
Elliott Hughes
17de6ce9ce Fix gdbclient to work with Python 3.
Test: gdbclient.py -r date
Change-Id: I10616c197dd50fe653e56c2e4c39e2371445c72b
2021-06-23 18:04:27 -07:00
Bob Badour
f7cf305656 [LSC] Add LOCAL_LICENSE_KINDS to development
Added SPDX-license-identifier-Apache-2.0 to:
  apps/BluetoothDebug/Android.bp
  apps/BuildWidget/Android.bp
  apps/CustomLocale/Android.bp
  apps/DevelopmentSettings/Android.bp
  apps/Fallback/Android.bp
  apps/GestureBuilder/Android.bp
  apps/NinePatchLab/Android.bp
  apps/OBJViewer/Android.bp
  apps/PushApiAuthenticator/Android.bp
  apps/PushApiTestAppOne/Android.bp
  apps/PushApiTestAppTwo/Android.bp
  apps/SdkSetup/Android.bp
  apps/SettingInjectorSample/Android.bp
  apps/WidgetPreview/Android.bp
  apps/launchperf/Android.bp
  cmds/monkey/Android.mk
  gsi/gsi_util/Android.bp
  gsi/repack_super_image/Android.bp
  host/windows/Android.bp
  python-packages/Android.bp
  samples/AccelerometerPlay/Android.bp
  samples/AdaptiveIconSample/Android.bp
  samples/AliasActivity/Android.bp
  samples/AndroidBeamDemo/Android.bp
  samples/AppNavigation/Android.bp
  samples/AutofillKeyboard/Android.bp
  samples/BackupRestore/Android.bp
  samples/BasicGLSurfaceView/Android.bp
  samples/BluetoothChat/Android.bp
  samples/BrokenKeyDerivation/Android.bp
  samples/BrokenKeyDerivation/tests/Android.bp
  samples/BusinessCard/Android.bp
  samples/Compass/Android.bp
  samples/ContactManager/Android.bp
  samples/CubeLiveWallpaper/Android.bp
  samples/DataWiper/Android.bp
  samples/DeviceAdminWhitelistedAccount/Android.bp
  samples/FixedGridLayout/Android.bp
  samples/HeavyWeight/Android.bp
  samples/HelloActivity/Android.bp
  samples/HelloActivity/tests/Android.bp
  samples/HelloEffects/Android.bp
  samples/Home/Android.bp
  samples/HoneycombGallery/Android.bp
  samples/InlineFillService/Android.bp
  samples/JetBoy/Android.bp
  samples/LceDemo/Android.bp
  samples/LunarLander/Android.bp
  samples/LunarLander/tests/Android.bp
  samples/MultiResolution/Android.bp
  samples/MultiWindow/Android.bp
  samples/MySampleRss/Android.bp
  samples/NotePad/Android.bp
  samples/Obb/Android.bp
  samples/RSSReader/Android.bp
  samples/ReceiveShareDemo/Android.bp
  samples/SampleSyncAdapter/Android.bp
  samples/SimpleJNI/Android.bp
  samples/SimpleJNI/jni/Android.bp
  samples/SipDemo/Android.bp
  samples/SkeletonApp/Android.bp
  samples/SkeletonApp/tests/Android.bp
  samples/Snake/Android.bp
  samples/Snake/tests/Android.bp
  samples/SoftKeyboard/Android.bp
  samples/SpellChecker/HelloSpellChecker/Android.bp
  samples/SpellChecker/SampleSpellCheckerService/Android.bp
  samples/StackWidget/Android.bp
  samples/ThemedNavBarKeyboard/Android.bp
  samples/ToyVpn/Android.bp
  samples/TtsEngine/Android.bp
  samples/USB/AdbTest/Android.bp
  samples/USB/MissileLauncher/Android.bp
  samples/UiAutomator/Android.mk
  samples/Vault/Android.bp
  samples/Vault/tests/Android.bp
  samples/VoiceRecognitionService/Android.bp
  samples/VoicemailProviderDemo/Android.bp
  samples/WeatherListWidget/Android.bp
  samples/WiFiDirectDemo/Android.bp
  samples/WiFiDirectServiceDiscovery/Android.bp
  samples/Wiktionary/Android.bp
  samples/WiktionarySimple/Android.bp
  samples/XmlAdapters/Android.bp
  samples/apkcachetest/Android.bp
  samples/training/NsdChat/Android.bp
  scripts/Android.bp
  testrunner/Android.mk
  testrunner/tests/Android_native.mk
  tools/apkcheck/Android.bp
  tools/bugreport/Android.bp
  tools/etc1tool/Android.bp
  tools/idegen/Android.bp
  tools/mkstubs/Android.bp
  tools/rmtypedefs/Android.bp
  vndk/Android.bp
  vndk/tools/Android.bp
  vndk/tools/elfcheck/Android.bp
  vndk/tools/header-checker/Android.bp
  vndk/tools/header-checker/src/repr/protobuf/proto/Android.bp
  vndk/tools/header-checker/tests/integration/ifunc/Android.bp
  vndk/tools/header-checker/tests/integration/version_script_example/Android.bp
  vndk/tools/image-diff-tool/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-CPL-1.0 SPDX-license-identifier-MIT
    SPDX-license-identifier-Unicode-DFS SPDX-license-identifier-W3C
    legacy_restricted legacy_unencumbered
to:
  Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-CPL-1.0
to:
  samples/SearchableDictionary/Android.bp

Added SPDX-license-identifier-Apache-2.0 legacy_unencumbered
to:
  tools/Android.bp

Added SPDX-license-identifier-BSD SPDX-license-identifier-CPL-1.0
    SPDX-license-identifier-MIT SPDX-license-identifier-Unicode-DFS
    SPDX-license-identifier-W3C
to:
  sdk/Android.bp

Added legacy_restricted
to:
  samples/KeyChainDemo/Android.bp
  tools/line_endings/Android.bp
  vndk/tools/definition-tool/datasets/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I9847e00fb4278bc083b4debbc751003c995ea45c
2021-02-12 17:13:45 -08:00
Ryan Prichard
a51b4796c7 Add "--" to separate program args from lldb/gdb server args
Without this, "lldbclient.py -r ls --help" fails, because the lldb/gdb
server handles the "--help" argument rather than passing it through to
the program being started.

Test: lldbclient.py --lldb -r /system/bin/ls --help
Test: gdbclient.py --no-lldb -r /system/bin/ls --help
Change-Id: I76c7e73b535125ea96f5435bbfe99099786956c1
2020-09-21 20:48:52 -07:00
Haibo Huang
e8ab4475ea Merge "Make lldb default for gdbclient.py" 2020-09-15 22:04:29 +00:00
Haibo Huang
6a4636a9ef Make lldb default for gdbclient.py
Adds a symlink lldbclient.py that pointing to gdbclient.py

Bug: 168187078
Change-Id: I1831875812d22bb6a264b8396bc9d3b8ed7712e3
2020-09-15 18:55:52 +00:00
Haibo Huang
0cb1c9b4e5 Show a warning if adb is not root before gdbclient.py
Bug: 168278173
Change-Id: I0e60c4036b611e31ffd3436ae2389780e9cda0e3
2020-09-15 11:28:46 -07:00
Josh Gao
e955f07799 Support lists of files in adb.AndroidDevice.push.
Bug: http://b/166155032
Test: system/core/adb/test_device.py
Change-Id: I7a6514070b5bbb379f2652053de64a7603e988ae
2020-09-08 18:09:32 -07:00
Treehugger Robot
dfb244428a Merge "Update gitignore." 2020-05-19 03:36:44 +00:00
Haibo Huang
07e17073c5 Updates gdbclient.py for lldb
1. Sets up source mapping so that people can run from other directories.
2. Removes PYTHONHOME. It is embedded into the binary.

Change-Id: Ic7a7f1483dc645d890b7e0f3dcbb0ebb169794ac
2020-05-12 16:51:29 -07:00
Dan Albert
f92680d51a Update gitignore.
Was missing .mypy_cache mainly, but this is a full update from
https://github.com/github/gitignore/blob/master/Python.gitignore.

Test: git status
Bug: None
Change-Id: Ic47242e907cd24a8e58d2ba1d5c3fc2c6d4b7513
2020-05-08 11:41:32 -07:00
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
Adrian Salido
8d10687419 adb_py: Build python3 module
Commit 1b06c6e40d ("Python 3 compatibility.") addressed python3
compatilbity issues for adb python package. Enable it in build.

Test: python3 test.py
Change-Id: Ie00e86f473a79f215b8e053a6ed8be5a2184e0a4
2019-09-24 23:06:54 +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
Dan Albert
be37f5542d Add Python git ignore.
Test: git status (after having built this package)
Bug: None
Change-Id: I63c36eef51b7ecb950af0ad06385e13a3b0cd870
2018-04-26 12:48:30 -07:00
Dan Albert
1b06c6e40d Python 3 compatibility.
Test: ndk/run_tests.py
Bug: None
Change-Id: Id0d2d8024adec880c1a41b524704df1641cda065
2018-02-14 12:46:58 -08:00
Elliott Hughes
22b6b9faf9 Add python-packages OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ia7ef3254454a851577873e92d38ede3b84b3bbbf
2017-12-14 12:50:14 -08:00
Treehugger Robot
1fc6d09b95 Merge "The "ps" command has changed in Android O" 2017-11-13 23:34:22 +00:00
Josh Gao
908c4dbd10 Move GetDeviceTest from adb's test_device.py to adb package.
This test actually belongs with the adb python wrapper, since it's not
affected by changes to adb itself.

Bug: http://b/64260633
Test: python test.py
Change-Id: Ia70a5529e30d91ea6232c65c9d50b2dabd07b925
2017-11-08 14:39:34 -08: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
5b1219eaaa Record the path to adb used for the device
Test: run ndk-gdb.py
Change-Id: I12487c63ee00aae46adba9c98056f295a341c64a
2017-10-19 17:40:28 -07: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
Treehugger Robot
e79b9969d6 Merge "Remove device.get_props." 2017-06-15 19:45:27 +00: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
Elliott Hughes
c34da2dcc7 Remove device.get_props.
Bug: https://issuetracker.google.com/37093233
Test: N/A
Change-Id: I6f516904475354e51071544bf1bf6ccb0f30f583
2017-06-02 17:22:37 -07:00
Treehugger Robot
3099f0c89d Merge "gdbrunner: take a run-as/su command instead of a user." 2017-05-31 00:35:47 +00: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
GuangHui Liu
328def813e Add Soong rule for python adb library.
Test: m adb_integration_test_adb adb_integration_test_device

Change-Id: Id055f10adfb14f18f30b92131682d758de72c3c7
2017-05-22 12:37:20 -07:00
Dan Albert
c52723d77d Add support for push --sync.
Test: nose2 in system/core/adb
Bug: None
Change-Id: I6dcea2ff38a721f941c4abeba2949a319ea8c75f
2017-05-19 11:11:43 -07:00
Daniel Rosenberg
83bef81a9c Add python fastboot package
Change-Id: I310b259c59e2a1c609254ea60e8fc6438d3b2dc5
2016-08-16 17:12:38 -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
016c18c73d Fix adb.py.
oops

Change-Id: Id3e11ebc89d32f1d0a606047f9b69469fe701098
2016-03-29 11:33:30 -07:00
Josh Gao
f3532aedfa gdbrunner: decapitalize usage for --adb.
Change-Id: I36e84e2570d41c0723a35eab9cea329af4987006
2016-03-28 18:38:55 -07:00
Josh Gao
1d404e6c92 adb.py: require adb version >= 35 to use shell protocol.
Change-Id: I2513db8a88e1a1bd96ce642251882de97ca37df6
2016-03-28 14:10:57 -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