summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/util/util.c14
-rw-r--r--lib/util/util.h4
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_ */