# reverse debugging with gdb



## SIFE (Jan 26, 2013)

Hello,
I installed GDB 7.5.1 from ports, when I start debugging and executing record pragma, I get this message:

```
GNU gdb (GDB) 7.5.1 [GDB v7.5.1 for FreeBSD]
Copyright (C) 2012 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 "x86_64-portbld-freebsd8.1".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/XXXXXXX/Desktop/om/o-mp10...done.

(gdb) record
Process record: the current architecture doesn't support record function.
```
Does reverse debugging for FreeBSD not supported yet, or this is just a bug.


----------



## cpm@ (Jan 27, 2013)

To see if a target supports reverse execution, try: 

[CMD="(gdb)"]start[/CMD]

[CMD="(gdb)"]-gdb-set exec-direction reverse[/CMD]

[CMD="(gdb)"]show exec-direction[/CMD]

If the 'show' command shows "Reverse", that the target supports reverse execution. 

[CMD="(gdb)"]-gdb-set exec-direction forward[/CMD]

You should notice a bug if you use '-gdb-show' instead of 'show', and see if it actually reports "Reverse".  So use 'show'.

Read ProcessRecord/Tutorial.


----------



## SIFE (Jan 27, 2013)

```
GNU gdb (GDB) 7.5.1 [GDB v7.5.1 for FreeBSD]
Copyright (C) 2012 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 "x86_64-portbld-freebsd8.1".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/XXXXXXX/Desktop/om/o-mp11...done.
(gdb) start
Temporary breakpoint 1 at 0x400719: file o-mp11.c, line 46.
Starting program: /home/XXXXXXX/Desktop/om/o-mp11 

Temporary breakpoint 1, main (argc=1, argv=0x7fffffffe888) at o-mp11.c:46
46	    machines m[3] = {0};
(gdb) -gdb-set exec-direction reverse
Undefined command: "-gdb-set".  Try "help".
(gdb) show exec-direction
Forward. // Does not return Reverse, what is that mean?
(gdb) -gdb-set exec-direction forward // Doesn't work
Undefined command: "-gdb-set".  Try "help".
(gdb) gdb-set exec-direction forward // Doesn't work
Undefined command: "gdb-set".  Try "help".
(gdb) record
Process record: the current architecture doesn't support record function.
(gdb)
```
Does it work with you? What is the version of kernel you using and GDB?


----------



## cpm@ (Jan 27, 2013)

SIFE said:
			
		

> Does it work with you? What is the version of kernel you using and GDB?



The kernel has nothing to do with it. GDB added support for reverse debugging in version 7.0


```
(gdb) -gdb-set exec-direction reverse
Undefined command: "-gdb-set".  Try "help".
```

The synopsis '-gdb-set' corresponding GDB command is `set'. The '-gdb-set' command, set an internal GDB variable. Type instead:

[CMD="(gdb)"]set exec-direction reverse[/CMD]


----------



## SIFE (Jan 30, 2013)

```
(gdb)  set exec-direction reverse
Target does not support this operation.
```


----------



## cpm@ (Jan 30, 2013)

Yep, this note can help after I check infrun.c which contains GDB's runtime state machine used for implementing operations. Is defined in infrun.c:6991:7007 @@ (set_exec_direction_func): Error out if target does not support reverse execution.

```
set_exec_direction_func (char *args, int from_tty,
               struct cmd_list_element *cmd)
  {
    if (target_can_execute_reverse)
      {
        if (!strcmp (exec_direction, exec_forward))
      execution_direction = EXEC_FORWARD;
        else if (!strcmp (exec_direction, exec_reverse))
      execution_direction = EXEC_REVERSE;
      }
    else
      {
        exec_direction = exec_forward;
        error (_("[B]Target does not support this operation.[/B]"));
      }
  }
```

See http://sourceware.org/ml/gdb/2010-08/msg00173.html. Please, submit a PR to GDB mailing list to request help.


----------

