1
1
# NativeAOT Sample
2
2
3
- This is the sample for using NativeAOT with .net Android
3
+ This is the sample for using NativeAOT with .NET for Android.
4
4
5
5
## Debugging
6
6
7
7
In order to debug we need to use ` lldb ` . First install the application
8
8
9
- ``` dotnetcli
9
+ ``` sh
10
10
./dotnet-local.sh build samples/NativeAOT/NativeAOT.csproj -c Release -p:DebugSymbols=true -t:Install
11
11
```
12
12
@@ -19,7 +19,7 @@ In order to lldb debugging to work we need to make sure we install the `lldb-ser
19
19
The following steps, install the ` lldb-server ` , stop any existing lldb-server process and they launches
20
20
it. It also sets up the required port forwarding so we can connect to the server from the local machine.
21
21
22
- ``` dotnetcli
22
+ ``` shell
23
23
adb push $( ANDROID_NDK_HOME) /toolchains/llvm/prebuilt/darwin-x86_64/lib/clang/18/lib/linux/aarch64/lldb-server /data/local/tmp/lldb-server
24
24
adb shell run-as net.dot.hellonativeaot cp /data/local/tmp/lldb-server .
25
25
adb forward tcp:5039 tcp:5039
@@ -31,7 +31,7 @@ Note: We have to run the `lldb-server` in the context of the app so it has the c
31
31
32
32
Once ` lldb-server ` is up and running, you will want to run up the app using the following
33
33
34
- ``` dotnetcli
34
+ ``` shell
35
35
adb shell am start -S --user " 0" -a " android.intent.action.MAIN" -c " android.intent.category.LAUNCHER" -n " net.dot.hellonativeaot/my.MainActivity" -D
36
36
```
37
37
@@ -41,7 +41,7 @@ If you do not want to the app to pause on startup, you can omit the `-D` argumen
41
41
Now that the app is running we need to get the process id. We do that using ` adb shell ps ` .
42
42
The ` grep ` is used to filter the results to only our app.
43
43
44
- ``` dotnetcli
44
+ ``` shell
45
45
adb shell ps | grep net.dot.hellonativeaot
46
46
```
47
47
@@ -50,7 +50,7 @@ These setup `lldb` and loads the symbols, then attaches to the process. It also
50
50
a ` clearjdb ` command which you can use from within the ` lldb ` REPL to clear the Java
51
51
Debugger dialog you get when you launch your app.
52
52
53
- ``` dotnetcli
53
+ ``` shell
54
54
lldb
55
55
> platform select remote-android
56
56
> platform connect connect://localhost:5039
65
65
66
66
if your symbols are in a separate ` .dbg` file, you can use the following.
67
67
68
- ``` dotnetcli
68
+ ` ` `
69
69
> target symbols add samples/NativeAOT/bin/Debug/net10.0-android/android-arm64/native/NativeAOT.so.dbg
70
70
` ` `
71
71
@@ -75,13 +75,15 @@ launching the activity.
75
75
you can do this via the ` lldb` terminal by using the ` clearjdb` function which is an
76
76
extension function we have.
77
77
78
- or use the following from the command line.
78
+ or use the following from the command line:
79
79
80
- ` python3 samples/NativeAOT/lldb_commands.py `
80
+ ` ` ` shell
81
+ python3 samples/NativeAOT/lldb_commands.py
82
+ ` ` `
81
83
82
84
you can also clear it manually via
83
85
84
- ``` dotnetcli
86
+ ` ` ` shell
85
87
adb forward --remove tcp:8700
86
88
adb forward tcp:8700 jdwp:< pid>
87
89
jdb -attach localhost:8700
@@ -93,7 +95,7 @@ You will want to type `quit` to exit the `jdb` terminal once it has connected.
93
95
94
96
Setting breakpoints just need to use the filename and line number, these are just standard ` lldb` commands.
95
97
96
- ``` dotnetcli
98
+ ` ` `
97
99
breakpoint set -f MainActivity.cs -l 34
98
100
` ` `
99
101
0 commit comments