0

Is there a quicker way to copypaste C++ pointers from Visual Studio's Watch window into a conditional breakpoint?

Context: My pointer values change each time I restart my application, so I need to update the address in my conditional breakpoint.

If I have a watch for this, copypasting it gives something like this:

+ this 0x000001287234a8c0 {mTick=2994 mTime=0.00000000 ...} AnimComponent *

When I right click on this, there's a "Copy Value" option, but it copies that {} block too:

0x000001287234a8c0 {mTick=2994 mTime=0.00000000 ...}

So my current process to copy my this watch's pointer value:

  • Click on this
  • Ctrl-C
  • Edit conditional breakpoint
  • Ctrl-v, remove the {} block, and add a == after this

I'm using C++, so I can't use the "Make Object ID" feature.

idbrii
  • 10,975
  • 5
  • 66
  • 107
  • Just click on variable value in the Watch window, it will leave only `0x000001287234a8c0`, then copy it. – 273K Jun 24 '22 at 18:38
  • @273K: That sounds like something that used to work, but neither clicking nor double clicking on anything in the Value column makes it an editable number field. I'm using VS 2017. – idbrii Jun 24 '22 at 19:15
  • Left click? You used right clicks in the question. – 273K Jun 24 '22 at 19:17

1 Answers1

1

Watch Window

Use (void*)this in the watch window to prevent the {} block and make "Copy Value" copy only the number.

Keyboard Shortcut

Open Tools > Customize > Keyboard

Search for "CopyValue" and you should find DebuggerContextMenus.AutosWindow.CopyValue. Map a keyboard shortcut to it and you can copy values with only two steps: click + keyboard.

If you use Ctrl-Shift-C to copy, be sure to remove that shortcut from View.ClassView or it will interrupt your copying.

idbrii
  • 10,975
  • 5
  • 66
  • 107