git-svn-id: svn://db.shs.com.ru/pip@186 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -35,7 +35,8 @@ option(ICU "Unicode support" 1)
|
||||
option(USB "USB support" 0)
|
||||
option(STL "Building with STL containers" 0)
|
||||
option(CRYPT "Crypt support" 0)
|
||||
option(INTROSPECTION "Build with introspection" 1)
|
||||
option(INTROSPECTION_CONTAINERS "Build with containers introspection" 0)
|
||||
option(INTROSPECTION_THREADS "Build with threads introspection" 0)
|
||||
option(LIB "System install" 1)
|
||||
option(DEBUG "Build with -g3" 0)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
@@ -141,13 +142,21 @@ else ()
|
||||
endif ()
|
||||
|
||||
|
||||
# Check if PIP should be built with introspection
|
||||
if (INTROSPECTION)
|
||||
message(STATUS "Building with introspection")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_INTROSPECTION")
|
||||
list(APPEND LIBS sodium)
|
||||
# Check if PIP should be built with containers introspection
|
||||
if (INTROSPECTION_CONTAINERS)
|
||||
message(STATUS "Building with containers introspection")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_INTROSPECTION_CONTAINERS")
|
||||
else ()
|
||||
message(STATUS "Building without introspection")
|
||||
message(STATUS "Building without containers introspection")
|
||||
endif ()
|
||||
|
||||
|
||||
# Check if PIP should be built with threads introspection
|
||||
if (INTROSPECTION_THREADS)
|
||||
message(STATUS "Building with threads introspection")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_INTROSPECTION_THREADS")
|
||||
else ()
|
||||
message(STATUS "Building without threads introspection")
|
||||
endif ()
|
||||
|
||||
|
||||
|
||||
7
main.cpp
7
main.cpp
@@ -9,8 +9,13 @@
|
||||
|
||||
int main (int argc, char * argv[]) {
|
||||
//PIByteArray ba;
|
||||
PIKbdListener kbd;
|
||||
kbd.enableExitCapture();
|
||||
PIString str;
|
||||
piCout << PIINTROSPECTION_CONTAINERS->count;
|
||||
str.reserve(1024*1024);
|
||||
PIINTROSPECTION_START
|
||||
//piCout << PIINTROSPECTION_CONTAINERS->count;
|
||||
WAIT_FOR_EXIT
|
||||
/*PIVector<PIVariant> vl;
|
||||
vl << PIVariant('2') << PIVariant(-5.5) << PIVariant(10) << PIVariant(complexd(2,3)) << PIVariant("text") << PIVariant(PIByteArray("bytearray", 9)) << PIVariant(PIDateTime::current());
|
||||
piForeachC (PIVariant v, vl)
|
||||
|
||||
@@ -295,7 +295,7 @@ public:
|
||||
PIDeque<T> & removeOne(const T & v) {for (size_t i = 0; i < pid_size; ++i) if (pid_data[i + pid_start] == v) {remove(i); return *this;} return *this;}
|
||||
PIDeque<T> & removeAll(const T & v) {for (llong i = 0; i < pid_size; ++i) if (pid_data[i + pid_start] == v) {remove(i); --i;} return *this;}
|
||||
|
||||
PIDeque<T> & push_back(const T & v) {alloc(pid_size + 1, true); elementNew(pid_data + pid_start + pid_size - 1, v); return *this;}
|
||||
PIDeque<T> & push_back(const T & v) {alloc(pid_size + 1, true); PIINTROSPECTION_CONTAINER_USED(sizeof(T)); elementNew(pid_data + pid_start + pid_size - 1, v); return *this;}
|
||||
PIDeque<T> & append(const T & v) {return push_back(v);}
|
||||
PIDeque<T> & operator <<(const T & v) {return push_back(v);}
|
||||
PIDeque<T> & operator <<(const PIDeque<T> & t) {
|
||||
@@ -462,8 +462,8 @@ private:
|
||||
};
|
||||
|
||||
#define __PIDEQUE_SIMPLE_TYPE__(T) \
|
||||
template<> inline void PIDeque<T>::newT(T * dst, const T * src, size_t s) {memcpy(dst, src, s * sizeof(T));} \
|
||||
template<> inline void PIDeque<T>::deleteT(T * d, size_t sz) {;} \
|
||||
template<> inline void PIDeque<T>::newT(T * dst, const T * src, size_t s) {PIINTROSPECTION_CONTAINER_USED(s*sizeof(T)); memcpy(dst, src, s * sizeof(T));} \
|
||||
template<> inline void PIDeque<T>::deleteT(T * d, size_t sz) {PIINTROSPECTION_CONTAINER_UNUSED(sz*sizeof(T));} \
|
||||
template<> inline void PIDeque<T>::elementNew(T * to, const T & from) {(*to) = from;} \
|
||||
template<> inline void PIDeque<T>::elementDelete(T & from) {;}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "pivector.h"
|
||||
#include "pideque.h"
|
||||
|
||||
class PIByteArray;
|
||||
|
||||
#if !defined(PIP_CONTAINERS_STL) || defined(DOXYGEN)
|
||||
|
||||
@@ -53,6 +54,8 @@ void piQuickSort(T * a, ssize_t N) {
|
||||
|
||||
template <typename Key, typename T>
|
||||
class PIMap {
|
||||
template <typename Key1, typename T1> friend PIByteArray & operator >>(PIByteArray & s, PIMap<Key1, T1> & v);
|
||||
template <typename Key1, typename T1> friend PIByteArray & operator <<(PIByteArray & s, const PIMap<Key1, T1> & v);
|
||||
public:
|
||||
PIMap() {;}
|
||||
PIMap(const PIMap<Key, T> & other) {*this = other;}
|
||||
@@ -244,7 +247,9 @@ protected:
|
||||
bool operator <(const MapIndex & s) const {return key < s.key;}
|
||||
bool operator >(const MapIndex & s) const {return key > s.key;}
|
||||
};
|
||||
|
||||
template <typename Key1, typename T1> friend PIByteArray & operator >>(PIByteArray & s, typename PIMap<Key1, T1>::MapIndex & v);
|
||||
template <typename Key1, typename T1> friend PIByteArray & operator <<(PIByteArray & s, const typename PIMap<Key1, T1>::MapIndex & v);
|
||||
|
||||
ssize_t binarySearch(ssize_t first, ssize_t last, const Key & key, bool & found) const {
|
||||
ssize_t mid;
|
||||
while (first <= last) {
|
||||
|
||||
Binary file not shown.
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "piintrospection.h"
|
||||
#include "pisysteminfo.h"
|
||||
|
||||
|
||||
PIIntrospectionContainers::PIIntrospectionContainers() {
|
||||
@@ -32,6 +33,7 @@ PIIntrospectionThreads::PIIntrospectionThreads() {
|
||||
|
||||
PIIntrospectionContainers * __PIIntrospectionContainers__::p = 0;
|
||||
PIIntrospectionThreads * __PIIntrospectionThreads__::p = 0;
|
||||
PIIntrospectionServer * __PIIntrospectionServer__::p = 0;
|
||||
|
||||
|
||||
void PIIntrospectionThreads::registerThread(int id, short prior, const PIString & name) {
|
||||
@@ -92,3 +94,25 @@ void PIIntrospectionContainers::containerUnused(ullong cnt) {
|
||||
bytes_used -= cnt;
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
PIIntrospectionServer::PIIntrospectionServer(): PIPeer(genName()) {
|
||||
CONNECTU(&timer, tickEvent, this, timerEvent)
|
||||
timer.start(100);
|
||||
}
|
||||
|
||||
|
||||
PIString PIIntrospectionServer::genName() {
|
||||
randomize();
|
||||
return "__introspection__server_" + PIString::fromNumber(rand() % 1000);
|
||||
}
|
||||
|
||||
|
||||
void PIIntrospectionServer::timerEvent() {
|
||||
PIByteArray ba;
|
||||
PIINTROSPECTION_THREADS->mutex.lock();
|
||||
ba << appname << *(PIINTROSPECTION_CONTAINERS) << PIINTROSPECTION_THREADS->threads.values();
|
||||
PIINTROSPECTION_THREADS->mutex.unlock();
|
||||
//piCout << "send" << appname;
|
||||
send("__introspection_client__", ba);
|
||||
}
|
||||
|
||||
@@ -20,15 +20,16 @@
|
||||
#ifndef PIINTROSPECTION_H
|
||||
#define PIINTROSPECTION_H
|
||||
|
||||
#include "pistring.h"
|
||||
#include "pipeer.h"
|
||||
#include "pimutex.h"
|
||||
|
||||
|
||||
class PIP_EXPORT PIIntrospectionThreads
|
||||
{
|
||||
friend class __PIIntrospectionThreads__;
|
||||
PIIntrospectionThreads();
|
||||
public:
|
||||
PIIntrospectionThreads();
|
||||
|
||||
struct ThreadInfo {
|
||||
ThreadInfo() {id = 0; priority = 0;}
|
||||
PIString name;
|
||||
@@ -47,8 +48,9 @@ public:
|
||||
class PIP_EXPORT PIIntrospectionContainers
|
||||
{
|
||||
friend class __PIIntrospectionContainers__;
|
||||
PIIntrospectionContainers();
|
||||
public:
|
||||
PIIntrospectionContainers();
|
||||
|
||||
void containerNew();
|
||||
void containerDelete();
|
||||
void containerAlloc(ullong cnt);
|
||||
@@ -63,6 +65,20 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class PIP_EXPORT PIIntrospectionServer: public PIPeer
|
||||
{
|
||||
PIOBJECT_SUBCLASS(PIIntrospectionServer, PIPeer)
|
||||
friend class __PIIntrospectionServer__;
|
||||
PIIntrospectionServer();
|
||||
public:
|
||||
PIString appname;
|
||||
private:
|
||||
EVENT_HANDLER(void, timerEvent);
|
||||
PIString genName();
|
||||
PITimer timer;
|
||||
};
|
||||
|
||||
|
||||
class __PIIntrospectionContainers__ {
|
||||
public:
|
||||
__PIIntrospectionContainers__() {if (!p) p = new PIIntrospectionContainers();}
|
||||
@@ -70,7 +86,6 @@ public:
|
||||
static PIIntrospectionContainers * p;
|
||||
};
|
||||
|
||||
|
||||
class __PIIntrospectionThreads__ {
|
||||
public:
|
||||
__PIIntrospectionThreads__() {if (!p) p = new PIIntrospectionThreads();}
|
||||
@@ -78,6 +93,15 @@ public:
|
||||
static PIIntrospectionThreads * p;
|
||||
};
|
||||
|
||||
class __PIIntrospectionServer__ {
|
||||
public:
|
||||
__PIIntrospectionServer__() {if (!p) p = new PIIntrospectionServer();}
|
||||
~__PIIntrospectionServer__() {if (!p) return; delete p; p = 0;}
|
||||
static PIIntrospectionServer * get() {static __PIIntrospectionServer__ * r = new __PIIntrospectionServer__(); return r->p;}
|
||||
static PIIntrospectionServer * p;
|
||||
};
|
||||
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & b, const PIIntrospectionContainers & v) {b << v.count << v.bytes_allocated << v.bytes_used; return b;}
|
||||
inline PIByteArray & operator <<(PIByteArray & b, const PIIntrospectionThreads::ThreadInfo & v) {b << v.id << v.priority << v.name; return b;}
|
||||
|
||||
@@ -86,5 +110,6 @@ inline PIByteArray & operator >>(PIByteArray & b, PIIntrospectionThreads::Thread
|
||||
|
||||
#define PIINTROSPECTION_CONTAINERS __PIIntrospectionContainers__::get()
|
||||
#define PIINTROSPECTION_THREADS __PIIntrospectionThreads__::get()
|
||||
#define PIINTROSPECTION_SERVER __PIIntrospectionServer__::get()
|
||||
|
||||
#endif // PIINTROSPECTION_H
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "piintrospection_proxy.h"
|
||||
#include "piintrospection.h"
|
||||
#include "pisysteminfo.h"
|
||||
|
||||
void __PIIntrospection__registerThread(int id, short prior, const PIString & name) {PIINTROSPECTION_THREADS->registerThread(id, prior, name);}
|
||||
void __PIIntrospection__unregisterThread(int id) {PIINTROSPECTION_THREADS->unregisterThread(id);}
|
||||
@@ -28,3 +29,4 @@ void __PIIntrospection__containerAlloc(ullong cnt) {PIINTROSPECTION_CONTAINERS->
|
||||
void __PIIntrospection__containerFree(ullong cnt) {PIINTROSPECTION_CONTAINERS->containerFree(cnt);}
|
||||
void __PIIntrospection__containerUsed(ullong cnt) {PIINTROSPECTION_CONTAINERS->containerUsed(cnt);}
|
||||
void __PIIntrospection__containerUnused(ullong cnt) {PIINTROSPECTION_CONTAINERS->containerUnused(cnt);}
|
||||
void __PIIntrospection__start() {PIINTROSPECTION_SERVER->appname = PISystemInfo::instance()->execCommand;}
|
||||
|
||||
@@ -32,16 +32,15 @@ void __PIIntrospection__containerAlloc(ullong cnt);
|
||||
void __PIIntrospection__containerFree(ullong cnt);
|
||||
void __PIIntrospection__containerUsed(ullong cnt);
|
||||
void __PIIntrospection__containerUnused(ullong cnt);
|
||||
void __PIIntrospection__start();
|
||||
|
||||
#ifdef PIP_INTROSPECTION
|
||||
#ifdef PIP_INTROSPECTION_CONTAINERS
|
||||
# define PIINTROSPECTION_CONTAINER_NEW() __PIIntrospection__containerNew();
|
||||
# define PIINTROSPECTION_CONTAINER_DELETE() __PIIntrospection__containerDelete();
|
||||
# define PIINTROSPECTION_CONTAINER_USED(cnt) __PIIntrospection__containerUsed(cnt);
|
||||
# define PIINTROSPECTION_CONTAINER_UNUSED(cnt) __PIIntrospection__containerUnused(cnt);
|
||||
# define PIINTROSPECTION_CONTAINER_ALLOC(cnt) __PIIntrospection__containerAlloc(cnt);
|
||||
# define PIINTROSPECTION_CONTAINER_FREE(cnt) __PIIntrospection__containerFree(cnt);
|
||||
# define PIINTROSPECTION_REGISTER_THREAD(id, pr, name) __PIIntrospection__registerThread(id, pr, name);
|
||||
# define PIINTROSPECTION_UNREGISTER_THREAD(id) __PIIntrospection__unregisterThread(id);
|
||||
#else
|
||||
# define PIINTROSPECTION_CONTAINER_NEW()
|
||||
# define PIINTROSPECTION_CONTAINER_DELETE()
|
||||
@@ -49,8 +48,22 @@ void __PIIntrospection__containerUnused(ullong cnt);
|
||||
# define PIINTROSPECTION_CONTAINER_UNUSED(cnt)
|
||||
# define PIINTROSPECTION_CONTAINER_ALLOC(cnt)
|
||||
# define PIINTROSPECTION_CONTAINER_FREE(cnt)
|
||||
#endif
|
||||
|
||||
#ifdef PIP_INTROSPECTION_THREADS
|
||||
# define PIINTROSPECTION_REGISTER_THREAD(id, pr, name) __PIIntrospection__registerThread(id, pr, name);
|
||||
# define PIINTROSPECTION_UNREGISTER_THREAD(id) __PIIntrospection__unregisterThread(id);
|
||||
# define PIINTROSPECTION_START __PIIntrospection__start();
|
||||
#else
|
||||
# define PIINTROSPECTION_REGISTER_THREAD(id, pr, name)
|
||||
# define PIINTROSPECTION_UNREGISTER_THREAD(id)
|
||||
# define PIINTROSPECTION_START
|
||||
#endif
|
||||
|
||||
#if defined(PIP_INTROSPECTION_CONTAINERS) || defined(PIP_INTROSPECTION_THREADS)
|
||||
# define PIINTROSPECTION_START __PIIntrospection__start();
|
||||
#else
|
||||
# define PIINTROSPECTION_START
|
||||
#endif
|
||||
|
||||
#endif // PIINTROSPECTION_PROXY_H
|
||||
|
||||
@@ -213,6 +213,7 @@ public:
|
||||
int main(int argc, char * argv[]) {
|
||||
//piDebug = false;
|
||||
PICLI cli(argc, argv);
|
||||
PIINTROSPECTION_START
|
||||
//cli.addArgument("");
|
||||
sys_mon.startOnSelf();
|
||||
screen.enableExitCapture(PIKbdListener::F10);
|
||||
|
||||
@@ -100,6 +100,7 @@ void usage() {
|
||||
|
||||
int main (int argc, char * argv[]) {
|
||||
PICLI cli(argc, argv);
|
||||
PIINTROSPECTION_START
|
||||
cli.setOptionalArgumentsCount(-1);
|
||||
cli.addArgument("send", true);
|
||||
cli.addArgument("receive", true);
|
||||
|
||||
Reference in New Issue
Block a user