diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-03-17 15:02:25 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-03-17 15:02:25 -0700 |
commit | 32fc2c6dd64a9feb5872b0e5d45ed13fa21ef9d5 (patch) | |
tree | 1222aac899858dafa4aede94f417d1dbe0171254 /compat | |
parent | Merge branch 'js/test-unc-fetch' into maint (diff) | |
parent | mingw: add a helper function to attach GDB to the current process (diff) | |
download | tgif-32fc2c6dd64a9feb5872b0e5d45ed13fa21ef9d5.tar.xz |
Merge branch 'js/mingw-open-in-gdb' into maint
Dev support.
* js/mingw-open-in-gdb:
mingw: add a helper function to attach GDB to the current process
Diffstat (limited to 'compat')
-rw-r--r-- | compat/mingw.c | 13 | ||||
-rw-r--r-- | compat/mingw.h | 10 |
2 files changed, 23 insertions, 0 deletions
diff --git a/compat/mingw.c b/compat/mingw.c index 402c1ad91c..b5230149db 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -13,6 +13,19 @@ static const int delay[] = { 0, 1, 10, 20, 40 }; +void open_in_gdb(void) +{ + static struct child_process cp = CHILD_PROCESS_INIT; + extern char *_pgmptr; + + argv_array_pushl(&cp.args, "mintty", "gdb", NULL); + argv_array_pushf(&cp.args, "--pid=%d", getpid()); + cp.clean_on_exit = 1; + if (start_command(&cp) < 0) + die_errno("Could not start gdb"); + sleep(1); +} + int err_win_to_posix(DWORD winerr) { int error = ENOSYS; diff --git a/compat/mingw.h b/compat/mingw.h index 714bc1d591..e6fe810ba9 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -599,6 +599,16 @@ int wmain(int argc, const wchar_t **w_argv); int main(int argc, const char **argv); /* + * For debugging: if a problem occurs, say, in a Git process that is spawned + * from another Git process which in turn is spawned from yet another Git + * process, it can be quite daunting to figure out what is going on. + * + * Call this function to open a new MinTTY (this assumes you are in Git for + * Windows' SDK) with a GDB that attaches to the current process right away. + */ +extern void open_in_gdb(void); + +/* * Used by Pthread API implementation for Windows */ int err_win_to_posix(DWORD winerr); |