Fixed formatting of output in some debugger commands.
Currently all debugger commands assume 32-bit pointers when formatting their output. This means that on x86_64 the output is incorrectly formatted. Fixed this by adding a B_PRINTF_POINTER_WIDTH definition (16 on 64-bit, 8 on 32-bit), and using this to correctly format the output. Not all commands have been fixed yet, but all VM, slab, VFS, team, thread and image commands should be correct.
This commit is contained in:
@@ -148,6 +148,14 @@ typedef generic_addr_t generic_size_t;
|
|||||||
#define B_PRIiTIME B_PRIi32
|
#define B_PRIiTIME B_PRIi32
|
||||||
|
|
||||||
|
|
||||||
|
/* Printed width of a pointer with the %p format (minus 0x prefix). */
|
||||||
|
#ifdef B_HAIKU_64_BIT
|
||||||
|
# define B_PRINTF_POINTER_WIDTH 16
|
||||||
|
#else
|
||||||
|
# define B_PRINTF_POINTER_WIDTH 8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Empty string ("") */
|
/* Empty string ("") */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern const char *B_EMPTY_STRING;
|
extern const char *B_EMPTY_STRING;
|
||||||
|
|||||||
@@ -463,8 +463,8 @@ dump_symbols(int argc, char **argv)
|
|||||||
|
|
||||||
// dump symbols
|
// dump symbols
|
||||||
|
|
||||||
kprintf("Symbols of image %" B_PRId32 "\"%s\":\n"
|
kprintf("Symbols of image %" B_PRId32 "\"%s\":\n", image->id, image->name);
|
||||||
"Address Type Size Name\n", image->id, image->name);
|
kprintf("%-*s Type Size Name\n", B_PRINTF_POINTER_WIDTH, "Address");
|
||||||
|
|
||||||
if (image->num_debug_symbols > 0) {
|
if (image->num_debug_symbols > 0) {
|
||||||
// search extended debug symbol table (contains static symbols)
|
// search extended debug symbol table (contains static symbols)
|
||||||
@@ -475,7 +475,7 @@ dump_symbols(int argc, char **argv)
|
|||||||
>= image->text_region.size + image->data_region.size)
|
>= image->text_region.size + image->data_region.size)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
kprintf("%08lx %s/%s %5ld %s\n",
|
kprintf("%0*lx %s/%s %5ld %s\n", B_PRINTF_POINTER_WIDTH,
|
||||||
symbol->st_value + image->text_region.delta,
|
symbol->st_value + image->text_region.delta,
|
||||||
get_symbol_type_string(symbol), get_symbol_bind_string(symbol),
|
get_symbol_type_string(symbol), get_symbol_bind_string(symbol),
|
||||||
symbol->st_size, image->debug_string_table + symbol->st_name);
|
symbol->st_size, image->debug_string_table + symbol->st_name);
|
||||||
|
|||||||
@@ -3174,7 +3174,9 @@ dump_mounts(int argc, char** argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
kprintf("address id root covers cookie fs_name\n");
|
kprintf("%-*s id %-*s %-*s %-*s fs_name\n",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "address", B_PRINTF_POINTER_WIDTH, "root",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "covers", B_PRINTF_POINTER_WIDTH, "cookie");
|
||||||
|
|
||||||
struct hash_iterator iterator;
|
struct hash_iterator iterator;
|
||||||
struct fs_mount* mount;
|
struct fs_mount* mount;
|
||||||
@@ -3257,8 +3259,9 @@ dump_vnodes(int argc, char** argv)
|
|||||||
struct hash_iterator iterator;
|
struct hash_iterator iterator;
|
||||||
struct vnode* vnode;
|
struct vnode* vnode;
|
||||||
|
|
||||||
kprintf("address dev inode ref cache fs-node locking "
|
kprintf("%-*s dev inode ref %-*s %-*s %-*s flags\n",
|
||||||
"flags\n");
|
B_PRINTF_POINTER_WIDTH, "address", B_PRINTF_POINTER_WIDTH, "cache",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "fs-node", B_PRINTF_POINTER_WIDTH, "locking");
|
||||||
|
|
||||||
hash_open(sVnodeTable, &iterator);
|
hash_open(sVnodeTable, &iterator);
|
||||||
while ((vnode = (struct vnode*)hash_next(sVnodeTable, &iterator)) != NULL) {
|
while ((vnode = (struct vnode*)hash_next(sVnodeTable, &iterator)) != NULL) {
|
||||||
@@ -3293,7 +3296,8 @@ dump_vnode_caches(int argc, char** argv)
|
|||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
device = parse_expression(argv[1]);
|
device = parse_expression(argv[1]);
|
||||||
|
|
||||||
kprintf("address dev inode cache size pages\n");
|
kprintf("%-*s dev inode %-*s size pages\n",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "address", B_PRINTF_POINTER_WIDTH, "cache");
|
||||||
|
|
||||||
hash_open(sVnodeTable, &iterator);
|
hash_open(sVnodeTable, &iterator);
|
||||||
while ((vnode = (struct vnode*)hash_next(sVnodeTable, &iterator)) != NULL) {
|
while ((vnode = (struct vnode*)hash_next(sVnodeTable, &iterator)) != NULL) {
|
||||||
@@ -3344,9 +3348,10 @@ dump_io_context(int argc, char** argv)
|
|||||||
kprintf(" used fds:\t%" B_PRIu32 "\n", context->num_used_fds);
|
kprintf(" used fds:\t%" B_PRIu32 "\n", context->num_used_fds);
|
||||||
kprintf(" max fds:\t%" B_PRIu32 "\n", context->table_size);
|
kprintf(" max fds:\t%" B_PRIu32 "\n", context->table_size);
|
||||||
|
|
||||||
if (context->num_used_fds)
|
if (context->num_used_fds) {
|
||||||
kprintf(" no. type ops ref open mode pos"
|
kprintf(" no. type %*s ref open mode pos %*s\n",
|
||||||
" cookie\n");
|
B_PRINTF_POINTER_WIDTH, "ops", B_PRINTF_POINTER_WIDTH, "cookie");
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32 i = 0; i < context->table_size; i++) {
|
for (uint32 i = 0; i < context->table_size; i++) {
|
||||||
struct file_descriptor* fd = context->fds[i];
|
struct file_descriptor* fd = context->fds[i];
|
||||||
|
|||||||
@@ -261,7 +261,8 @@ dump_images_list(int argc, char **argv)
|
|||||||
team = thread_get_current_thread()->team;
|
team = thread_get_current_thread()->team;
|
||||||
|
|
||||||
kprintf("Registered images of team %" B_PRId32 "\n", team->id);
|
kprintf("Registered images of team %" B_PRId32 "\n", team->id);
|
||||||
kprintf(" ID text size data size name\n");
|
kprintf(" ID %-*s size %-*s size name\n",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "text", B_PRINTF_POINTER_WIDTH, "data");
|
||||||
|
|
||||||
while ((image = (struct image*)list_get_next_item(&team->image_list, image))
|
while ((image = (struct image*)list_get_next_item(&team->image_list, image))
|
||||||
!= NULL) {
|
!= NULL) {
|
||||||
|
|||||||
@@ -153,7 +153,8 @@ dump_sem_list(int argc, char** argv)
|
|||||||
} else if (argc > 1)
|
} else if (argc > 1)
|
||||||
owner = strtoul(argv[1], NULL, 0);
|
owner = strtoul(argv[1], NULL, 0);
|
||||||
|
|
||||||
kprintf("sem id count team last name\n");
|
kprintf("%-*s id count team last name\n", B_PRINTF_POINTER_WIDTH,
|
||||||
|
"sem");
|
||||||
|
|
||||||
for (i = 0; i < sMaxSems; i++) {
|
for (i = 0; i < sMaxSems; i++) {
|
||||||
struct sem_entry* sem = &sSems[i];
|
struct sem_entry* sem = &sSems[i];
|
||||||
|
|||||||
@@ -1766,7 +1766,8 @@ MemoryManager::_CheckMetaChunk(MetaChunk* metaChunk)
|
|||||||
/*static*/ int
|
/*static*/ int
|
||||||
MemoryManager::_DumpRawAllocations(int argc, char** argv)
|
MemoryManager::_DumpRawAllocations(int argc, char** argv)
|
||||||
{
|
{
|
||||||
kprintf("area meta chunk chunk base size (KB)\n");
|
kprintf("%-*s meta chunk chunk %-*s size (KB)\n",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "area", B_PRINTF_POINTER_WIDTH, "base");
|
||||||
|
|
||||||
size_t totalSize = 0;
|
size_t totalSize = 0;
|
||||||
|
|
||||||
@@ -1798,8 +1799,8 @@ MemoryManager::_DumpRawAllocations(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kprintf("total: %9" B_PRIuSIZE "\n",
|
kprintf("total:%*s%9" B_PRIuSIZE "\n", (2 * B_PRINTF_POINTER_WIDTH) + 21,
|
||||||
totalSize / 1024);
|
"", totalSize / 1024);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1976,7 +1977,8 @@ MemoryManager::_DumpArea(int argc, char** argv)
|
|||||||
/*static*/ int
|
/*static*/ int
|
||||||
MemoryManager::_DumpAreas(int argc, char** argv)
|
MemoryManager::_DumpAreas(int argc, char** argv)
|
||||||
{
|
{
|
||||||
kprintf(" base area meta small medium large\n");
|
kprintf(" %*s %*s meta small medium large\n",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "base", B_PRINTF_POINTER_WIDTH, "area");
|
||||||
|
|
||||||
size_t totalTotalSmall = 0;
|
size_t totalTotalSmall = 0;
|
||||||
size_t totalUsedSmall = 0;
|
size_t totalUsedSmall = 0;
|
||||||
|
|||||||
@@ -258,8 +258,9 @@ dump_slab(::slab* slab)
|
|||||||
static int
|
static int
|
||||||
dump_slabs(int argc, char* argv[])
|
dump_slabs(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
kprintf("%10s %22s %8s %8s %8s %6s %8s %8s %8s\n", "address", "name",
|
kprintf("%*s %22s %8s %8s %8s %6s %8s %8s %8s\n",
|
||||||
"objsize", "align", "usage", "empty", "usedobj", "total", "flags");
|
B_PRINTF_POINTER_WIDTH + 2, "address", "name", "objsize", "align",
|
||||||
|
"usage", "empty", "usedobj", "total", "flags");
|
||||||
|
|
||||||
ObjectCacheList::Iterator it = sObjectCaches.GetIterator();
|
ObjectCacheList::Iterator it = sObjectCaches.GetIterator();
|
||||||
|
|
||||||
@@ -303,7 +304,8 @@ dump_cache_info(int argc, char* argv[])
|
|||||||
kprintf("resize entry don't wait: %p\n", cache->resize_entry_dont_wait);
|
kprintf("resize entry don't wait: %p\n", cache->resize_entry_dont_wait);
|
||||||
kprintf("resize entry can wait: %p\n", cache->resize_entry_can_wait);
|
kprintf("resize entry can wait: %p\n", cache->resize_entry_can_wait);
|
||||||
|
|
||||||
kprintf(" slab chunk size used offset free\n");
|
kprintf(" %-*s %-*s size used offset free\n",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "slab", B_PRINTF_POINTER_WIDTH, "chunk");
|
||||||
|
|
||||||
SlabList::Iterator iterator = cache->empty.GetIterator();
|
SlabList::Iterator iterator = cache->empty.GetIterator();
|
||||||
if (iterator.HasNext())
|
if (iterator.HasNext())
|
||||||
|
|||||||
@@ -1185,7 +1185,8 @@ dump_team_info(int argc, char** argv)
|
|||||||
static int
|
static int
|
||||||
dump_teams(int argc, char** argv)
|
dump_teams(int argc, char** argv)
|
||||||
{
|
{
|
||||||
kprintf("team id parent name\n");
|
kprintf("%-*s id %-*s name\n", B_PRINTF_POINTER_WIDTH, "team",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "parent");
|
||||||
|
|
||||||
for (TeamTable::Iterator it = sTeamHash.GetIterator();
|
for (TeamTable::Iterator it = sTeamHash.GetIterator();
|
||||||
Team* team = it.Next();) {
|
Team* team = it.Next();) {
|
||||||
|
|||||||
@@ -1595,8 +1595,10 @@ state_to_text(Thread *thread, int32 state)
|
|||||||
static void
|
static void
|
||||||
print_thread_list_table_head()
|
print_thread_list_table_head()
|
||||||
{
|
{
|
||||||
kprintf("thread id state wait for object cpu pri stack "
|
kprintf("%-*s id state wait for %-*s cpu pri %-*s team "
|
||||||
" team name\n");
|
"name\n",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "thread", B_PRINTF_POINTER_WIDTH, "object",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "stack");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1614,42 +1616,44 @@ _dump_thread_info(Thread *thread, bool shortInfo)
|
|||||||
{
|
{
|
||||||
sem_id sem = (sem_id)(addr_t)thread->wait.object;
|
sem_id sem = (sem_id)(addr_t)thread->wait.object;
|
||||||
if (sem == thread->msg.read_sem)
|
if (sem == thread->msg.read_sem)
|
||||||
kprintf(" ");
|
kprintf("%*s", B_PRINTF_POINTER_WIDTH + 15, "");
|
||||||
else
|
else {
|
||||||
kprintf("sem %12" B_PRId32 " ", sem);
|
kprintf("sem %-*" B_PRId32,
|
||||||
|
B_PRINTF_POINTER_WIDTH + 5, sem);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case THREAD_BLOCK_TYPE_CONDITION_VARIABLE:
|
case THREAD_BLOCK_TYPE_CONDITION_VARIABLE:
|
||||||
kprintf("cvar %p ", thread->wait.object);
|
kprintf("cvar %p ", thread->wait.object);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THREAD_BLOCK_TYPE_SNOOZE:
|
case THREAD_BLOCK_TYPE_SNOOZE:
|
||||||
kprintf(" ");
|
kprintf("%*s", B_PRINTF_POINTER_WIDTH + 15, "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THREAD_BLOCK_TYPE_SIGNAL:
|
case THREAD_BLOCK_TYPE_SIGNAL:
|
||||||
kprintf("signal ");
|
kprintf("signal%*s", B_PRINTF_POINTER_WIDTH + 9, "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THREAD_BLOCK_TYPE_MUTEX:
|
case THREAD_BLOCK_TYPE_MUTEX:
|
||||||
kprintf("mutex %p ", thread->wait.object);
|
kprintf("mutex %p ", thread->wait.object);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THREAD_BLOCK_TYPE_RW_LOCK:
|
case THREAD_BLOCK_TYPE_RW_LOCK:
|
||||||
kprintf("rwlock %p ", thread->wait.object);
|
kprintf("rwlock %p ", thread->wait.object);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case THREAD_BLOCK_TYPE_OTHER:
|
case THREAD_BLOCK_TYPE_OTHER:
|
||||||
kprintf("other ");
|
kprintf("other%*s", B_PRINTF_POINTER_WIDTH + 10, "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
kprintf("??? %p ", thread->wait.object);
|
kprintf("??? %p ", thread->wait.object);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
kprintf(" - ");
|
kprintf("-%*s", B_PRINTF_POINTER_WIDTH + 14, "");
|
||||||
|
|
||||||
// on which CPU does it run?
|
// on which CPU does it run?
|
||||||
if (thread->cpu)
|
if (thread->cpu)
|
||||||
|
|||||||
@@ -344,8 +344,9 @@ VMAddressSpace::_DumpCommand(int argc, char** argv)
|
|||||||
/*static*/ int
|
/*static*/ int
|
||||||
VMAddressSpace::_DumpListCommand(int argc, char** argv)
|
VMAddressSpace::_DumpListCommand(int argc, char** argv)
|
||||||
{
|
{
|
||||||
kprintf(" address id base end area count "
|
kprintf(" %*s id %*s %*s area count area size\n",
|
||||||
" area size\n");
|
B_PRINTF_POINTER_WIDTH, "address", B_PRINTF_POINTER_WIDTH, "base",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "end");
|
||||||
|
|
||||||
AddressSpaceTable::Iterator it = sAddressSpaceTable.GetIterator();
|
AddressSpaceTable::Iterator it = sAddressSpaceTable.GetIterator();
|
||||||
while (VMAddressSpace* space = it.Next()) {
|
while (VMAddressSpace* space = it.Next()) {
|
||||||
|
|||||||
@@ -3372,7 +3372,9 @@ dump_area_list(int argc, char** argv)
|
|||||||
name = argv[1];
|
name = argv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
kprintf("addr id base\t\tsize protect lock name\n");
|
kprintf("%-*s id %-*s %-*sprotect lock name\n",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "addr", B_PRINTF_POINTER_WIDTH, "base",
|
||||||
|
B_PRINTF_POINTER_WIDTH, "size");
|
||||||
|
|
||||||
VMAreaHashTable::Iterator it = VMAreaHash::GetIterator();
|
VMAreaHashTable::Iterator it = VMAreaHash::GetIterator();
|
||||||
while ((area = it.Next()) != NULL) {
|
while ((area = it.Next()) != NULL) {
|
||||||
@@ -3380,7 +3382,7 @@ dump_area_list(int argc, char** argv)
|
|||||||
|| (name != NULL && strstr(area->name, name) == NULL))
|
|| (name != NULL && strstr(area->name, name) == NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
kprintf("%p %5" B_PRIx32 " %p\t%p %4" B_PRIx32 "\t%4d %s\n", area,
|
kprintf("%p %5" B_PRIx32 " %p %p %4" B_PRIx32 " %4d %s\n", area,
|
||||||
area->id, (void*)area->Base(), (void*)area->Size(),
|
area->id, (void*)area->Base(), (void*)area->Size(),
|
||||||
area->protection, area->wiring, area->name);
|
area->protection, area->wiring, area->name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user