Printing the expression result in hexadecimal format using visual studio's trace points - visual-studio

Does anybody know, whether it's possible to output the values in a hexadecimal via the visual studio's trace points?
Thanks!

I have recently found out, how this can be done. Visual studio provides a way to specify the format we want to see the expression in the watch/immediate windows. You can do the following:
foo, x
This will display the foo variable in the hexadecimal format regardless of whether the hex or dec displayed is globally enabled in VS. You can also specify lots of other display formats. The full list can be found there http://msdn.microsoft.com/en-us/library/75w45ekt.aspx.
This feature also works with trace points, which is very useful when you want the values to appear in hexadecimal format in output window.
{bar,x}

Related

Can there be a difference between Column number and Character number in Visual Studio 2019?

Visual Studio 2019 (and probably older versions) show you the Column number and Character number of the current position of your cursor. As you can see, these are showing the same number.
I was wondering if these can be different numbers, and if so what would cause them to be different (maybe there are characters that take up more or less than 1 space).
Yes - the values can be different. For example, when you have tab characters in your file (frequently used for indenting code). See below:

Visual Studio Hexadecimal Display Uppercase

I work directly with binaries files, doing a lot of reverse engineering and inserting security patches to bypass some things.
Anyways this means I'm constantly starring at hexadecimal, and I have my hexadecimal display enabled in Visual Studio, but the one thing that my mind has a hard time with is all other hex editors put their alpha-numeric numbers (0xA-0xF) in uppercase, Visual Studio is lower case. I've spent some time looking over all the options and references but couldn't find anything. Anyone know of an option to change this to uppercase?
I'm talking the debugging hexadecimal display for example I want this to be in uppercase:

MSVC Autoexp.dat tokens explanation

In Visual Studio 2010, there is a little bit of explanation at the beginning of autoexp.dat on how to define rules. However, this explanation is quite limited and I haven't come across any other document. Appreciate your help in understanding a few tokens.
Here is a rule I copied from somewhere. It works for my needs.
MyString{
preview ([$e.data,su])
stringview ([$e.data,sub])
}
Q1. What is the difference between preview and stringview? Do I really need stringview.
Q2. Why does stringview use "sub" and not "su?"
Q3. What does a hash (#) do on an expression? What is the difference between the following two lines?
preview ([$e.data,su])
preview #([$e.data,su])
preview is that you see in Debuger's watch window, if you define stringview it will add a small icon (looking glass) witch calls a Text Visuzlisers. (read StringView)
Format Specifiers in C++
I think this is some syntax requirements like tokens #tree #list etc

How to make Intellisense in Visual Studio 2012 not to substitute text right to the cursor?

While programming I often realize that I need to add something before already typed code. For example I type the name of the variable:
input[0]
and then I realize that my array is of type string and I need to convert it. So, I move to the beginning of the word (with Ctrl-Left Arrow) and start typing
Convert.To|input[0]
with pipe used to show the position of my cursor. I get some suggestions from Intellisense, including the ToInt32() method I am looking for. But as long as I confirm this suggestion with Tab or Space, I get the following:
Convert.ToInt32(|)[0]
So, the text from the cursor position to the end of the word is substituted with suggestion, and this is definitely not what I want.
This problem is not specific for VS 2012 and might be due to some extensions I have installed, but my attempt to pursue its origin did not yield anything. I have following extensions installed: ReSharper, PowerCommands, Productivity Power Tools.
If you are entering an unrelated expression before an identifier, add a space before you start typing the new expression. This will prevent the completion from replacing the existing identifier.
For example, if | marks the caret, the following scenario would avoid the problem you are facing.
Convert.To| input
This code completion feature is designed to prevent the insertion of incorrect identifiers. If Visual Studio behaved like some other IDEs I know of, using the code completion feature in your original example would result in the insertion of ToInt32input, which would never be valid.
If you are interested in additional thoughts regarding this feature in general, I have described this as the Extend (default for Visual Studio) and No-extend (default for NetBeans, Eclipse, and others) modes in my blog article Code Completion filtering, selection, and replacement algorithms.
A two years later answer. But it might still be useful for some.
What helped for me in VS2015 (which might also work in VS2012) is to add the a space character to the list of 'Member List Commit Characters' in the Intellisense settings.
After this the characters after the cursor are not removed by an auto-completion.

Display strings with embedded nulls in VS2010 debugger visualizer

In Visual Studio 2010, I am trying to have strings (char* and wchar_t*) display with embedded nulls in the various native C++ Debugger Visualizer components, such as the data tip area (Watch window, preview) and expanded area accessed by the magnifying glass (stringview). For example, I want to display a BSTR (embedded in an ATL::CComBSTR) with all of its content, even if null characters are in the string. By default, setting a pointer to ,s8, ,s, or ,su will treat the string as null-terminated, which is not the desired behavior. This question specifically applies to VS2010, not 2012, 2008, or prior versions.
Any clever ideas?
Any clever ideas?
Assuming you know when the data changes, and you have your own structure wrapping the BSTR, you could add a second debug only vector of strings (or a single string with some separator replacing the nulls) to your structure that you keep in sync with the string containing embedded nulls, then visualize the vector instead. It's not pretty, but it allows you to debug your code.

Resources