Commit 246c9c0
[android] implement support for
## Purpose
Properly respond to the GDB `qModuleInfo` packet, defined
[here](https://lldb.llvm.org/resources/lldbgdbremote.html#qmoduleinfo-module-path-arch-triple),
in the DS2 platform session.
## Overview
* Implement basic support to parse the build ID out of an ELF executable
file
* Define a new `GetExecutableFileBuildID` method in the `Host::Platform`
interface and implement a Linux and FreeBSD version based on the new ELF
support to fetch build ID
* Define a new `fileSize` method in the `Host::File` interface and
implement a POSIX version based on `stat`
* Define a new `onQueryModuleInfo` method in the `Session` interface and
implement it in the platform session using the new file size and
executable file build ID implementations
If deemed important, we can eventually implement
[`jModulesInfo`](https://lldb.llvm.org/resources/lldbgdbremote.html#jmodulesinfo-file-triple)
using the bulk of this implementation.
## Problem Details
Though `qModuleInfo` is documented as optional for lldb support, I have
found it must be implemented on Android in order to properly resolve
symbols of on-device executable files.
## Validation
On an aarch64 Android device and x86_64 Android emulator, attach lldb to
a ds2 instance running in the app sandbox. Verify that images are loaded
with `(lldb) image list`.
Verify Swift symbols from an Android test app can be looked-up in lldb:
```
(lldb) image lookup --name getSwiftGreeting
2 matches found in C:\Users\user\.lldb\module_cache\remote-android\.cache\2749C9AB-7810-6105\libSwiftMainActivity.so:
Address: libSwiftMainActivity.so[0x0000000000006f40] (libSwiftMainActivity.so.PT_LOAD[1]..text + 864)
Summary: libSwiftMainActivity.so`Java_com_thebrowsercompany_SwiftSupportTestApp_MainActivity_getSwiftGreeting at <compiler-generated>
Address: libSwiftMainActivity.so[0x0000000000006f50] (libSwiftMainActivity.so.PT_LOAD[1]..text + 880)
Summary: libSwiftMainActivity.so`SwiftMainActivity.getSwiftGreeting(Swift.UnsafeMutablePointer<Swift.Optional<Swift.UnsafePointer<__C.JNINativeInterface>>>, Swift.UnsafeMutableRawPointer) -> Swift.Optional<Swift.UnsafeMutableRawPointer> at MainActivity.swift:8
(lldb)
```
Build and execute on an AMD64 FreeBSD 14.0 host to verify the build is
not broken.
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>qModuleInfo packet1 parent 5935b73 commit 246c9c0
File tree
19 files changed
+205
-4
lines changed- Headers/DebugServer2
- GDBRemote
- Host
- Support/POSIX
- Sources
- GDBRemote
- Host
- Darwin
- FreeBSD
- Linux
- POSIX
- Windows
- Support/POSIX
19 files changed
+205
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
28 | 37 | | |
29 | 38 | | |
30 | 39 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
413 | 422 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
98 | 124 | | |
99 | 125 | | |
100 | 126 | | |
| |||
0 commit comments