Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

saving execution logs

Name: Anonymous 2012-03-08 3:18

hello prog,

Do popular available debuggers like gdb support things like recording the complete execution of a program and writing it to a file for later reference? Or possibly only recording the state of the stack for certain groups of functions in important files? In the past, I've achieved this with macros for logging and placing them in the code, but it would be nice to be able to do it without having to modify the source code, especially when the number of functions selected for logging is large. Thanks /b/ros.

Name: Anonymous 2012-03-08 3:58

Read the manual. Bye.

Name: Anonymous 2012-03-08 4:00

>>1
/b/ros

/polecat kebabs/

Name: Anonymous 2012-03-08 4:45

>>2

the manual is shit.

Name: Anonymous 2012-03-09 2:35

so this seems to work:


$ cat main.c
#include <stdio.h>

int g(int n) {
  return n + 1;
}

int f(int n) {
  return n + 2;
}

int main(int argc, char** argv) {
  printf("f(2)=%d\n", f(2));
  printf("g(2)=%d\n", g(2));
  return 0;
}
$ gcc -c -g main.c -o main.o
$ gcc -g -o main main.o
$ main
f(2)=4
g(2)=3
$ gdb main
GNU gdb (GDB) 7.0-ubuntu
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>;...
Reading symbols from /home/ryan/C/nm/lang/tests/ran/main...done.
(gdb) grebreak f
Breakpoint 1 at 0x80483f2: file main.c, line 8.
(gdb) commands
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>cont
>end
(gdb) break g
Breakpoint 2 at 0x80483e7: file main.c, line 4.
(gdb) commands
Type commands for when breakpoint 2 is hit, one per line.
End with a line saying just "end".
>cont
>end
(gdb) runset logging on outlog.tt
Copying output to log.tt.
(gdb) run
Starting program: /home/ryan/C/nm/lang/tests/ran/main

Breakpoint 1, f (n=2) at main.c:8
8      return n + 2;
f(2)=4

Breakpoint 2, g (n=2) at main.c:4
4      return n + 1;
g(2)=3

Program exited normally.
(gdb) quit
$ cat log.tt
Starting program: /home/ryan/C/nm/lang/tests/ran/main

Breakpoint 1, f (n=2) at main.c:8
8      return n + 2;

Breakpoint 2, g (n=2) at main.c:4
4      return n + 1;

Program exited normally.
quit
$


I could write a script that reads a file containing a list of function names to include in the trace, and then generate the input I would normally type into gdb, and have the output of gdb saved to a log. But this seems much more limited than log files. So I will continue using logging for correctness, and debuggers for crashes.

Name: Anonymous 2012-03-09 11:31

gdb also has record, which saves everything so you may step backwards.

Name: Anonymous 2012-03-09 11:48

>>6
yes but will it blend?

Name: Anonymous 2012-03-09 11:57

>>7
It does everything OP asked for, it saves the complete state of the program at every step, and you can save it in a file for later viewing.

Don't change these.
Name: Email:
Entire Thread Thread List