From e482c592854fd8a54f23d908ef79b1a35d314f95 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 11 Dec 2003 14:21:00 +0000 Subject: 2003-12-11 Joel Sherrill PR 540/rtems_misc * cpuuse/cpuuse.c, rtmonuse/rtmonuse.c: Correct object name printing. --- cpukit/libmisc/ChangeLog | 5 +++++ cpukit/libmisc/cpuuse/cpuuse.c | 24 +++++++++++++-------- cpukit/libmisc/rtmonuse/rtmonuse.c | 44 ++++++++++++++++++++++++++++++-------- 3 files changed, 55 insertions(+), 18 deletions(-) (limited to 'cpukit') diff --git a/cpukit/libmisc/ChangeLog b/cpukit/libmisc/ChangeLog index 419d2563e5..157ca092b5 100644 --- a/cpukit/libmisc/ChangeLog +++ b/cpukit/libmisc/ChangeLog @@ -1,3 +1,8 @@ +2003-12-11 Joel Sherrill + + PR 540/rtems_misc + * cpuuse/cpuuse.c, rtmonuse/rtmonuse.c: Correct object name printing. + 2003-12-11 Joel Sherrill PR 531/rtems_misc diff --git a/cpukit/libmisc/cpuuse/cpuuse.c b/cpukit/libmisc/cpuuse/cpuuse.c index 739321a005..bf4f674fce 100644 --- a/cpukit/libmisc/cpuuse/cpuuse.c +++ b/cpukit/libmisc/cpuuse/cpuuse.c @@ -40,6 +40,7 @@ void CPU_usage_Dump( void ) Thread_Control *the_thread; Objects_Information *information; unsigned32 u32_name; + char *cname; char name[5]; unsigned32 total_units = 0; @@ -79,16 +80,21 @@ void CPU_usage_Dump( void ) if ( !the_thread ) continue; - if ( information->is_string ) - u32_name = *(unsigned32 *)the_thread->Object.name; - else + if ( information->is_string ) { + cname = the_thread->Object.name; + name[ 0 ] = cname[0]; + name[ 1 ] = cname[1]; + name[ 2 ] = cname[2]; + name[ 3 ] = cname[3]; + name[ 4 ] = '\0'; + } else { u32_name = (unsigned32)the_thread->Object.name; - - name[ 0 ] = (u32_name >> 24) & 0xff; - name[ 1 ] = (u32_name >> 16) & 0xff; - name[ 2 ] = (u32_name >> 8) & 0xff; - name[ 3 ] = (u32_name >> 0) & 0xff; - name[ 4 ] = '\0'; + name[ 0 ] = (u32_name >> 24) & 0xff; + name[ 1 ] = (u32_name >> 16) & 0xff; + name[ 2 ] = (u32_name >> 8) & 0xff; + name[ 3 ] = (u32_name >> 0) & 0xff; + name[ 4 ] = '\0'; + } if ( !isprint(name[0]) ) name[0] = '*'; if ( !isprint(name[1]) ) name[1] = '*'; diff --git a/cpukit/libmisc/rtmonuse/rtmonuse.c b/cpukit/libmisc/rtmonuse/rtmonuse.c index 52c272828d..bd1d4b38b0 100644 --- a/cpukit/libmisc/rtmonuse/rtmonuse.c +++ b/cpukit/libmisc/rtmonuse/rtmonuse.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -130,7 +131,10 @@ void Period_usage_Dump( void ) Period_usage_t *the_usage; Rate_monotonic_Control *the_period; unsigned32 u32_name; + char *cname; char name[5]; + unsigned32 api_index; + Objects_Information *information; if ( !Period_usage_Information ) { printf( "Period statistics library is not initialized\n" ); @@ -154,17 +158,39 @@ void Period_usage_Dump( void ) the_period = (Rate_monotonic_Control *)_Rate_monotonic_Information.local_table[ i ]; - if ( the_period->owner ) - u32_name = *(unsigned32 *)the_period->owner->Object.name; - else - u32_name = rtems_build_name(' ', ' ', ' ', ' '); - - name[ 0 ] = (u32_name >> 24) & 0xff; - name[ 1 ] = (u32_name >> 16) & 0xff; - name[ 2 ] = (u32_name >> 8) & 0xff; - name[ 3 ] = (u32_name >> 0) & 0xff; + name[ 0 ] = ' '; + name[ 1 ] = ' '; + name[ 2 ] = ' '; + name[ 3 ] = ' '; name[ 4 ] = '\0'; + if ( the_period->owner ) { + api_index = _Objects_Get_API(the_period->owner->Object.id); + information = _Objects_Information_table[ api_index ][ 1 ]; + + if ( information->is_string ) { + cname = the_period->owner->Object.name; + name[ 0 ] = cname[0]; + name[ 1 ] = cname[1]; + name[ 2 ] = cname[2]; + name[ 3 ] = cname[3]; + name[ 4 ] = '\0'; + } else { + u32_name = (unsigned32)the_period->owner->Object.name; + name[ 0 ] = (u32_name >> 24) & 0xff; + name[ 1 ] = (u32_name >> 16) & 0xff; + name[ 2 ] = (u32_name >> 8) & 0xff; + name[ 3 ] = (u32_name >> 0) & 0xff; + name[ 4 ] = '\0'; + } + } + + if ( !isprint(name[0]) ) name[0] = '*'; + if ( !isprint(name[1]) ) name[1] = '*'; + if ( !isprint(name[2]) ) name[2] = '*'; + if ( !isprint(name[3]) ) name[3] = '*'; + + printf( "0x%08x %4s %6d %3d %d/%d/%5.2f %d/%d/%3.2f\n", the_usage->id, -- cgit v1.2.3