javacommons/jvms/j9utils/threaddump/inc/threaddumper.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Thread dump server of J9 VM in S60,
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef THREADDUMPER_H
       
    20 #define THREADDUMPER_H
       
    21 
       
    22 #include <memory>
       
    23 #include <memory.h>
       
    24 
       
    25 #include "logger.h"
       
    26 #include "dynamiclibloader.h"
       
    27 
       
    28 namespace java
       
    29 {
       
    30 namespace util
       
    31 {
       
    32 
       
    33 class ThreadDump
       
    34 {
       
    35 public:
       
    36     static void doDump();
       
    37     static void closeDumper();
       
    38 };
       
    39 
       
    40 } // namespace util
       
    41 } // namespace java
       
    42 
       
    43 
       
    44 
       
    45 const char* const THREAD_DUMP_LIB = "javathreaddumper";
       
    46 
       
    47 // Keep this in sync with doThreadDump() method.
       
    48 typedef void (*DoThreadDump)();
       
    49 
       
    50 // Keep this in sync with closeThreadDump() method.
       
    51 typedef void (*CloseThreadDump)();
       
    52 
       
    53 
       
    54 
       
    55 //START OF INLINE METHODS
       
    56 
       
    57 inline void java::util::ThreadDump::doDump()
       
    58 {
       
    59     try
       
    60     {
       
    61         std::auto_ptr<java::util::DynamicLibLoader>loader
       
    62         (new DynamicLibLoader("javathreaddumper"));
       
    63         DoThreadDump doThreadDump =
       
    64             (DoThreadDump)loader->getFunction("doThreadDump");
       
    65         doThreadDump();
       
    66     }
       
    67     catch (...)
       
    68     {
       
    69         // Ignoring all exceptions
       
    70     }
       
    71 }
       
    72 
       
    73 inline void java::util::ThreadDump::closeDumper()
       
    74 {
       
    75     try
       
    76     {
       
    77         std::auto_ptr<java::util::DynamicLibLoader>loader
       
    78         (new DynamicLibLoader("javathreaddumper"));
       
    79         CloseThreadDump closeThreadDump =
       
    80             (CloseThreadDump)loader->getFunction("closeThreadDump");
       
    81         closeThreadDump();
       
    82     }
       
    83     catch (...)
       
    84     {
       
    85         // Ignoring all exceptions
       
    86     }
       
    87 }
       
    88 
       
    89 #endif // THREADDUMPER_H