git-svn-id: svn://db.shs.com.ru/libs@559 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-06-23 09:54:44 +00:00
parent 25fea9b21a
commit 385bf61d96
3 changed files with 30 additions and 180 deletions

View File

@@ -7,31 +7,6 @@
#include "pichunkstream.h"
#include "ccm_piintrospector.h"
#include <cxxabi.h>
const QString demangle(const char * name) {
int status = -4;
char * res = abi::__cxa_demangle(name, NULL, NULL, &status);
QString ret((status == 0) ? res : name);
free(res);
return ret;
}
enum ColumnContainers {
ccType,
ccCount,
ccItems,
ccBytesAllocated,
ccBytesUsed,
};
enum ColumnObjects {
coClassName,
coName,
coParents,
coQueuedEvents,
};
QPIIntrospector::QPIIntrospector(QWidget * parent): EMainWindow(parent), peer("__introspection_client__") {
setupUi(this);
@@ -48,16 +23,19 @@ QPIIntrospector::QPIIntrospector(QWidget * parent): EMainWindow(parent), peer("_
CONNECTU(&peer, peerConnectedEvent, this, reqProcPIEvents);
CONNECTU(&peer, peerDisconnectedEvent, this, reqProcPIEvents);
CONNECTU(&peer, dataReceivedEvent, this, reqProcPIEvents);
session.addEntry(this);
session.addEntry(tabWidgetMain);
PICodeInfo::EnumInfo * ei = PICodeInfo::enumsInfo->value("PIIntrospection::InfoTypes");
if (ei) {
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members) {
QCheckBox * cb = new QCheckBox(PI2QString(e.name.mid(2)));
cb->setObjectName(QString("checkRequest%1").arg(e.value));
cb->setProperty("__value__", e.value);
layoutRequestFlags->addWidget(cb);
session.addEntry(cb);
}
}
//startTimer(100);
session.addEntry(this);
session.load();
peer.start();
}
@@ -123,53 +101,13 @@ void QPIIntrospector::showInfo(const PIIntrospection::ProcessInfo & info) {
}
void QPIIntrospector::showContainers(const PIMap<uint, PIIntrospectionContainers::Type> & data, const PIMap<uint, PIString> & typenames) {
int vpos = treeContainers->verticalScrollBar()->value();
treeContainers->clear();
for (auto i = data.constBegin(); i != data.constEnd(); ++i) {
QTreeWidgetItem * ti = new QTreeWidgetItem();
ti->setText(ccType, demangle(typenames.value(i.key(), PIString::fromNumber(i.key())).dataAscii()));
ti->setText(ccCount, QString::number(i.value().count));
ti->setText(ccItems, QString::number(i.value().items));
ti->setText(ccBytesAllocated, PI2QString(PIString::readableSize(i.value().bytes_allocated)));
ti->setText(ccBytesUsed, PI2QString(PIString::readableSize(i.value().bytes_used)));
treeContainers->addTopLevelItem(ti);
}
treeContainers->verticalScrollBar()->setValue(vpos);
}
void QPIIntrospector::showObjects(const PIVector<PIIntrospection::ObjectInfo> & objects) {
QHash<QString, int> stat;
int vpos = treeObjects->verticalScrollBar()->value();
treeObjects->clear();
piForeachC (PIIntrospection::ObjectInfo & i, objects) {
stat[PI2QString(i.classname)]++;
QTreeWidgetItem * ti = new QTreeWidgetItem();
ti->setText(coClassName, PI2QString(i.classname));
ti->setText(coName, PI2QString(i.name));
ti->setText(coParents, PI2QString(i.parents.join(":")));
ti->setText(coQueuedEvents, QString::number(i.queued_events));
treeObjects->addTopLevelItem(ti);
}
treeObjects->verticalScrollBar()->setValue(vpos);
vpos = treeObjectsStat->verticalScrollBar()->value();
treeObjectsStat->clear();
for (auto i = stat.constBegin(); i != stat.constEnd(); ++i) {
QTreeWidgetItem * ti = new QTreeWidgetItem();
ti->setText(0, i.key());
ti->setText(1, QString::number(i.value()));
treeObjectsStat->addTopLevelItem(ti);
}
treeObjectsStat->verticalScrollBar()->setValue(vpos);
}
void QPIIntrospector::on_listApp_currentRowChanged(int r) {
if (r < 0) cur_server.clear();
else cur_server = Q2PIString(listApp->item(r)->text());
PIString cs;
if (r < 0) cs.clear();
else cs = Q2PIString(listApp->item(r)->text());
if (cur_server != cs)
widgetContainers->clear();
cur_server = cs;
}
@@ -195,13 +133,13 @@ void QPIIntrospector::peerReceived(const PIString & from, const PIByteArray & da
PIMap<uint, PIIntrospectionContainers::Type> data;
PIMap<uint, PIString> typenames;
PIIntrospection::unpackContainers(pba, data, typenames);
showContainers(data, typenames);
widgetContainers->showContainers(data, typenames);
} break;
case 4: {
cs.get(pba);
PIVector<PIIntrospection::ObjectInfo> objects;
PIIntrospection::unpackObjects(pba, objects);
showObjects(objects);
widgetObjects->showObjects(objects);
} break;
default: break;
}

View File

@@ -25,8 +25,6 @@ protected:
void buildDumpSection(QTreeWidgetItem * pi, PIString & str);
void showInfo(const PIIntrospection::ProcessInfo & info);
void showContainers(const PIMap<uint, PIIntrospectionContainers::Type> & data, const PIMap<uint, PIString> & typenames);
void showObjects(const PIVector<PIIntrospection::ObjectInfo> & objects);
EVENT_HANDLER(void, reqProcPIEvents) {QMetaObject::invokeMethod(this, "procPIEvents", Qt::QueuedConnection);}

View File

@@ -122,9 +122,9 @@
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<widget class="QTabWidget" name="tabWidgetMain">
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -149,39 +149,7 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTreeWidget" name="treeContainers">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<column>
<property name="text">
<string>type</string>
</property>
</column>
<column>
<property name="text">
<string>count</string>
</property>
</column>
<column>
<property name="text">
<string>items</string>
</property>
</column>
<column>
<property name="text">
<string>bytes_allocated</string>
</property>
</column>
<column>
<property name="text">
<string>bytes_used</string>
</property>
</column>
</widget>
<widget class="ContainersView" name="widgetContainers" native="true"/>
</item>
</layout>
</widget>
@@ -191,75 +159,7 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>List</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QTreeWidget" name="treeObjects">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<column>
<property name="text">
<string>class</string>
</property>
</column>
<column>
<property name="text">
<string>name</string>
</property>
</column>
<column>
<property name="text">
<string>parents</string>
</property>
</column>
<column>
<property name="text">
<string>queued_events</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>Statictic</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QTreeWidget" name="treeObjectsStat">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<column>
<property name="text">
<string>class</string>
</property>
</column>
<column>
<property name="text">
<string>count</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="ObjectsView" name="widgetObjects" native="true"/>
</item>
</layout>
</widget>
@@ -277,6 +177,20 @@
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>ObjectsView</class>
<extends>QWidget</extends>
<header>objects_view.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ContainersView</class>
<extends>QWidget</extends>
<header>containers_view.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>