loop
loop

Reputation: 3590

Debug a program with equal memory address locations over multiple runs?

I have a program that I'm debugging in Visual Studio 2010. I have a reproducible error that occurs in the program and I am printing some diagnostic information. The error leaves the program in a bad state so I have to constantly restart the program. Each time I run the program the addresses for my structs are different. There are many of them and it would be much easier to debug if the addresses would stay the same each time I run the program.

The addresses look almost similar but are different. For example one struct has an address of 0x003F5540 one time, 0x003E5540 the next time, 0x00605540 and 0x004F5540 the next time.

The code executes exactly the same every time so I don't know why I see the slightly different addresses. I have turned off ASLR and DEP. What can I do to get the same addresses every time I run the program?

Thanks

Edit- It may not be possible to disable heap and stack randomization:
1st call to "new" always returns different addresses. How do I get it to return the same address?

Upvotes: 1

Views: 408

Answers (1)

Blindy
Blindy

Reputation: 67388

There's no "may" about it, address randomization has been the core of every OS since 16 bit protected mode ones. Otherwise you couldn't run the same process twice. Or two processes that chose overlapping virtual base addresses.

Use symbol names instead of pointer values, that's what debug symbols are for!

Upvotes: 1

Related Questions