[haiku-commits] r39441 - in haiku/trunk: headers/private/app src/servers/app src/tests/servers/app

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 15 Nov 2010 22:25:04 +0100 (CET)

Author: axeld
Date: 2010-11-15 22:25:03 +0100 (Mon, 15 Nov 2010)
New Revision: 39441
Changeset: http://dev.haiku-os.org/changeset/39441

Added:
   haiku/trunk/src/tests/servers/app/app_server_debug.cpp
Modified:
   haiku/trunk/headers/private/app/ServerProtocol.h
   haiku/trunk/src/servers/app/ClientMemoryAllocator.cpp
   haiku/trunk/src/servers/app/ClientMemoryAllocator.h
   haiku/trunk/src/servers/app/Desktop.cpp
   haiku/trunk/src/servers/app/ServerApp.cpp
   haiku/trunk/src/tests/servers/app/Jamfile
Log:
* Added AS_DUMP_ALLOCATOR command that dumps an applications memory allocator to
  the syslog/serial output.
* Added app_server_debug command that currently just sends this command to the
  specified teams.


Modified: haiku/trunk/headers/private/app/ServerProtocol.h
===================================================================
--- haiku/trunk/headers/private/app/ServerProtocol.h    2010-11-15 21:23:38 UTC 
(rev 39440)
+++ haiku/trunk/headers/private/app/ServerProtocol.h    2010-11-15 21:25:03 UTC 
(rev 39441)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2009, Haiku.
+ * Copyright 2001-2010, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -81,7 +81,7 @@
 
        AS_BEGIN_RECT_TRACKING,
        AS_END_RECT_TRACKING,
-       
+
        AS_GET_CURSOR_POSITION,
        AS_GET_CURSOR_BITMAP,
 
@@ -336,6 +336,9 @@
        // desktop listener communications
        AS_TALK_TO_DESKTOP_LISTENER,
 
+       // debugging helper
+       AS_DUMP_ALLOCATOR,
+
        AS_LAST_CODE
 };
 

Modified: haiku/trunk/src/servers/app/ClientMemoryAllocator.cpp
===================================================================
--- haiku/trunk/src/servers/app/ClientMemoryAllocator.cpp       2010-11-15 
21:23:38 UTC (rev 39440)
+++ haiku/trunk/src/servers/app/ClientMemoryAllocator.cpp       2010-11-15 
21:25:03 UTC (rev 39441)
@@ -211,6 +211,32 @@
 }
 
 
