April 18th, 2014

How do I set a breakpoint on a function whose name contains spaces or other special characters?

If you use one of the command line debuggers based on the Debugger Engine, you can set a breakpoint on a function whose name contains spaces or other special characters by quoting the symbol name. The trick here is that you do not quote the entire string; you quote only the symbol name.

0:001> bu @!"CSimpleArray<wchar_t *>::CSimpleArray<wchar_t *>"

Note that the quotation marks do not go around the @! part. They go only around the symbol. (Otherwise, the debugger thinks you are setting a breakpoint action.)

Another trick for setting breakpoints is using tab autocompletion for symbols. If you type bp contoso!*Widget* and then hit Tab repeatedly, you will cycle through all the matches. (It takes a few seconds to build the list of matches, so be patient the first time you hit Tab.)

Personally, I use the x command to print out all the matches, and then cherry-pick the one I want.

0:001> x contoso!*Widget*
00af114c contoso!CreateWidget
009fe863 contoso!DestroyWidget
00a2e161 contoso!MakeWidgetReadOnly
00a93168 ...
0:001> bp 00a2e161     set breakpoint on MakeWidgetReadOnly
Topics
Other

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.