headers/bsd: Add sys/queue.h.
[haiku.git] / src / tests / servers / app / app_server_debug.cpp
blob487b41351f1bb861fad63c01a1e708e38348baae
1 /*
2 * Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <DesktopLink.h>
8 #include <ServerProtocol.h>
10 #include <stdio.h>
11 #include <stdlib.h>
14 extern const char* __progname;
17 status_t
18 send_debug_message(team_id team, int32 code)
20 BPrivate::DesktopLink link;
22 status_t status = link.InitCheck();
23 if (status != B_OK)
24 return status;
26 // prepare the message
27 status = link.StartMessage(code);
28 if (status != B_OK)
29 return status;
31 status = link.Attach(team);
32 if (status != B_OK)
33 return status;
35 // send it
36 return link.Flush();
40 void
41 usage()
43 fprintf(stderr, "usage: %s -[ab] <team-id> [...]\n", __progname);
44 exit(1);
48 int
49 main(int argc, char** argv)
51 if (argc == 1)
52 usage();
54 bool dumpAllocator = false;
55 bool dumpBitmaps = false;
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();
68 arg++;
70 i++;
73 for (int32 i = 1; i < argc; i++) {
74 team_id team = atoi(argv[i]);
75 if (team <= 0)
76 continue;
78 if (dumpAllocator)
79 send_debug_message(team, AS_DUMP_ALLOCATOR);
80 if (dumpBitmaps)
81 send_debug_message(team, AS_DUMP_BITMAPS);
84 return 0;