[Lldb-commits] [PATCH] D152494: [lldb][Android] Fix adb shell cat

2023-06-14 Thread Kazuki Sakamoto via Phabricator via lldb-commits
splhack abandoned this revision.
splhack added a comment.

@bulbazord thanks for the suggestion! property works well. D152933 
 supersedes this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152494/new/

https://reviews.llvm.org/D152494

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D152494: [lldb][Android] Fix adb shell cat

2023-06-13 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

An environment variable isn't the worst thing in the world, but what would be 
better is an lldb setting so we can change it at runtime instead of needing to 
restart the debugging session. That may happen if you make a typo or make a 
mistake. Something like `plugin.platform.android.platform-run-as`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152494/new/

https://reviews.llvm.org/D152494

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D152494: [lldb][Android] Fix adb shell cat

2023-06-12 Thread Nathan Lanza via Phabricator via lldb-commits
lanza accepted this revision.
lanza added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152494/new/

https://reviews.llvm.org/D152494

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D152494: [lldb][Android] Fix adb shell cat

2023-06-08 Thread Kazuki Sakamoto via Phabricator via lldb-commits
splhack created this revision.
splhack added a reviewer: clayborg.
Herald added a subscriber: danielkiss.
Herald added a project: All.
splhack edited the summary of this revision.
splhack added reviewers: labath, lanza.
splhack published this revision for review.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When LLDB failed to pull a module file due to the security constraint,
it uses "adb shell cat" as a fallback for getting the file.
However when "adb pull path" fails, "adb shell cat path" also fails
with the same security reason.

Introduce ANDROID_PLATFORM_RUN_AS to grant permission to read the file
with "adb shell run-as package cat path" command line.
https://android.googlesource.com/platform/system/core.git/+/refs/heads/master/run-as/run-as.cpp#39


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152494

Files:
  lldb/docs/use/remote.rst
  lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp


Index: lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -204,7 +204,11 @@
   AdbClient adb(m_device_id);
 
   char cmd[PATH_MAX];
-  snprintf(cmd, sizeof(cmd), "cat '%s'", source_file.c_str());
+  if (const char *run_as = std::getenv("ANDROID_PLATFORM_RUN_AS"))
+snprintf(cmd, sizeof(cmd), "run-as '%s' cat '%s'", run_as,
+ source_file.c_str());
+  else
+snprintf(cmd, sizeof(cmd), "cat '%s'", source_file.c_str());
 
   return adb.ShellToFile(cmd, minutes(1), destination);
 }
Index: lldb/docs/use/remote.rst
===
--- lldb/docs/use/remote.rst
+++ lldb/docs/use/remote.rst
@@ -140,6 +140,10 @@
 The client ports are configurable through the environment variables
 ANDROID_PLATFORM_LOCAL_PORT and ANDROID_PLATFORM_LOCAL_GDB_PORT, respectively.
 
+The "remote-android" platform requires ANDROID_PLATFORM_RUN_AS when target
+application install path is not accessible with "adb pull". LLDB will use
+"adb shell run-as $ANDROID_PLATFORM_RUN_AS cat path" to get module file.
+
 Launching a locally built process on the remote machine
 ---
 


Index: lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -204,7 +204,11 @@
   AdbClient adb(m_device_id);
 
   char cmd[PATH_MAX];
-  snprintf(cmd, sizeof(cmd), "cat '%s'", source_file.c_str());
+  if (const char *run_as = std::getenv("ANDROID_PLATFORM_RUN_AS"))
+snprintf(cmd, sizeof(cmd), "run-as '%s' cat '%s'", run_as,
+ source_file.c_str());
+  else
+snprintf(cmd, sizeof(cmd), "cat '%s'", source_file.c_str());
 
   return adb.ShellToFile(cmd, minutes(1), destination);
 }
Index: lldb/docs/use/remote.rst
===
--- lldb/docs/use/remote.rst
+++ lldb/docs/use/remote.rst
@@ -140,6 +140,10 @@
 The client ports are configurable through the environment variables
 ANDROID_PLATFORM_LOCAL_PORT and ANDROID_PLATFORM_LOCAL_GDB_PORT, respectively.
 
+The "remote-android" platform requires ANDROID_PLATFORM_RUN_AS when target
+application install path is not accessible with "adb pull". LLDB will use
+"adb shell run-as $ANDROID_PLATFORM_RUN_AS cat path" to get module file.
+
 Launching a locally built process on the remote machine
 ---
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits