5

Could somebody tell me where would the execution log be stored when using the process record/replay feature in gdb?

Thanks Raj

Update

#include <stdio.h>

int main (int argc, char const *argv[])
{
    printf("Hello World\n");
    printf("How are you?\n");
    char *c = NULL;
    printf("%c\n", *c);
    return 0;
}      

The code above seg faults when I dereference c. I want to use this example to figure out how I can use reverse-next/reverse-continue to go back after a segfault. I am able to do reverse-next and reach the first printf statement at which I put a break point when recording the execution. After this, when I try the "next" command in gdb, I see that the cursor moves through the printf statements but I don't see any output printed on the terminal. In summary, I want to know if the record/replay feature can be used to go through the execution history even after a segfault?

Raj
  • 708
  • 3
  • 10
  • 21

1 Answers1

8

I thought you had to manually specify that with

record save filename

The default filename is gdb_record.process_id, where process_id is the process ID of the debugged process. That means, if you don't specify it, look in the CWD of the debugger

Update

With respect to your extra question on insn-number-max:

info record 

Show various statistics about the state of process record and its in-memory execution log buffer, including:

  • Whether in record mode or replay mode.
  • Lowest recorded instruction number (counting from when the current execution log started recording instructions).
  • Highest recorded instruction number.
  • Current instruction about to be replayed (if in replay mode).
  • Number of instructions contained in the execution log.
  • Maximum number of instructions that may be contained in the execution log.

I'm not to sure but this might indicate that the whole is kept in memory after all. Of course, a 64bit system and plenty of swap (and ulimit unlimited) will make this a 'virtual' limitation

sehe
  • 374,641
  • 47
  • 450
  • 633
  • Thanks for your reply. Could you tell me where is the execution buffer stored(RAM or disk) while the execution is still being recorded. I want to know this as I want to set the insn-number-max to zero (to set the record size to unlimited). – Raj Apr 02 '11 at 17:10
  • I'm not to sure what you mean. You can simply do (gdb) `set record insn-number-max 0`, isn't it? If you're worried about memory usage, I really really expect the records to be in memory mapped files and only the actively used pages locked. I've got no proof of that, but I'm sure you will find out :) – sehe Apr 02 '11 at 19:25
  • Thanks for your reply. One last question. Please see the code in my updated question. In summary, I want to know if the record/replay feature can be used to go through the execution history even after a segfault? – Raj Apr 03 '11 at 02:18
  • Of course you can ([see here e.g.](http://www.jayconrod.com/cgi/view_post.py?28)) – sehe Apr 03 '11 at 10:28
  • Yes. I already saw that. Could you tell me why I am not able to see the output of the printf statements when using next? – Raj Apr 03 '11 at 21:39
  • 1
    Yes. gdb restores program state. Program state does not include external peripherals (like the screen). Imagine this: if your program just sent an email, would reverse-continue make the email be unsent? (In other words, read the manual carefully and adjust your expectations!) – sehe Apr 03 '11 at 21:42