diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index 39b912c49f..d8246f2c79 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -338,6 +338,7 @@ enum { // debugging helper AS_DUMP_ALLOCATOR, + AS_DUMP_BITMAPS, AS_LAST_CODE }; diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index db8d9e79c6..5b866ec81b 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -2387,6 +2387,7 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) case AS_APP_CRASHED: case AS_DUMP_ALLOCATOR: + case AS_DUMP_BITMAPS: { BAutolock locker(fApplicationsLock); diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 0738517782..adaa3a6a43 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -548,6 +548,23 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) case AS_DUMP_ALLOCATOR: fMemoryAllocator.Dump(); break; + case AS_DUMP_BITMAPS: + { + fMapLocker.Lock(); + + debug_printf("Application %ld, %s: %d bitmaps:\n", ClientTeam(), + Signature(), (int)fBitmapMap.size()); + + BitmapMap::const_iterator iterator = fBitmapMap.begin(); + for (; iterator != fBitmapMap.end(); iterator++) { + ServerBitmap* bitmap = iterator->second; + debug_printf(" [%ld] %ldx%ld, area %ld, size %ld\n", + bitmap->Token(), bitmap->Width(), bitmap->Height(), + bitmap->Area(), bitmap->BitsLength()); + } + fMapLocker.Unlock(); + break; + } case AS_CREATE_WINDOW: case AS_CREATE_OFFSCREEN_WINDOW: diff --git a/src/tests/servers/app/app_server_debug.cpp b/src/tests/servers/app/app_server_debug.cpp index 184e62adac..487b41351f 100644 --- a/src/tests/servers/app/app_server_debug.cpp +++ b/src/tests/servers/app/app_server_debug.cpp @@ -37,18 +37,48 @@ send_debug_message(team_id team, int32 code) } +void +usage() +{ + fprintf(stderr, "usage: %s -[ab] [...]\n", __progname); + exit(1); +} + + int main(int argc, char** argv) { - if (argc == 1) { - fprintf(stderr, "usage: %s [...]\n", __progname); - return 1; + if (argc == 1) + usage(); + + bool dumpAllocator = false; + bool dumpBitmaps = false; + + int32 i = 1; + while (argv[i][0] == '-') { + const char* arg = &argv[i][1]; + while (arg[0]) { + if (arg[0] == 'a') + dumpAllocator = true; + else if (arg[0] == 'b') + dumpBitmaps = true; + else + usage(); + + arg++; + } + i++; } for (int32 i = 1; i < argc; i++) { team_id team = atoi(argv[i]); - if (team > 0) + if (team <= 0) + continue; + + if (dumpAllocator) send_debug_message(team, AS_DUMP_ALLOCATOR); + if (dumpBitmaps) + send_debug_message(team, AS_DUMP_BITMAPS); } return 0;