+void
+ClientMemoryAllocator::Dump()
+{
+       AutoReadLocker locker(fLock);
+
+       debug_printf("Application %ld, %s: chunks:\n", 
fApplication->ClientTeam(),
+               fApplication->Signature());
+
+       chunk_list::Iterator iterator = fChunks.GetIterator();
+       int32 i = 0;
+       while (struct chunk* chunk = iterator.Next()) {
+               debug_printf("  [%4ld] %p, area %ld, base %p, size %lu\n", i++, 
chunk,
+                       chunk->area, chunk->base, chunk->size);
+       }
+
+       debug_printf("free blocks:\n");
+
+       block_list::Iterator blockIterator = fFreeBlocks.GetIterator();
+       i = 0;
+       while (struct block* block = blockIterator.Next()) {
+               debug_printf("  [%6ld] %p, chunk %p, base %p, size %lu\n", i++, 
block,
+                       block->chunk, block->base, block->size);
+       }
+}
+
+
 struct block *
 ClientMemoryAllocator::_AllocateChunk(size_t size, bool& newArea)
 {

Modified: haiku/trunk/src/servers/app/ClientMemoryAllocator.h
===================================================================
--- haiku/trunk/src/servers/app/ClientMemoryAllocator.h 2010-11-15 21:23:38 UTC 
(rev 39440)
+++ haiku/trunk/src/servers/app/ClientMemoryAllocator.h 2010-11-15 21:25:03 UTC 
(rev 39441)
@@ -51,6 +51,8 @@
                        bool                            Lock();
                        void                            Unlock();
 
+                       void                            Dump();
+
 private:
                        struct block*           _AllocateChunk(size_t size, 
bool& newArea);
 

Modified: haiku/trunk/src/servers/app/Desktop.cpp
===================================================================
--- haiku/trunk/src/servers/app/Desktop.cpp     2010-11-15 21:23:38 UTC (rev 
39440)
+++ haiku/trunk/src/servers/app/Desktop.cpp     2010-11-15 21:25:03 UTC (rev 
39441)
@@ -2265,7 +2265,7 @@
 
 
 void
-Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
+Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
 {
        switch (code) {
                case AS_CREATE_APP:
@@ -2285,7 +2285,7 @@
                        port_id clientLooperPort = -1;
                        port_id clientReplyPort = -1;
                        int32 htoken = B_NULL_TOKEN;
-                       char *appSignature = NULL;
+                       char* appSignature = NULL;
 
                        link.Read<port_id>(&clientReplyPort);
                        link.Read<port_id>(&clientLooperPort);
@@ -2294,7 +2294,7 @@
                        if (link.ReadString(&appSignature) != B_OK)
                                break;
 
-                       ServerApp *app = new ServerApp(this, clientReplyPort,
+                       ServerApp* app = new ServerApp(this, clientReplyPort,
                                clientLooperPort, clientTeamID, htoken, 
appSignature);
                        if (app->InitCheck() == B_OK
                                && app->Run()) {
@@ -2334,10 +2334,10 @@
                        // Run through the list of apps and nuke the proper one
 
                        int32 count = fApplications.CountItems();
-                       ServerApp *removeApp = NULL;
+                       ServerApp* removeApp = NULL;
 
                        for (int32 i = 0; i < count; i++) {
-                               ServerApp *app = fApplications.ItemAt(i);
+                               ServerApp* app = fApplications.ItemAt(i);
 
                                if (app->Thread() == thread) {
                                        fApplications.RemoveItemAt(i);
@@ -2387,6 +2387,7 @@
                }
 
                case AS_APP_CRASHED:
+               case AS_DUMP_ALLOCATOR:
                {
                        BAutolock locker(fApplicationsLock);
 
@@ -2398,7 +2399,7 @@
                                ServerApp* app = fApplications.ItemAt(i);
 
                                if (app->ClientTeam() == team)
-                                       app->PostMessage(AS_APP_CRASHED);
+                                       app->PostMessage(code);
                        }
                        break;
                }

Modified: haiku/trunk/src/servers/app/ServerApp.cpp
===================================================================
--- haiku/trunk/src/servers/app/ServerApp.cpp   2010-11-15 21:23:38 UTC (rev 
39440)
+++ haiku/trunk/src/servers/app/ServerApp.cpp   2010-11-15 21:25:03 UTC (rev 
39441)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2009, Haiku.
+ * Copyright 2001-2010, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -545,6 +545,10 @@
                        }
                        break;
 
+               case AS_DUMP_ALLOCATOR:
+                       fMemoryAllocator.Dump();
+                       break;
+
                case AS_CREATE_WINDOW:
                case AS_CREATE_OFFSCREEN_WINDOW:
                {

Modified: haiku/trunk/src/tests/servers/app/Jamfile
===================================================================
--- haiku/trunk/src/tests/servers/app/Jamfile   2010-11-15 21:23:38 UTC (rev 
39440)
+++ haiku/trunk/src/tests/servers/app/Jamfile   2010-11-15 21:25:03 UTC (rev 
39441)
@@ -1,12 +1,18 @@
 SubDir HAIKU_TOP src tests servers app ;
 
+UsePrivateHeaders app graphics input interface shared storage ;
+
+SimpleTest app_server_debug :
+       app_server_debug.cpp
+       : be
+;
+
 SetSubDirSupportedPlatforms libbe_test ;
 
 # No need to define any of those targets, when not building for libbe_test
 if $(TARGET_PLATFORM) = libbe_test {
 
 UseLibraryHeaders agg png zlib ;
-UsePrivateHeaders app graphics input interface shared storage ;
 UsePrivateHeaders [ FDirName graphics common ] ;
 
 # headers/build/private/kernel is needed for safemode.h and syscalls.h.

Added: haiku/trunk/src/tests/servers/app/app_server_debug.cpp
===================================================================
--- haiku/trunk/src/tests/servers/app/app_server_debug.cpp                      
        (rev 0)
+++ haiku/trunk/src/tests/servers/app/app_server_debug.cpp      2010-11-15 
21:25:03 UTC (rev 39441)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include <DesktopLink.h>
+#include <ServerProtocol.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+extern const char* __progname;
+
+
+status_t
+send_debug_message(team_id team, int32 code)
+{
+       BPrivate::DesktopLink link;
+
+       status_t status = link.InitCheck();
+       if (status != B_OK)
+               return status;
+
+       // prepare the message
+       status = link.StartMessage(code);
+       if (status != B_OK)
+               return status;
+
+       status = link.Attach(team);
+       if (status != B_OK)
+               return status;
+
+       // send it
+       return link.Flush();
+}
+
+
+int
+main(int argc, char** argv)
+{
+       if (argc == 1) {
+               fprintf(stderr, "usage: %s <team-id> [...]\n", __progname);
+               return 1;
+       }
+
+       for (int32 i = 1; i < argc; i++) {
+               team_id team = atoi(argv[i]);
+               if (team > 0)
+                       send_debug_message(team, AS_DUMP_ALLOCATOR);
+       }
+
+       return 0;
+}


Other related posts:

  • » [haiku-commits] r39441 - in haiku/trunk: headers/private/app src/servers/app src/tests/servers/app - axeld