diff options
author | Justus Winter <justus@gnupg.org> | 2017-06-19 21:20:57 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2017-08-05 18:42:22 +0200 |
commit | 835b293d35a209d38047126443d41fa7090daa4c (patch) | |
tree | 5bf956895e6030f91cd618fb191b2151f6d25423 /proc | |
parent | dc0b5a43224999223a246870912b0f292b1980e9 (diff) | |
download | hurd-835b293d35a209d38047126443d41fa7090daa4c.tar.gz hurd-835b293d35a209d38047126443d41fa7090daa4c.tar.bz2 hurd-835b293d35a209d38047126443d41fa7090daa4c.zip |
Use our own variant of 'assert' and 'assert_perror'.
Our variants print stack traces on failures. This will make locating
errors much easier.
Diffstat (limited to 'proc')
-rw-r--r-- | proc/host.c | 16 | ||||
-rw-r--r-- | proc/info.c | 8 | ||||
-rw-r--r-- | proc/main.c | 10 | ||||
-rw-r--r-- | proc/mgt.c | 20 | ||||
-rw-r--r-- | proc/msg.c | 2 | ||||
-rw-r--r-- | proc/pgrp.c | 4 | ||||
-rw-r--r-- | proc/stubs.c | 6 | ||||
-rw-r--r-- | proc/wait.c | 3 |
8 files changed, 35 insertions, 34 deletions
diff --git a/proc/host.c b/proc/host.c index c68ab8ae..25066888 100644 --- a/proc/host.c +++ b/proc/host.c @@ -32,7 +32,7 @@ #include <stdio.h> #include <hurd/exec.h> #include <unistd.h> -#include <assert.h> +#include <assert-backtrace.h> #include <version.h> #include <sys/mman.h> @@ -359,7 +359,7 @@ initialize_version_info (void) err = host_info (mach_host_self (), HOST_BASIC_INFO, (host_info_t) &info, &n); - assert (! err); + assert_backtrace (! err); snprintf (uname_info.machine, sizeof uname_info.machine, "%s-%s", mach_cpu_types[info.cpu_type], mach_cpu_subtypes[info.cpu_type][info.cpu_subtype]); @@ -367,11 +367,11 @@ initialize_version_info (void) /* Notice Mach's and our own version and initialize server version variables. */ server_versions = malloc (sizeof (struct server_version) * 10); - assert (server_versions); + assert_backtrace (server_versions); server_versions_nalloc = 10; err = host_kernel_version (mach_host_self (), kv); - assert (! err); + assert_backtrace (! err); /* Make sure the result is null-terminated, as the kernel doesn't guarantee it. */ kv[sizeof (kv) - 1] = '\0'; @@ -382,14 +382,14 @@ initialize_version_info (void) if (p) *p = '\0'; kernel_name = strdup (p ? kv : "mach"); - assert (kernel_name); + assert_backtrace (kernel_name); kernel_version = strdup (p ? p + 1 : kv); - assert (kernel_version); + assert_backtrace (kernel_version); server_versions[0].name = strdup ("proc"); - assert (server_versions[0].name); + assert_backtrace (server_versions[0].name); server_versions[0].version = strdup (HURD_VERSION); - assert (server_versions[0].version); + assert_backtrace (server_versions[0].version); nserver_versions = 1; diff --git a/proc/info.c b/proc/info.c index 79a4c37f..3c1bf6d3 100644 --- a/proc/info.c +++ b/proc/info.c @@ -27,7 +27,7 @@ #include <errno.h> #include <string.h> #include <sys/resource.h> -#include <assert.h> +#include <assert-backtrace.h> #include <hurd/msg.h> #include "proc.h" @@ -71,7 +71,7 @@ S_proc_pid2task (struct proc *callerp, if (! check_owner (callerp, p)) return EPERM; - assert (MACH_PORT_VALID (p->p_task)); + assert_backtrace (MACH_PORT_VALID (p->p_task)); *t = p->p_task; return 0; @@ -618,7 +618,7 @@ S_proc_getprocinfo (struct proc *callerp, pi->pgrp = p->p_pgrp->pg_pgid; pi->session = p->p_pgrp->pg_session->s_sid; for (tp = p; !tp->p_loginleader; tp = tp->p_parent) - assert (tp); + assert_backtrace (tp); pi->logincollection = tp->p_pid; if (p->p_dead || p->p_stopped) { @@ -837,7 +837,7 @@ S_proc_getloginid (struct proc *callerp, } for (p = proc; !p->p_loginleader; p = p->p_parent) - assert (p); + assert_backtrace (p); *leader = p->p_pid; return 0; diff --git a/proc/main.c b/proc/main.c index e615f363..0a6f9916 100644 --- a/proc/main.c +++ b/proc/main.c @@ -25,7 +25,7 @@ #include <hurd/paths.h> #include <hurd/startup.h> #include <device/device.h> -#include <assert.h> +#include <assert-backtrace.h> #include <argp.h> #include <error.h> #include <version.h> @@ -165,7 +165,7 @@ main (int argc, char **argv, char **envp) initialize_version_info (); err = task_get_bootstrap_port (mach_task_self (), &boot); - assert_perror (err); + assert_perror_backtrace (err); if (boot == MACH_PORT_NULL) error (2, 0, "proc server can only be run by startup during boot"); @@ -187,14 +187,14 @@ main (int argc, char **argv, char **envp) /* Create our own proc object. */ self_proc = allocate_proc (mach_task_self ()); - assert (self_proc); + assert_backtrace (self_proc); complete_proc (self_proc, HURD_PID_PROC); startup_port = ports_get_send_right (startup_proc); err = startup_procinit (boot, startup_port, &startup_proc->p_task, &authserver, &_hurd_host_priv, &_hurd_device_master); - assert_perror (err); + assert_perror_backtrace (err); mach_port_deallocate (mach_task_self (), startup_port); /* Get our stderr set up to print on the console, in case we have @@ -252,7 +252,7 @@ main (int argc, char **argv, char **envp) startup_fallback = 1; err = mach_port_deallocate (mach_task_self (), startup); - assert_perror (err); + assert_perror_backtrace (err); } else /* Fall back to abusing the message port lookup. */ @@ -33,7 +33,7 @@ #include <mach/mig_errors.h> #include <sys/resource.h> #include <hurd/auth.h> -#include <assert.h> +#include <assert-backtrace.h> #include <pids.h> #include "proc.h" @@ -189,7 +189,7 @@ S_proc_child (struct proc *parentp, /* Process hierarchy. Remove from our current location and place us under our new parent. Sanity check to make sure parent is currently init. */ - assert (childp->p_parent == init_proc); + assert_backtrace (childp->p_parent == init_proc); if (childp->p_sib) childp->p_sib->p_prevsib = childp->p_prevsib; *childp->p_prevsib = childp->p_sib; @@ -606,7 +606,7 @@ create_init_proc (void) const char *rootsname = "root"; p = allocate_proc (MACH_PORT_NULL); - assert (p); + assert_backtrace (p); p->p_pid = HURD_PID_INIT; @@ -622,11 +622,11 @@ create_init_proc (void) p->p_noowner = 0; p->p_id = make_ids (&zero, 1); - assert (p->p_id); + assert_backtrace (p->p_id); p->p_loginleader = 1; p->p_login = malloc (sizeof (struct login) + strlen (rootsname) + 1); - assert (p->p_login); + assert_backtrace (p->p_login); p->p_login->l_refcnt = 1; strcpy (p->p_login->l_name, rootsname); @@ -649,7 +649,7 @@ proc_death_notify (struct proc *p) p->p_pi.port_right, MACH_MSG_TYPE_MAKE_SEND_ONCE, &old); - assert_perror (err); + assert_perror_backtrace (err); if (old != MACH_PORT_NULL) mach_port_deallocate (mach_task_self (), old); @@ -681,7 +681,7 @@ complete_proc (struct proc *p, pid_t pid) HURD_PID_INIT. */ static const uid_t zero; p->p_id = make_ids (&zero, 1); - assert (p->p_id); + assert_backtrace (p->p_id); } else { @@ -930,8 +930,8 @@ process_has_exited (struct proc *p) void complete_exit (struct proc *p) { - assert (p->p_dead); - assert (p->p_waited); + assert_backtrace (p->p_dead); + assert_backtrace (p->p_waited); remove_proc_from_hash (p); if (p->p_task != MACH_PORT_NULL) @@ -1178,7 +1178,7 @@ S_mach_notify_new_task (struct port_info *notify, proc_child, so we do it on their behalf. */ mach_port_mod_refs (mach_task_self (), task, MACH_PORT_RIGHT_SEND, +1); err = S_proc_child (parentp, task); - assert_perror (err); + assert_perror_backtrace (err); /* Relay the notification. This consumes task and parent. */ return mach_notify_new_task (childp->p_task_namespace, task, parent); @@ -19,7 +19,7 @@ #include <hurd.h> #include "proc.h" #include <hurd/startup.h> -#include <assert.h> +#include <assert-backtrace.h> #include <stdlib.h> #include <stdio.h> diff --git a/proc/pgrp.c b/proc/pgrp.c index 9db1dba6..a7876764 100644 --- a/proc/pgrp.c +++ b/proc/pgrp.c @@ -25,7 +25,7 @@ #include <sys/errno.h> #include <stdlib.h> #include <signal.h> -#include <assert.h> +#include <assert-backtrace.h> #include "proc.h" #include "process_S.h" @@ -130,7 +130,7 @@ boot_setsid (struct proc *p) sess = new_session (p); p->p_pgrp = new_pgrp (p->p_pid, sess); - assert (p->p_pgrp); + assert_backtrace (p->p_pgrp); join_pgrp (p); return; } diff --git a/proc/stubs.c b/proc/stubs.c index 096e55ef..e984f234 100644 --- a/proc/stubs.c +++ b/proc/stubs.c @@ -20,7 +20,7 @@ #include <hurd/hurd_types.h> #include <mach/message.h> #include <string.h> -#include <assert.h> +#include <assert-backtrace.h> #include <stdio.h> #include "proc.h" @@ -61,7 +61,7 @@ blocking_message_send (void *arg) case MACH_SEND_INVALID_NOTIFY: case MACH_SEND_NO_NOTIFY: case MACH_SEND_NOTIFY_IN_PROGRESS: - assert_perror (err); + assert_perror_backtrace (err); break; default: /* Other errors are safe to ignore. */ @@ -169,7 +169,7 @@ send_signal (mach_port_t msgport, case MACH_SEND_INVALID_NOTIFY: case MACH_SEND_NO_NOTIFY: case MACH_SEND_NOTIFY_IN_PROGRESS: - assert_perror (err); + assert_perror_backtrace (err); break; default: /* Other errors are safe to ignore. */ diff --git a/proc/wait.c b/proc/wait.c index 824e6672..e8c379a0 100644 --- a/proc/wait.c +++ b/proc/wait.c @@ -29,7 +29,8 @@ #include <sys/wait.h> #include <errno.h> #include <stdlib.h> -#include <assert.h> +#include <assert-backtrace.h> +#define assert assert_backtrace #include "process_S.h" #include <mach/mig_errors.h> |