Skip to content

Add a helper function to start GDB that was already attached to the current process #1915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@

#define HCAST(type, handle) ((type)(intptr_t)handle)

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;
Expand Down
10 changes: 10 additions & 0 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,16 @@ static int mingw_main(c,v)

#endif

/*
* 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
*/
Expand Down