debugging TSVN in Visual Studio 2022

39 views
Skip to first unread message

Stefan Sperling

unread,
Nov 15, 2023, 10:17:26 AM11/15/23
to tortois...@googlegroups.com
I am trying to follow the file notes/Debug-Hints.txt in order to set
breakpoints in TortoiseSVN.

I am stuck at the following step:

- Start VS.NET and load the TortoiseSVN
solution file. Set the TortoiseProc
project as "startup project".
In the properties page of the project,
add the following command line:
/command:createpatch /path:"path/to/wc"
(substitute "path/to/wc" with a path
to an existing working copy).

Which properties page is this referring to exactly?
When I right-click on TortoiseProc I see a 'Properties' item at the very bottom
of the menu. This opens a dialog called 'TortoiseProc Property Pages' which has
a nested menu of Configuration Properties: General, Advanced, Debugging, VC++
Directories, C/C++ etc. etc.
It's not immediately clear to me where to add the /command:createpatch string.

Any hints?

Regards,
Stefan

Daniel Sahlberg

unread,
Nov 15, 2023, 10:22:30 AM11/15/23
to TortoiseSVN-dev
onsdag 15 november 2023 kl. 16:17:26 UTC+1 skrev Stefan Sperling:
I am trying to follow the file notes/Debug-Hints.txt in order to set
breakpoints in TortoiseSVN.

I am stuck at the following step:

- Start VS.NET and load the TortoiseSVN
solution file. Set the TortoiseProc
project as "startup project".
In the properties page of the project,
add the following command line:
/command:createpatch /path:"path/to/wc"
(substitute "path/to/wc" with a path
to an existing working copy).

Which properties page is this referring to exactly?
When I right-click on TortoiseProc I see a 'Properties' item at the very bottom
of the menu. This opens a dialog called 'TortoiseProc Property Pages' which has
a nested menu of Configuration Properties: General, Advanced, Debugging, VC++
Directories, C/C++ etc. etc.

If I remember correctly, you should find the command line setting under Debugging. However https://stackoverflow.com/questions/4791140/how-do-i-start-a-program-with-arguments-when-debugging suggest this might be slightly different in Visual Studio 2022. Unfortunately I'm not on my Win dev machine right now so I can't provide screenshots.

/Daniel

Stefan

unread,
Nov 15, 2023, 1:45:46 PM11/15/23
to TortoiseSVN-dev
Screenshot 2023-11-15 194517.png

Stefan Sperling

unread,
Nov 16, 2023, 8:47:03 AM11/16/23
to TortoiseSVN-dev on behalf of Stefan
On Wed, Nov 15, 2023 at 10:45:46AM -0800, Stefan via TortoiseSVN-dev wrote:
> [image: Screenshot 2023-11-15 194517.png]

Thank you both, Daniel and Stefan.

I see how this works now. TortoiseProc takes an argument which specifies
a subcommand to run, which spawns a specific TSVN dialog, which can then
be debugged.
This wasn't clear from the description in debug hints. I wasn't sure what
"createpatch" was referring to. I assumed it was something related to
patching the real .dll file over the stub .dll, but this not the case.

I can now step through the debugger during operations like "command:update".
So that goal has been reached :)

Next, I need to figure out an issue where the Explorer context menu takes
a long time to appear after right-click on a working copy folder, but
comes up instantly on other folders. Any hints where a suitable breakpoint
location might be that would allow me to understand what the extra time
is being spent on? In any case, I'll keep looking.

Regards,
Stefan

Daniel Sahlberg

unread,
Nov 16, 2023, 9:21:32 AM11/16/23
to TortoiseSVN-dev
Doh. Context menu is a pain. Is it the new one (Win 11) or the classic (Win 10 and below)? Is it consistent? I have a feeling the new context menu sometimes takes forever to load (this is not only TSVN but for all programs that add their own entry); after right click there is a "Loading..." text that is replaced by "Open in Terminal", "TortoiseSVN" etc. after some delay.

Building support for the new context menu is a PITA. I assume you saw the section "digitally signing the binaries and installers". I don't have an official code signing cert and I couldn't find the tools indicated by build.txt. After some significant searching I've made the following notes to myself:

[[[
Timestamp server: http://timestamp.comodoca.com/authenticode

PS C:\Users\danie> $cert = New-SelfSignedCertificate -Subject "CN=dsahlberg" -CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -KeyAlgorithm RSA -HashAlgorithm SHA256 -Type CodeSigningCert
PS C:\Users\danie> Export-PfxCertificate -cert "Cert:\CurrentUser\My\$($cert.Thumbprint)" -FilePath c:\devel\codesigning.pfx -Password $(ConvertTo-SecureString -String "mypassword" -Force -AsPlainText)
]]]

"PS" indicates that this is run under PowerShell. I wasn't sure enough to know if it was only me or build.txt should be updated to those utilities so I left that for another day.

I think the context menu is implemented in the TortoiseShell/TortoiseStub projects and I don't think they are called by a /command: in TortoiseProc but rather loaded directly to the Explorer process as a DLL.

I'd probably start by adding some profiling to whatever Explorer calls to create the context menu (CShellExt::InsertSVNMenu?) and start from there. There is some profiling in the class ProfileTimer (in Utils\DebugOutput.h) that can probably help. I'm not so sure how easy it would be to connect to the running Explorer process but that might be possible if you can reproduce the issue.

Good luck!

Kind regards,
Daniel

Stefan

unread,
Nov 16, 2023, 1:29:32 PM11/16/23
to TortoiseSVN-dev
I wouldn't recommend debugging the shell extension part if you're not already familiar with shell extensions in general.
While it is possible to do some debugging, getting everything set up for this takes a *lot* of time, and since you're dealing with the shell any mistake can basically break your system.

What I would recommend is enabling the debug outputs the tsvn shell extension has built in:
create a registry DWORD key under SOFTWARE\TortoiseSVN named DebugOutputString, and set the value to 1.
Then restart the shell (reboot is maybe the safest and fastest way to do that).
Then you can use dbgView from sysinternals (part of microsoft now) to see all the debug output of the tsvn shell extension. That might be enough to figure out the delay you have.

Stefan Sperling

unread,
Nov 26, 2023, 6:44:48 AM11/26/23
to TortoiseSVN-dev on behalf of Stefan
On Thu, Nov 16, 2023 at 10:29:32AM -0800, Stefan via TortoiseSVN-dev wrote:
> What I would recommend is enabling the debug outputs the tsvn shell
> extension has built in:
> create a registry DWORD key under SOFTWARE\TortoiseSVN named
> DebugOutputString, and set the value to 1.
> Then restart the shell (reboot is maybe the safest and fastest way to do
> that).
> Then you can use dbgView from sysinternals (part of microsoft now) to see
> all the debug output of the tsvn shell extension. That might be enough to
> figure out the delay you have.

Thanks, I got this to work. What's great is that it even works
with an official release build.

However, nothing seems to get printed while the context menu is
being opened. I only see new lines appearing in DebugView once
I trigger an operation from the menu, such as 'Update'.

I will try to find a way to add debug output while hooks are called
by the shell during construction of the context menu.
Reply all
Reply to author
Forward
0 new messages