-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for Debugging NativeAOT #9855
base: main
Are you sure you want to change the base?
Conversation
```dotnetcli | ||
adb shell am start -S --user "0" -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "net.dot.hellonativeaot/my.MainActivity" -D | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove the -D
, do you need the jdb
example below? Or is it needed for other reasons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -D
is there primarily to make sure the app stops on startup so you have time to attach the lldb debugger before the app starts.
If you don't mind attaching after startup you can remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think it makes sense to use it as a way to pause the app. 👍
If an app is crashing on launch, you will need to connect the debugger before it starts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a comment that it is optional
6c543ac
to
0bcd739
Compare
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
<DebugType>portable</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
<Optimize>false</Optimize> | ||
</PropertyGroup> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | |
<DebugType>portable</DebugType> | |
<DebugSymbols>true</DebugSymbols> | |
<Optimize>false</Optimize> | |
</PropertyGroup> |
Is this needed? It should be the default behavior
NativeAOT Sample
This is the sample for using NativeAOT with .net Android
Debugging
In order to debug we need to use
lldb
. The following commands will install thelldb-server
for the application.The above commands are setup in a MSBuild Target which will run after the
Install
target has run. So thereis no need to do this manually if you are using
NativeAOT.csproj
.Once
lldb-server
is up and running, you will want to run up the app using the followingThe
-D
is important as it stops the app from running until the java debugger is attached.Now that the app is running we need to get the process id.
Grab the process id, then start VSCode
Debug NativeAOT
Task. And drop in the process id.Set your breakpoints as usual in the VSCode.
if you are using lldb from the command line use the following
Next you need to attach the java debugger to clear the dialog which is currently blocking the
application execution.
You will want to type
quit
to exit thejdb
terminal once it has connected.