GDB [[Inferior 1 (Prozess-2710) beendet mit code 06]] seltsame Ausgabe

Ich versuche zu beurteilen, die Leistung von einem C-Programm, also lief ich den debugger.

Dies ist das Programm:

#define swap(a, b) temp=a; a=b; b=temp;
#include <stdio.h>

main()
{
        int i, j, temp;
    i = 5;
    j = 10;
    temp = 0;
    if(i > j)
        swap(i, j);
    printf("%d %d %d",  i, j, temp);
}

Den Ausgabe dieses Programm 10 0 0. Ich kann nicht sehen, wie es möglich.

Lege ich Pausen auf den Linien 6, 7, 8, 9, 10, GDB. Dies ist, was ich bekomme -:

(gdb) run
Starting program: /home/pritishc/Documents/a.out 

Breakpoint 1, main () at ProbleminC.c:7

7   i = 5;

(gdb) print i

$1 = 0

(gdb) print j

$2 = 0

(gdb) continue

Continuing.

Breakpoint 3, main () at ProbleminC.c:8

8   j = 10;

(gdb) print i

$3 = 5

(gdb) print j

$4 = 0

(gdb) print temp

$5 = 32767

(gdb) continue

Continuing.

Breakpoint 4, main () at ProbleminC.c:9

9   temp = 0;

(gdb) print i

$6 = 5

(gdb) print j

$7 = 10

(gdb) print temp

$8 = 32767

(gdb) c

Continuing.

Breakpoint 5, main () at ProbleminC.c:10

10  if(i > j)

(gdb) print i

$9 = 5

(gdb) print j

$10 = 10

(gdb) print temp

$11 = 0

(gdb) c

Continuing.

10 0 0[Inferior 1 (process 2710) exited with code 06]

(gdb) print i

No symbol "i" in current context.

(gdb)

Was genau bedeutet das? Und warum auf der Erde ist er mir solche Ausgabe?

InformationsquelleAutor PritishC | 2014-01-14

Schreibe einen Kommentar