Skip to content

Commit 41704ca

Browse files
committed
expand reverse using rr tests
1 parent ce5dd22 commit 41704ca

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

gdb/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ OUTS := $(addsuffix $(OUT_EXT), $(basename $(INS)))
1313
INS_CPP := $(wildcard *$(IN_EXT_CPP))
1414
OUTS_CPP := $(addsuffix $(OUT_EXT), $(basename $(INS_CPP)))
1515

16-
1716
.PHONY: all clean run
1817

1918
all: $(OUTS) $(OUTS_CPP)

gdb/reverse.c

+47-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,51 @@
1+
#include <stdio.h>
12
#include <stdlib.h>
3+
#include <time.h>
4+
5+
int f() {
6+
int i;
7+
i = 0;
8+
i = 1;
9+
i = 2;
10+
return i;
11+
}
12+
13+
int where_return(int i) {
14+
if (i)
15+
return 0;
16+
else
17+
return 1;
18+
}
19+
20+
int main(void) {
21+
int i;
22+
23+
/* Variable changes. */
24+
i = 0;
25+
i = 1;
26+
i = 2;
27+
28+
/* Local call. */
29+
f();
30+
31+
/* Where it returns. */
32+
/* https://stackoverflow.com/questions/3649468/setting-breakpoint-in-gdb-where-the-function-returns */
33+
where_return(0);
34+
where_return(1);
35+
36+
/* printf. Meh. How dare they ship this crap.
37+
* Use rr instead for now.
38+
* - https://stackoverflow.com/questions/40125154/target-record-full-in-gdb-makes-n-command-fail-on-printf-with-process-recor/46113357#46113357
39+
* - https://stackoverflow.com/questions/2528918/gdb-reverse-debugging-fails-with-process-record-does-not-support-instruction-0x/46113472#46113472
40+
* - https://stackoverflow.com/questions/42451492/disable-avx-optimized-functions-in-glibc-ld-hwcap-mask-etc-ld-so-nohwcap-for/44468494#44468494
41+
* - https://stackoverflow.com/questions/43750603/gdb-reverse-debugging-avx2
42+
* */
43+
printf("i = %d\n", i);
44+
45+
/* Is randomness completely removed? */
46+
srand(time(NULL));
47+
i = rand();
48+
printf("rand() = %d\n", i);
249

3-
int main() {
4-
int i, j;
5-
i = 0;
6-
j = 0;
7-
i = 1;
8-
j = 1;
9-
i = 2;
10-
j = 2;
1150
return EXIT_SUCCESS;
1251
}

gdb/reverse.gdb

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
12
start
23
record
4+
# TODO same as target record-full ?
35

46
continue
57
reverse-continue

0 commit comments

Comments
 (0)