Closed m93a closed 4 months ago
You have to pass the path to the csproj
for the _Gdb
target to work. This is the same for all the custom Xamarin.Android targets. When you just call msbuild
it will default to building the solution and MSBuild will not find the required targets.
So try this instead.
msbuild monodroid-samples/Button/DroidButton.csproj /t:_Gdb
or
msbuild DroidButton.csproj /t:_Gdb
of you are already in the monodroid-samples/Button
directory.
It looks like the _Gdb
target is in Xamarin.Android.Common.Debugging.targets
and that is not in the OSS core of xamarin-android.
@dellis1972 is there a reason this part couldn't be open sourced? There are some other "private-ish" targets like _Run
being used, but I don't think I see anything that has to be proprietary.
@jonathanpeppers generally our debugging support is close source. The _Gdb target itself depends on a bunch of things that depend on AndroidTools which is not open sourced.
I think @jonathanpeppers was getting at this, but just to make sure we're all clear, this report is about using an open source build that the reporter built and ran locally on:
elementaryOS 5.0 (based on Ubuntu 18.04.2)
So invoking msbuild
on the .csproj file won't change the error message. If m39a runs the following command:
msbuild monodroid-samples/Button/DroidButton.csproj /t:_Gdb
They will still see the same error:
error MSB4057: The target "_Gdb" does not exist in the project.
Because the open source build does not include the _Gdb
target.
That said, the fact that the open source build does not include the _Gdb
target is arguably a good thing. After working on the related, though primarily contributor-focused, Development tips and native debugging document earlier this year, I had the understanding that the _Gdb
target was no longer maintained and should likely be removed in a future round of code cleanup.
In particular, https://github.com/xamarin/xamarin-android/commit/d80b485bcbc6dff29dbd79aa2423f283dd62c60a removed the gdbserver
binary from debug APKs and removed support for launching the gdbserver
binary via the libmono-android runtime.
So the _Gdb
target doesn't work in commercial builds on macOS or Windows right now either.
It is still possible to debug Xamarin.Android apps from the command line using GDB, but since most Xamarin.Android users are on Windows or macOS, my default recommendation for them would be to use the integrated GDB support in Visual Studio on Windows or the mono/lldb-binaries on macOS instead.
For this particular GitHub issue about Linux, attaching GDB on the command line would be a fine approach. Note that that contributor-focused article only mentions libmonosgen-2.0, but you would need to copy any native unmanaged library you wanted to debug to the local gdb-symbols directory.
Another approach that might be more convenient would be to use Android Studio. I'm fairly certain the Attaching LLDB using Android Studio steps also work on Linux. Those steps are nice because LLDB takes care of setting up all the native unmanaged libraries automatically (at the cost of having to wait for it to download them from the device on the first debugging session) and you get a graphical UI for stepping through the native unmanaged source files.
Thank you all for your responses, I will give LLDB a try! However, since I came here from the specs (I've never even used GDB before), I think that it's advisable to add some deprecation warning there. Maybe even point them to the LLDB tutorial. Than I'll happilly close the issue :)
Closing, as this seems expected with an OSS build.
Steps to Reproduce
Expected Behavior
An app connected to
gdb
should start up in the emulator, like described in the docs.Actual Behavior
Build fails, saying that the target
_Gdb
doesn't exist.Version Information
make jenkins
, details here)Log File
N/A