summaryrefslogtreecommitdiff
path: root/libports
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2017-06-19 21:20:57 +0200
committerJustus Winter <justus@gnupg.org>2017-08-05 18:42:22 +0200
commit835b293d35a209d38047126443d41fa7090daa4c (patch)
tree5bf956895e6030f91cd618fb191b2151f6d25423 /libports
parentdc0b5a43224999223a246870912b0f292b1980e9 (diff)
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 'libports')
-rw-r--r--libports/claim-right.c4
-rw-r--r--libports/complete-deallocate.c6
-rw-r--r--libports/create-internal.c6
-rw-r--r--libports/destroy-right.c4
-rw-r--r--libports/get-right.c4
-rw-r--r--libports/get-send-right.c4
-rw-r--r--libports/import-port.c4
-rw-r--r--libports/interrupt-on-notify.c4
-rw-r--r--libports/manage-multithread.c2
-rw-r--r--libports/port-deref-deferred.c12
-rw-r--r--libports/port-deref-weak.c2
-rw-r--r--libports/port-deref.c2
-rw-r--r--libports/port-ref-weak.c2
-rw-r--r--libports/port-ref.c2
-rw-r--r--libports/reallocate-from-external.c14
-rw-r--r--libports/reallocate-port.c14
-rw-r--r--libports/resume-all-rpcs.c4
-rw-r--r--libports/resume-bucket-rpcs.c4
-rw-r--r--libports/resume-class-rpcs.c4
-rw-r--r--libports/resume-port-rpcs.c4
-rw-r--r--libports/transfer-right.c10
21 files changed, 56 insertions, 56 deletions
diff --git a/libports/claim-right.c b/libports/claim-right.c
index 85592ff0..2ead7171 100644
--- a/libports/claim-right.c
+++ b/libports/claim-right.c
@@ -20,7 +20,7 @@
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
#include <errno.h>
#include <hurd/ihash.h>
@@ -39,7 +39,7 @@ ports_claim_right (void *portstruct)
hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry);
pthread_rwlock_unlock (&_ports_htable_lock);
err = mach_port_move_member (mach_task_self (), ret, MACH_PORT_NULL);
- assert_perror (err);
+ assert_perror_backtrace (err);
pthread_mutex_lock (&_ports_lock);
pi->port_right = MACH_PORT_NULL;
if (pi->flags & PORT_HAS_SENDRIGHTS)
diff --git a/libports/complete-deallocate.c b/libports/complete-deallocate.c
index e3123b26..5c548a37 100644
--- a/libports/complete-deallocate.c
+++ b/libports/complete-deallocate.c
@@ -19,13 +19,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
#include <hurd/ihash.h>
void
_ports_complete_deallocate (struct port_info *pi)
{
- assert ((pi->flags & PORT_HAS_SENDRIGHTS) == 0);
+ assert_backtrace ((pi->flags & PORT_HAS_SENDRIGHTS) == 0);
if (MACH_PORT_VALID (pi->port_right))
{
@@ -38,7 +38,7 @@ _ports_complete_deallocate (struct port_info *pi)
/* A reference was reacquired through a hash table lookup.
It's fine, we didn't touch anything yet. */
/* XXX: This really shouldn't happen. */
- assert (! "reacquired reference w/o send rights");
+ assert_backtrace (! "reacquired reference w/o send rights");
pthread_rwlock_unlock (&_ports_htable_lock);
return;
}
diff --git a/libports/create-internal.c b/libports/create-internal.c
index d79dc78f..853d541e 100644
--- a/libports/create-internal.c
+++ b/libports/create-internal.c
@@ -18,7 +18,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
-#include <assert.h>
+#include <assert-backtrace.h>
#include <hurd/ihash.h>
#include "ports.h"
@@ -49,7 +49,7 @@ _ports_create_port_internal (struct port_class *class,
{
err = mach_port_mod_refs (mach_task_self (), port,
MACH_PORT_RIGHT_RECEIVE, -1);
- assert_perror (err);
+ assert_perror_backtrace (err);
return ENOMEM;
}
@@ -123,7 +123,7 @@ _ports_create_port_internal (struct port_class *class,
error_t e;
e = mach_port_mod_refs (mach_task_self (), port,
MACH_PORT_RIGHT_RECEIVE, -1);
- assert_perror (e);
+ assert_perror_backtrace (e);
free (pi);
return err;
diff --git a/libports/destroy-right.c b/libports/destroy-right.c
index 276255f4..1afa80db 100644
--- a/libports/destroy-right.c
+++ b/libports/destroy-right.c
@@ -20,7 +20,7 @@
#include "ports.h"
#include <hurd/ihash.h>
-#include <assert.h>
+#include <assert-backtrace.h>
#include <pthread.h>
#include <error.h>
@@ -73,7 +73,7 @@ ports_destroy_right (void *portstruct)
{
err = mach_port_mod_refs (mach_task_self (), port_right,
MACH_PORT_RIGHT_RECEIVE, -1);
- assert_perror (err);
+ assert_perror_backtrace (err);
}
if (defer)
diff --git a/libports/get-right.c b/libports/get-right.c
index 8681f465..8b58d722 100644
--- a/libports/get-right.c
+++ b/libports/get-right.c
@@ -20,7 +20,7 @@
#include "ports.h"
#include <mach/notify.h>
-#include <assert.h>
+#include <assert-backtrace.h>
mach_port_t
ports_get_right (void *port)
@@ -49,7 +49,7 @@ ports_get_right (void *port)
pi->port_right,
MACH_MSG_TYPE_MAKE_SEND_ONCE,
&foo);
- assert_perror (err);
+ assert_perror_backtrace (err);
if (foo != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), foo);
}
diff --git a/libports/get-send-right.c b/libports/get-send-right.c
index 3e00276c..524cb8e3 100644
--- a/libports/get-send-right.c
+++ b/libports/get-send-right.c
@@ -18,7 +18,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
mach_port_t
ports_get_send_right (void *port)
@@ -32,7 +32,7 @@ ports_get_send_right (void *port)
err = mach_port_insert_right (mach_task_self (),
right, right, MACH_MSG_TYPE_MAKE_SEND);
- assert_perror (err);
+ assert_perror_backtrace (err);
return right;
}
diff --git a/libports/import-port.c b/libports/import-port.c
index 2c638e18..3a13876b 100644
--- a/libports/import-port.c
+++ b/libports/import-port.c
@@ -21,7 +21,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
#include <hurd/ihash.h>
#include <mach/notify.h>
@@ -107,7 +107,7 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket,
stat.mps_mscount,
port, MACH_MSG_TYPE_MAKE_SEND_ONCE,
&foo);
- assert_perror (err);
+ assert_perror_backtrace (err);
if (foo != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), foo);
}
diff --git a/libports/interrupt-on-notify.c b/libports/interrupt-on-notify.c
index b358e840..2feff63f 100644
--- a/libports/interrupt-on-notify.c
+++ b/libports/interrupt-on-notify.c
@@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
/* Arrange for hurd_cancel to be called on RPC's thread if OBJECT gets notified
that any of the things in COND have happened to PORT. RPC should be an
@@ -176,7 +176,7 @@ ports_interrupt_self_on_notification (void *object,
break;
pthread_mutex_unlock (&_ports_lock);
- assert (rpc);
+ assert_backtrace (rpc);
/* We don't have to worry about RPC going away after we dropped the lock
because we're that thread, and we're still here. */
diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c
index 576e7670..b3f96877 100644
--- a/libports/manage-multithread.c
+++ b/libports/manage-multithread.c
@@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
#include <error.h>
#include <stdio.h>
#include <mach/message.h>
diff --git a/libports/port-deref-deferred.c b/libports/port-deref-deferred.c
index 2580e913..76373ebb 100644
--- a/libports/port-deref-deferred.c
+++ b/libports/port-deref-deferred.c
@@ -19,7 +19,7 @@
You should have received a copy of the GNU General Public License
along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
-#include <assert.h>
+#include <assert-backtrace.h>
#include <pthread.h>
#include "ports.h"
@@ -40,7 +40,7 @@ valid_color (unsigned int c)
static inline unsigned int
flip_color (unsigned int c)
{
- assert (valid_color (c));
+ assert_backtrace (valid_color (c));
return ! c;
}
@@ -60,7 +60,7 @@ _ports_threadpool_init (struct ports_threadpool *pool)
static inline void
flip_generations (struct ports_threadpool *pool)
{
- assert (pool->old_threads == 0);
+ assert_backtrace (pool->old_threads == 0);
pool->old_threads = pool->young_threads;
pool->old_objects = pool->young_objects;
pool->young_threads = 0;
@@ -91,7 +91,7 @@ _ports_thread_quiescent (struct ports_threadpool *pool,
struct ports_thread *thread)
{
struct pi_list *free_list = NULL, *p;
- assert (valid_color (thread->color));
+ assert_backtrace (valid_color (thread->color));
pthread_spin_lock (&pool->lock);
if (thread->color == pool->color)
@@ -123,7 +123,7 @@ void
_ports_thread_offline (struct ports_threadpool *pool,
struct ports_thread *thread)
{
- assert (valid_color (thread->color));
+ assert_backtrace (valid_color (thread->color));
retry:
pthread_spin_lock (&pool->lock);
@@ -154,7 +154,7 @@ _ports_port_deref_deferred (struct port_info *pi)
pool->young_objects = pl;
if (pool->old_threads == 0)
{
- assert (pool->old_objects == NULL);
+ assert_backtrace (pool->old_objects == NULL);
flip_generations (pool);
}
pthread_spin_unlock (&pool->lock);
diff --git a/libports/port-deref-weak.c b/libports/port-deref-weak.c
index 8432660c..cb3f435a 100644
--- a/libports/port-deref-weak.c
+++ b/libports/port-deref-weak.c
@@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
void
ports_port_deref_weak (void *portstruct)
diff --git a/libports/port-deref.c b/libports/port-deref.c
index b97dd13d..34fa6f43 100644
--- a/libports/port-deref.c
+++ b/libports/port-deref.c
@@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
void
ports_port_deref (void *portstruct)
diff --git a/libports/port-ref-weak.c b/libports/port-ref-weak.c
index 3f62dfed..de759996 100644
--- a/libports/port-ref-weak.c
+++ b/libports/port-ref-weak.c
@@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
void
ports_port_ref_weak (void *portstruct)
diff --git a/libports/port-ref.c b/libports/port-ref.c
index 9a1c71e6..0088f09d 100644
--- a/libports/port-ref.c
+++ b/libports/port-ref.c
@@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
void
ports_port_ref (void *portstruct)
diff --git a/libports/reallocate-from-external.c b/libports/reallocate-from-external.c
index d0fae1a9..7392aa8a 100644
--- a/libports/reallocate-from-external.c
+++ b/libports/reallocate-from-external.c
@@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
#include <hurd/ihash.h>
#include <mach/notify.h>
@@ -33,15 +33,15 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive)
error_t err;
err = mach_port_get_receive_status (mach_task_self (), receive, &stat);
- assert_perror (err);
+ assert_perror_backtrace (err);
pthread_mutex_lock (&_ports_lock);
- assert (pi->port_right);
+ assert_backtrace (pi->port_right);
err = mach_port_mod_refs (mach_task_self (), pi->port_right,
MACH_PORT_RIGHT_RECEIVE, -1);
- assert_perror (err);
+ assert_perror_backtrace (err);
pthread_rwlock_wrlock (&_ports_htable_lock);
hurd_ihash_locp_remove (&_ports_htable, pi->ports_htable_entry);
@@ -65,11 +65,11 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive)
pthread_rwlock_wrlock (&_ports_htable_lock);
err = hurd_ihash_add (&_ports_htable, receive, pi);
- assert_perror (err);
+ assert_perror_backtrace (err);
err = hurd_ihash_add (&pi->bucket->htable, receive, pi);
pthread_rwlock_unlock (&_ports_htable_lock);
pthread_mutex_unlock (&_ports_lock);
- assert_perror (err);
+ assert_perror_backtrace (err);
/* This is an optimization. It may fail. */
mach_port_set_protected_payload (mach_task_self (), pi->port_right,
@@ -84,7 +84,7 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive)
stat.mps_mscount, receive,
MACH_MSG_TYPE_MAKE_SEND_ONCE,
&foo);
- assert_perror (err);
+ assert_perror_backtrace (err);
if (foo != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), foo);
}
diff --git a/libports/reallocate-port.c b/libports/reallocate-port.c
index 4e859a1f..8a9d3601 100644
--- a/libports/reallocate-port.c
+++ b/libports/reallocate-port.c
@@ -20,7 +20,7 @@
#include "ports.h"
#include <hurd/ihash.h>
-#include <assert.h>
+#include <assert-backtrace.h>
void
ports_reallocate_port (void *portstruct)
@@ -30,11 +30,11 @@ ports_reallocate_port (void *portstruct)
int dropref = 0;
pthread_mutex_lock (&_ports_lock);
- assert (pi->port_right);
+ assert_backtrace (pi->port_right);
err = mach_port_mod_refs (mach_task_self (), pi->port_right,
MACH_PORT_RIGHT_RECEIVE, -1);
- assert_perror (err);
+ assert_perror_backtrace (err);
pthread_rwlock_wrlock (&_ports_htable_lock);
hurd_ihash_locp_remove (&_ports_htable, pi->ports_htable_entry);
@@ -43,7 +43,7 @@ ports_reallocate_port (void *portstruct)
err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE,
&pi->port_right);
- assert_perror (err);
+ assert_perror_backtrace (err);
if (pi->flags & PORT_HAS_SENDRIGHTS)
{
pi->flags &= ~PORT_HAS_SENDRIGHTS;
@@ -53,11 +53,11 @@ ports_reallocate_port (void *portstruct)
pi->mscount = 0;
pthread_rwlock_wrlock (&_ports_htable_lock);
err = hurd_ihash_add (&_ports_htable, pi->port_right, pi);
- assert_perror (err);
+ assert_perror_backtrace (err);
err = hurd_ihash_add (&pi->bucket->htable, pi->port_right, pi);
pthread_rwlock_unlock (&_ports_htable_lock);
pthread_mutex_unlock (&_ports_lock);
- assert_perror (err);
+ assert_perror_backtrace (err);
/* This is an optimization. It may fail. */
mach_port_set_protected_payload (mach_task_self (), pi->port_right,
@@ -65,7 +65,7 @@ ports_reallocate_port (void *portstruct)
err = mach_port_move_member (mach_task_self (), pi->port_right,
pi->bucket->portset);
- assert_perror (err);
+ assert_perror_backtrace (err);
if (dropref)
ports_port_deref (pi);
diff --git a/libports/resume-all-rpcs.c b/libports/resume-all-rpcs.c
index e4befffc..0b78c925 100644
--- a/libports/resume-all-rpcs.c
+++ b/libports/resume-all-rpcs.c
@@ -19,13 +19,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
void
ports_resume_all_rpcs ()
{
pthread_mutex_lock (&_ports_lock);
- assert (_ports_flags & _PORTS_INHIBITED);
+ assert_backtrace (_ports_flags & _PORTS_INHIBITED);
_ports_flags &= ~_PORTS_INHIBITED;
if (_ports_flags & _PORTS_BLOCKED)
{
diff --git a/libports/resume-bucket-rpcs.c b/libports/resume-bucket-rpcs.c
index cf4db91c..ad129f44 100644
--- a/libports/resume-bucket-rpcs.c
+++ b/libports/resume-bucket-rpcs.c
@@ -19,13 +19,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
void
ports_resume_bucket_rpcs (struct port_bucket *bucket)
{
pthread_mutex_lock (&_ports_lock);
- assert (bucket->flags & PORT_BUCKET_INHIBITED);
+ assert_backtrace (bucket->flags & PORT_BUCKET_INHIBITED);
bucket->flags &= ~PORT_BUCKET_INHIBITED;
if (bucket->flags & PORT_BUCKET_BLOCKED)
{
diff --git a/libports/resume-class-rpcs.c b/libports/resume-class-rpcs.c
index 60a2b12e..806108b8 100644
--- a/libports/resume-class-rpcs.c
+++ b/libports/resume-class-rpcs.c
@@ -19,13 +19,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
void
ports_resume_class_rpcs (struct port_class *class)
{
pthread_mutex_lock (&_ports_lock);
- assert (class->flags & PORT_CLASS_INHIBITED);
+ assert_backtrace (class->flags & PORT_CLASS_INHIBITED);
class->flags &= ~PORT_CLASS_INHIBITED;
if (class->flags & PORT_CLASS_BLOCKED)
{
diff --git a/libports/resume-port-rpcs.c b/libports/resume-port-rpcs.c
index 6d71ab50..1894bce9 100644
--- a/libports/resume-port-rpcs.c
+++ b/libports/resume-port-rpcs.c
@@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
void
ports_resume_port_rpcs (void *portstruct)
@@ -28,7 +28,7 @@ ports_resume_port_rpcs (void *portstruct)
pthread_mutex_lock (&_ports_lock);
- assert (pi->flags & PORT_INHIBITED);
+ assert_backtrace (pi->flags & PORT_INHIBITED);
pi->flags &= ~PORT_INHIBITED;
if (pi->flags & PORT_BLOCKED)
{
diff --git a/libports/transfer-right.c b/libports/transfer-right.c
index 64de7f79..6e05dc65 100644
--- a/libports/transfer-right.c
+++ b/libports/transfer-right.c
@@ -20,7 +20,7 @@
#include "ports.h"
-#include <assert.h>
+#include <assert-backtrace.h>
#include <hurd/ihash.h>
error_t
@@ -63,7 +63,7 @@ ports_transfer_right (void *tostruct,
pthread_rwlock_unlock (&_ports_htable_lock);
err = mach_port_mod_refs (mach_task_self (), topi->port_right,
MACH_PORT_RIGHT_RECEIVE, -1);
- assert_perror (err);
+ assert_perror_backtrace (err);
if ((topi->flags & PORT_HAS_SENDRIGHTS) && !hassendrights)
{
dereftopi = 1;
@@ -87,10 +87,10 @@ ports_transfer_right (void *tostruct,
{
pthread_rwlock_wrlock (&_ports_htable_lock);
err = hurd_ihash_add (&_ports_htable, port, topi);
- assert_perror (err);
+ assert_perror_backtrace (err);
err = hurd_ihash_add (&topi->bucket->htable, port, topi);
pthread_rwlock_unlock (&_ports_htable_lock);
- assert_perror (err);
+ assert_perror_backtrace (err);
/* This is an optimization. It may fail. */
mach_port_set_protected_payload (mach_task_self (), port,
(unsigned long) topi);
@@ -98,7 +98,7 @@ ports_transfer_right (void *tostruct,
{
err = mach_port_move_member (mach_task_self (), port,
topi->bucket->portset);
- assert_perror (err);
+ assert_perror_backtrace (err);
}
}