diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-06-14 18:26:18 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-06-14 18:30:13 +0100 |
commit | 3c889ceed3b9a78da16ea2387f3b8029e25aa15b (patch) | |
tree | 1521fe438bba73454e32f732b74801732621eaf9 /base/memento.c | |
parent | 3bc51652cc962f0256acdf37f52d0a7d98b20ed1 (diff) | |
download | ghostpdl-3c889ceed3b9a78da16ea2387f3b8029e25aa15b.tar.gz |
Memento: Add Memento_tick()
Sometimes it can be useful to be able to run a program
repeatedly and stop it at a given place, just before a
problem occurs.
Suppose you know that the problem occurs in the 'foo'
function, but only after a number of runs.
Insert a call to Memento_tick() at the top of foo, rebuild
and run in the debugger. When the problem occurs, consult
memento.sequence to see what event number we are on;
suppose it's 1000.
Then you can rerun the debugger with breakpoints on Memento_inited
and Memento_breakpoint. When the program stops at Memento_inited,
call Memento_breakAt(1000) and continue execution. The program
will then stop in Memento_breakpoint within the Memento_tick
call just before the problem occurs, enabling you to step forward
and see what goes wrong.
Diffstat (limited to 'base/memento.c')
-rw-r--r-- | base/memento.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/base/memento.c b/base/memento.c index fd95b6ffa..de3a82134 100644 --- a/base/memento.c +++ b/base/memento.c @@ -1529,7 +1529,7 @@ static void Memento_startFailing(void) } } -static void Memento_event(void) +static int Memento_event(void) { memento.sequence++; if ((memento.sequence >= memento.paranoidAt) && (memento.paranoidAt != 0)) { @@ -1550,8 +1550,9 @@ static void Memento_event(void) if (memento.sequence == memento.breakAt) { fprintf(stderr, "Breaking at event %d\n", memento.breakAt); - Memento_breakpoint(); + return 1; } + return 0; } int Memento_breakAt(int event) @@ -1573,6 +1574,14 @@ void *Memento_label(void *ptr, const char *label) return ptr; } +void Memento_tick(void) +{ + if (!memento.inited) + Memento_init(); + + if (Memento_event()) Memento_breakpoint(); +} + int Memento_failThisEvent(void) { int failThisOne; @@ -1580,7 +1589,7 @@ int Memento_failThisEvent(void) if (!memento.inited) Memento_init(); - Memento_event(); + if (Memento_event()) Memento_breakpoint(); if ((memento.sequence >= memento.failAt) && (memento.failAt != 0)) Memento_startFailing(); @@ -1783,7 +1792,7 @@ static void do_free(void *blk, int eventType) if (!memento.inited) Memento_init(); - Memento_event(); + if (Memento_event()) Memento_breakpoint(); if (blk == NULL) return; |