When to use assembly language to debug a c / C ++ program?

When to use assembly to debug a c / C ++ program?

Does this assembly help debug programs?

+3
source share
12 answers

This can be very useful in cases where you cannot (yet) reliably reproduce the error, for example, due to damage to the heap / stack. You can get one or two dump cores, quite possibly from a client. Even if your debugger is reliable, looking at the assembly, it can tell you exactly which instruction (and, therefore, what part of the memory is corrupted).

, ( ) . , / .. , , . diassembly.

/ , , . , , , , .

+5

"", C/++, , ... asm, .

ASM C... , .

x86!

+3

, . , .

C/++, C/++, .

+2

, , , C/++.

, , , . , , . -, , .

, , - . , .

Wiki .

+2

. GCC .

. GCC 2.95 3.4.3, , .

, , . , , , , 16- 32- .

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

+2

, , " ". ( , ), , , . , , , .

+1

, gcc . - "" gcc , .

/* global */
int x = 1;

void *myFunc() {
    /* do something productive */
    x = 0;
    return NULL;
} 

int main() {
    thread_create(myFunc);

    while(x) continue;

    exit(1);
}

while(x) continue; jmp 0xDEADBEEF ( 0xDEADBEEF - jmp). , x .

-.

+1

, . , , , , , .

+1

, , . , , , . - ALT-6. , .

+1

; , minidump . , , ( ).

+1

I have some benefit for my build skills looking for bugs that were caused by the new version of the compiler being used. But compiler errors are very rare, so my answer will not be for debugging.

It is interesting to see how the compiler solves the build problem from your source, but this is by no means debugging.

0
source

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


All Articles