From c377d3e2b439a770210d502e3fd212a05929a7a2 Mon Sep 17 00:00:00 2001 From: jmallett Date: Sun, 20 Oct 2002 22:49:06 +0000 Subject: [PATCH] When dumping thread info, only include the filename and line if we actually know what file! (Prevents use of NULL). MFC after: 1 day Reviewed by: deischen --- lib/libc_r/uthread/uthread_info.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/libc_r/uthread/uthread_info.c b/lib/libc_r/uthread/uthread_info.c index c8bc4d5a7905..c3d259e606e9 100644 --- a/lib/libc_r/uthread/uthread_info.c +++ b/lib/libc_r/uthread/uthread_info.c @@ -220,11 +220,17 @@ dump_thread(int fd, pthread_t pthread, int long_version) /* Output a record for the thread: */ snprintf(s, sizeof(s), - "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n", + "--------------------\nThread %p (%s) prio %3d state %s", pthread, (pthread->name == NULL) ? "" : pthread->name, - pthread->active_priority, thread_info[i].name, pthread->fname, - pthread->lineno); + pthread->active_priority, thread_info[i].name); __sys_write(fd, s, strlen(s)); + /* And now where it is. */ + if (pthread->fname != NULL) { + snprintf(s, sizeof(s), " [%s:%d]", pthread->fname, + pthread->lineno); + __sys_write(fd, s, strlen(s)); + } + __sys_write(fd, "\n", 1); if (long_version != 0) { /* Check if this is the running thread: */