Skip to content
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

Wait for debugger #1559

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions document-portal/document-portal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,21 @@ main (int argc,
g_autoptr(GOptionContext) context = NULL;
GDBusMethodInvocation *invocation;

if (g_getenv ("XDG_DOCUMENT_PORTAL_WAIT_FOR_DEBUGGER") != NULL)
{
g_printerr ("document portal (PID %d) is waiting for a debugger. "
"Use `gdb -p %d` to connect. \n",
getpid (), getpid ());

if (raise (SIGSTOP) == -1)
{
g_printerr ("Failed waiting for debugger\n");
exit (1);
}

raise (SIGCONT);
}

g_log_writer_default_set_use_stderr (TRUE);

setlocale (LC_ALL, "");
Expand Down
15 changes: 15 additions & 0 deletions document-portal/permission-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ main (int argc,
GOptionContext *context;
g_autoptr(GError) error = NULL;

if (g_getenv ("XDG_PERMISSION_STORE_WAIT_FOR_DEBUGGER") != NULL)
{
g_printerr ("\npermission store (PID %d) is waiting for a debugger. "
"Use `gdb -p %d` to connect. \n",
getpid (), getpid ());

if (raise (SIGSTOP) == -1)
{
g_printerr ("Failed waiting for debugger\n");
exit (1);
}

raise (SIGCONT);
}

g_log_writer_default_set_use_stderr (TRUE);

setlocale (LC_ALL, "");
Expand Down
15 changes: 15 additions & 0 deletions src/xdg-desktop-portal.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,21 @@ main (int argc, char *argv[])
g_autoptr(GSource) signal_handler_source = NULL;
g_autoptr(GOptionContext) context = NULL;

if (g_getenv ("XDG_DESKTOP_PORTAL_WAIT_FOR_DEBUGGER") != NULL)
{
g_printerr ("\ndesktop portal (PID %d) is waiting for a debugger. "
"Use `gdb -p %d` to connect. \n",
getpid (), getpid ());

if (raise (SIGSTOP) == -1)
{
g_printerr ("Failed waiting for debugger\n");
exit (1);
}

raise (SIGCONT);
}

setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
Expand Down
9 changes: 9 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ but should not normally be set on production systems:
* `XDP_VALIDATE_SOUND_INSECURE`: Same as `XDP_VALIDATE_ICON_INSECURE`,
but for sounds

* `XDG_DESKTOP_PORTAL_WAIT_FOR_DEBUGGER`: Makes xdg-desktop-portal wait for
a debugger to attach by raising SIGSTOP

* `XDG_DOCUMENT_PORTAL_WAIT_FOR_DEBUGGER`: Makes xdg-document-portal wait
for a debugger to attach by raising SIGSTOP

* `XDG_PERMISSION_STORE_WAIT_FOR_DEBUGGER`: Makes xdg-permission-store wait
for a debugger to attach by raising SIGSTOP

### Used automatically

These environment variables are set automatically and shouldn't need to be
Expand Down
Loading