1 /* 2 * Copyright 2010, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <DesktopLink.h> 8 #include <ServerProtocol.h> 9 10 #include <stdio.h> 11 #include <stdlib.h> 12 13 14 extern const char* __progname; 15 16 17 status_t 18 send_debug_message(team_id team, int32 code) 19 { 20 BPrivate::DesktopLink link; 21 22 status_t status = link.InitCheck(); 23 if (status != B_OK) 24 return status; 25 26 // prepare the message 27 status = link.StartMessage(code); 28 if (status != B_OK) 29 return status; 30 31 status = link.Attach(team); 32 if (status != B_OK) 33 return status; 34 35 // send it 36 return link.Flush(); 37 } 38 39 40 void 41 usage() 42 { 43 fprintf(stderr, "usage: %s -[ab] <team-id> [...]\n", __progname); 44 exit(1); 45 } 46 47 48 int 49 main(int argc, char** argv) 50 { 51 if (argc == 1) 52 usage(); 53 54 bool dumpAllocator = false; 55 bool dumpBitmaps = false; 56 57 int32 i = 1; 58 while (argv[i][0] == '-') { 59 const char* arg = &argv[i][1]; 60 while (arg[0]) { 61 if (arg[0] == 'a') 62 dumpAllocator = true; 63 else if (arg[0] == 'b') 64 dumpBitmaps = true; 65 else 66 usage(); 67 68 arg++; 69 } 70 i++; 71 } 72 73 for (int32 i = 1; i < argc; i++) { 74 team_id team = atoi(argv[i]); 75 if (team <= 0) 76 continue; 77 78 if (dumpAllocator) 79 send_debug_message(team, AS_DUMP_ALLOCATOR); 80 if (dumpBitmaps) 81 send_debug_message(team, AS_DUMP_BITMAPS); 82 } 83 84 return 0; 85 } 86