This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] redebug - error reporting.


Hi, when I thougth about reporting of undefined and best was to run
process in gdb with set breakpoints when undefined behaviour is
detected.

Ideally we would run this in reversible debugger which could answer
queries like 'rewind to time just before this variable was freed' for
use after free/double free.

We can almost support queries like this with following techique. It
requires that user has program with deterministic inputs. 
We add a counter in various points of execution which will be passed as
ordinary variable.
When a error happens we print a watch command that user will pass back
to gdb. User then runs program again which causes gdb to stop when
original countpoint was assigned.

This functionality could be wrapped in gdb scripts, for now a output
could look like 

free: double free, to rewind to first free use watchpoint:
watch *0x123432 == 1354332

I do not know yet how best handle multithreaded environment, If address
of thread-local variable stays same for multiple runs of program it
would do a job.

Comments?

A simple implementation what I described is following. A determinism
requirement could be relaxed by making separate counter for each caller
which would make implementation more technical.

#include <stdint.h>
struct redebug {
  uint64_t __addr;
  uint64_t __cnt;
};


#define redebug_countpoint() ({ \
  static __thread uint64_t __count; \
  __count++; \
  struct redebug __r; \
  __r.__addr = (uint64_t) (&__count); \
  __r.__cnt = __count; \
  __r; \
})

#define redebug_print(fd, countpoint) fprintf (fd, "'watch *%lx == %lx'\n" ,\
                                               countpoint.__addr, \
                                               countpoint.__cnt)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]