Visual Studio Voodoo Debugger

Well, maybe this is not so surprising, given that I really do not understand how the debugger works in the first place, not to mention editing and continuing, which is absolutely amazing.

But I was wondering if anyone knows what the debugger does with variable declarations in this scenario. I can debug my code, move the execution line forward - past the initial declaration and assignment of variables, and the code still works fine. If it is a value type, it will have a default value for the type ref, null.

So, if I create a function that uses a variable before it is declared, it will not compile, but if I use a debugger to run it this way, it will work without errors. Why is this? And is it due to the fact that you cannot put a breakpoint in the declaration?

+3
source share
3 answers

Yes, these declarations are more structural. They are part of the locales on the stack that are allocated when the method is called. You cannot break them, because they really do not occur where you write them - these are not instructions.

, , - , . .

+4

:

.NET Common Language Runtime (CLR) . 0, .

, , , ( , , ) , , ​​.

+1

, , , , , , .

. : ", " wombatCount ": , 0x1234 , wombatCount". , , . *

, , , . wombatCount 0x1234, , . , , .

# , , , . , , , , "", . , , , . , , " " - , .

(* To be more technically correct, I believe that .Net tags are bound only at compile time with a list of pointers that will reserve memory at runtime, but the data bytes are not allocated until you use them. The difference is internal and not very important for your understanding, an important conclusion is that the declarative operator declares the label in advance, at compile time.)

+1
source

Source: https://habr.com/ru/post/1745484/


All Articles