How to insert breakpoint using symbols include “&l

2019-07-31 01:51发布

问题:

I want to insert a breakpoint in windbg, using symbols named "TSmartPointer::TSmartPointer".

bp TSmartPointer<class CDataMemberMgr>::TSmartPointer<class CDataMemberMgr>

WinDbg noticed me that no symbols were found.

I use command x to search symbol, but also no symbols are found:

x TSmartPointer<class CDataMemberMgr>::TSmartPointer<class CDataMemberMgr>

When I replace "<" and ">" to "*", WinDbg can find symbols:

x TSmartPointer*class CDataMemberMgr*::TSmartPointer*class CDataMemberMgr*

Am I wrong? How can I insert this breakpoint?

回答1:

I could not find this in WinDbg's internal help, but in Microsoft documentation, which makes me wonder a bit about the spaces as well

To set a breakpoint on complicated functions, including functions that contain spaces, as well as a member of a C++ public class, enclose the expression in parentheses. For example, use bp (??MyPublic) or bp (operator new).

Furthermore, it explicitly talks about angle brackets:

You must start with the three symbols @!" and end with a quotation mark ("). Without this syntax, you cannot use spaces, angle brackets (<, >), or other special characters in symbol names in the MASM evaluator.

(emphasis mine)

So, in your case, the following should work:

bp @!"TSmartPointer<class CDataMemberMgr>::TSmartPointer<class CDataMemberMgr>"

The quotation marks should care about the spaces as well.

And to make a comment of @Kurt Hutchinson persistent:

For template classes, it's important to use the exact spacing and angle bracket placement that Windbg wants. Sometimes there will be an extra space in there that is significant. You can tell what it should be by doing a symbol lookup first like x MSHTML!TSmartPointer*CDataMemberMgr*. Windbg should do a wildcard match and print out a bunch of symbol names. Then you should copy and paste the correct name from that list, using the @!"..." quoting. Don't try to retype the symbol name yourself because spaces matter and if you miss one, Windbg won't match it correctly.



标签: windbg