diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-07-20 15:31:49 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-09-04 12:29:10 +1000 |
commit | b58bfb351025816b18389ac2377c429b8a777dde (patch) | |
tree | 5453e8198587591c2b9c409e63f653970c1f5162 /lib/util | |
parent | 31d3227074a63ab7f66f74eca019884bb2e236da (diff) | |
download | samba-b58bfb351025816b18389ac2377c429b8a777dde.tar.gz samba-b58bfb351025816b18389ac2377c429b8a777dde.tar.bz2 samba-b58bfb351025816b18389ac2377c429b8a777dde.zip |
util: added samba_start_debugger()
This developer function is useful for debugging unusual error
conditions
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/util.c | 14 | ||||
-rw-r--r-- | lib/util/util.h | 4 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/util/util.c b/lib/util/util.c index d645f7edc9..c0af4b0116 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -891,3 +891,17 @@ void *allocate_anonymous_shared(size_t bufsz) } +#ifdef DEVELOPER +/* used when you want a debugger started at a particular point in the + code. Mostly useful in code that runs as a child process, where + normal gdb attach is harder to organise. +*/ +void samba_start_debugger(void) +{ + char *cmd = NULL; + asprintf(&cmd, "xterm -e \"gdb --pid %u\"&", getpid()); + system(cmd); + free(cmd); + sleep(2); +} +#endif diff --git a/lib/util/util.h b/lib/util/util.h index 8383344cd5..994fad04d3 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -877,4 +877,8 @@ struct tevent_req *samba_runcmd_send(TALLOC_CTX *mem_ctx, const char * const *argv0, ...); int samba_runcmd_recv(struct tevent_req *req, int *perrno); +#ifdef DEVELOPER +void samba_start_debugger(void); +#endif + #endif /* _SAMBA_UTIL_H_ */ |