# j_server.h

Go to the documentation of this file.

    00001 ///
    00002 /// \file       j_server.h
    00003 ///             Java Debug server classes
    00004 ///
    00005
    00006 /*
    00007     Copyright (C) 2009, Nicolas VIVIEN
    00008
    00009     This program is free software; you can redistribute it and/or modify
    00010     it under the terms of the GNU General Public License as published by
    00011     the Free Software Foundation; either version 2 of the License, or
    00012     (at your option) any later version.
    00013
    00014     This program is distributed in the hope that it will be useful,
    00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00017
    00018     See the GNU General Public License in the COPYING file at the
    00019     root directory of this project for more details.
    00020 */
    00021
    00022 #ifndef __BARRYJDWP_SERVER_H__
    00023 #define __BARRYJDWP_SERVER_H__
    00024
    00025 #include "dll.h"
    00026 #include "j_manager.h"
    00027 #include "dp_codinfo.h"
    00028 #include "m_jvmdebug.h"
    00029 #include "threadwrap.h"
    00030 #include <string>
    00031 #include <memory>
    00032
    00033
    00034 namespace Barry { namespace JDWP {
    00035
    00036 class BXEXPORT JDWServer
    00037 {
    00038 public:
    00039         typedef void (*ConsoleCallbackType)(const std::string &);
    00040
    00041 private:
    00042         Barry::Mode::JVMDebug *jvmdebug;
    00043
    00044         int acceptfd;
    00045         int sockfd;
    00046
    00047         std::string address;
    00048         int port;
    00049
    00050         bool loop;
    00051         bool targetrunning;
    00052
    00053         std::string password;
    00054
    00055         Barry::JVMModulesList modulesList;                              // List of COD applications installed on the device
    00056         Barry::JDG::DebugFileList debugFileList;                // List of debug file on the host
    00057
    00058         JDWAppList appList;                                                             // List of BlackBerry application (an application contents several COD files)
    00059         Barry::JDG::ClassList visibleClassList;         // Visible class list from JDB
    00060
    00061         std::auto_ptr<Thread> handler;
    00062         ConsoleCallbackType printConsoleMessage;
    00063
    00064         void CommandsetProcess(Barry::Data &cmd);
    00065
    00066         void CommandsetVirtualMachineProcess(Barry::Data &cmd);
    00067         void CommandsetEventRequestProcess(Barry::Data &cmd);
    00068
    00069         void CommandVersion(Barry::Data &cmd);
    00070         void CommandIdSizes(Barry::Data &cmd);
    00071         void CommandAllClasses(Barry::Data &cmd);
    00072         void CommandAllThreads(Barry::Data &cmd);
    00073         void CommandSuspend(Barry::Data &cmd);
    00074         void CommandResume(Barry::Data &cmd);
    00075         void CommandClassPaths(Barry::Data &cmd);
    00076
    00077         void CommandSet(Barry::Data &cmd);
    00078
    00079 //      void BackgroundDeviceProcess();
    00080
    00081 protected:
    00082
    00083 public:
    00084         JDWServer(Barry::Mode::JVMDebug &device, const char *address, int port);
    00085         ~JDWServer();
    00086
    00087         void SetPasswordDevice(std::string password);
    00088
    00089         void SetConsoleCallback(ConsoleCallbackType callback);
    00090
    00091         bool Start();           // starts new thread
    00092         bool AcceptConnection();
    00093         bool AttachToDevice();
    00094         bool InitVisibleClassList();
    00095         bool Hello();
    00096         void Run();
    00097         void DetachFromDevice();
    00098         bool Stop();            // cancels thread if still running, and
    00099                                 // cleans up Start()
    00100 };
    00101
    00102 }} // namespace Barry::JDWP
    00103
    00104 #endif
    00105