-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Generator] Allow to have a way to attach to the generator. (#19565)
As soon as we moved to have a build of the generator that used dotnet we opened the door to a number of developer life improvements. The very first one of those is the poissibility to attach the dotnet debugger to the bgen process and that way be able to debug. In order to do that, this PR has changed two small things: 1. Added code in the main method of the generator that will block the tool until a debugger is attached. 2. Changed the csproj to add the previously mentioned code only when the enviroment variable XAMMACIOS_DEBUGGER is set. This way the code does not reach our customers. A README has been added explaining how to debug the processes via Visual Studio. Any other IDE that support the dotnet debugger can be used this way. <img width="1075" alt="Screenshot 2023-12-03 at 19 10 18" src="https://github.com/xamarin/xamarin-macios/assets/2190086/dbafc570-7c43-419f-977e-ace66f5561ac"> --------- Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
- Loading branch information
1 parent
d4c6cfc
commit 1173c01
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## Debugging | ||
|
||
|
||
One of the main problems when adding changes to the generator was that before the generator was moved to dotnet, we could not attach the dotnet debugger to it. | ||
Things have changed, and now if you want to debug the generator, you can do it with Visual Studio. To do so, you need to follow these steps: | ||
|
||
1. Export the environment variable `XAMMACIOS_DEBUGGER` with any value. For example: | ||
|
||
```bash | ||
export XAMMACIOS_DEBUGGER=1 | ||
``` | ||
|
||
2. Open the src/src/bgen.csproj solution with Visual Studio. | ||
3. Add a break point at the end of the `Main` method in the BindingTouch.cs file. | ||
4. Rebuild the generator. | ||
|
||
|
||
Now, when the project is rebuilt you will have to pay attention to the output of the build. You will see something like this: | ||
|
||
```bash | ||
Waiting for debugger to attach: (55644) dotnet | ||
Waiting for debugger to attach: (55646) dotnet | ||
``` | ||
|
||
These messages are telling you that the generator is waiting for the debugger to be attach to the process. To do so, you need to go to the Debug menu and select | ||
the Attach to Process option. In the dialog that will appear, you will need to select the dotnet process that is running the generator. In this case, the process | ||
is the one with the PID 55644. Once you have selected the process, you can click on the Attach button. | ||
|
||
Because the generator is called several times, one per platform, you can attach to the different processes in case the issue you are trying to debug | ||
is platform specific. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters