-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TS-30100 add new sample project for debugging
- Loading branch information
1 parent
fe53f70
commit 927bd13
Showing
8 changed files
with
79 additions
and
32 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
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
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,13 @@ | ||
{ | ||
"profiles": { | ||
"Sample_Debugging_App": { | ||
"commandName": "Project", | ||
"environmentVariables": { | ||
"CORECLR_ENABLE_PROFILING": "1", | ||
"CORECLR_PROFILER": "{DD0A1BB6-11CE-11DD-8EE8-3F9E55D89593}", | ||
"CORECLR_PROFILER_PATH_64": "C:\\Dev\\teamscale-profiler-dotnet\\Profiler\\bin\\Debug\\Profiler64.dll" | ||
}, | ||
"nativeDebugging": true | ||
} | ||
} | ||
} |
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,23 @@ | ||
namespace SampleDebuggingApp | ||
{ | ||
/// <summary> | ||
/// Main entry of the debugging app. | ||
/// </summary> | ||
public class DebuggingApp | ||
{ | ||
public static void Main() | ||
{ | ||
Check warning on line 9 in Sample_Debugging_App/SampleDebuggingApp.cs cqse.teamscale.io / teamscale-findingsSample_Debugging_App/SampleDebuggingApp.cs#L8-L9
|
||
Console.WriteLine("Hello, World!"); | ||
while (true) | ||
{ | ||
Thread.Sleep(10000); | ||
TestMethod(); | ||
} | ||
} | ||
|
||
private static void TestMethod() | ||
{ | ||
Console.WriteLine($"TestMethod called."); | ||
} | ||
} | ||
} |
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,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
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 |
---|---|---|
@@ -1,27 +1,11 @@ | ||
# Debugging (WinDbg) | ||
|
||
The following script allows to debug the profiler with `windbg` on Windows 10 with the Windows SDK installed: | ||
|
||
SET COR_ENABLE_PROFILING=1 | ||
SET COR_PROFILER={DD0A1BB6-11CE-11DD-8EE8-3F9E55D89593} | ||
SET COR_PROFILER_PATH=E:\Profiler\bin\Debug\Profiler64.dll | ||
|
||
"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe" "E:\test-data\test-programs\GeneratedTest.exe" | ||
|
||
When `windbg` starts up, hit 'Insert and remove breakpoints' (`F9`) and add a breakpoint to | ||
|
||
bu Profiler64!CProfilerCallback::Initialize | ||
|
||
Then hit 'Go' (`F9`). | ||
The program will stop at the invocation of our initialization and open a source view showing this location. | ||
From this point you can debug with step over/into/out as usual. | ||
|
||
### Notes | ||
|
||
* `windbg` normally finds the source files automagically. | ||
If it doesn't, setting `File > Source File Path...` probably helps. | ||
* You may [set more specific breakpoints][breakpoints]. | ||
* Credits to David Broman and his blog post [explaining how to debug profilers using `windbg`][debugProfilers]. | ||
|
||
[debugProfilers]: https://blogs.msdn.microsoft.com/davbr/2007/12/11/debugging-your-profiler-i-activation/ | ||
[breakpoints]: https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/breakpoint-syntax | ||
# Debugging | ||
|
||
The `Sample Debugging App` inside this repository serves to debug the profiler. | ||
To get it going please follow these steps: | ||
* In Visual Studio, select the `Debug` solution config and `x64` as solution platform. | ||
* Build the profiler. | ||
* In the Sample Debugging App properties go to the `Debug` section and select `Open debug launch settings UI`. | ||
* Change `CORECLR_PROFILER_PATH_64` to the path of your `Profiler64.dll`. This path needs to be absolute and should look similar to `C:\\Dev\\teamscale-profiler-dotnet\\Profiler\\bin\\Debug\\Profiler64.dll`. | ||
* Start the Sample Debugging App via Visual Studio. | ||
|
||
Your breakpoints in the profiler should now be working correctly and help you with debugging. |