Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
AvalonWot committed Aug 25, 2014
2 parents 64692bd + 172da2a commit ebbfbcb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
22 changes: 15 additions & 7 deletions gui/xmono.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,28 +224,36 @@ def _clearFuncCntTableWidget(self):
def _traceCntShow(self, d):
self._clearFuncCntTableWidget()
w = self.ui.funcCntTableWidget
w.setColumnCount(2)
w.setColumnCount(3)
labels = QtCore.QStringList()
labels.append("")
labels.append("function")
labels.append("count")
w.setHorizontalHeaderLabels(labels)
w.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.Stretch)
w.horizontalHeader().setResizeMode(1, QtGui.QHeaderView.Stretch)
w.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.ResizeToContents)
w.verticalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents)
w.horizontalHeader().show()
w.verticalHeader().hide()
for k in d.keys():
row = w.rowCount()
w.insertRow(row)
w.setItem(row, 0, QtGui.QTableWidgetItem(k))
#设置序数
v = QtGui.QTableWidgetItem()
v.setData(0, d[k])
w.setItem(row, 1, v)
w.sortItems(1, QtCore.Qt.AscendingOrder)
v.setData(0, d[k][1])
w.setItem(row, 0, v)
#设置函数名
w.setItem(row, 1, QtGui.QTableWidgetItem(k))
#设置调用次数
v = QtGui.QTableWidgetItem()
v.setData(0, d[k][0]) #这里用setData是为了方便排序
w.setItem(row, 2, v)
w.sortItems(0, QtCore.Qt.AscendingOrder)

def _traceCntHandle(self, l):
for i in l:
item = i.split('|')
self._traceFuncCntDict[item[0]] = int(item[1])
self._traceFuncCntDict[item[0]] = (int(item[1]), int(item[2]))
self._funcTraceCntFilteShow()

def _recvFuncTrace(self, packet):
Expand Down
29 changes: 20 additions & 9 deletions jni/xmono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,23 @@ static char const *disil_method (MonoMethod *method) {
return mono_disasm_code (0, method, code, code + len);
}

static void send_trace_log (std::map<MonoMethod*, int> const &dict) {
struct CallInfo{
CallInfo () : order(0), times(0){}
uint32_t order;
uint32_t times;
};

static void send_trace_log (std::map<MonoMethod*, CallInfo> const &dict) {
MemWriter sbuf(0x100000);
MemWriter writer(0x100000);
std::map<MonoMethod*, int>::const_iterator p;
std::map<MonoMethod*, CallInfo>::const_iterator p;
for (p = dict.begin (); p != dict.end (); p++) {
MonoMethod *method = p->first;
int count = p->second;
CallInfo call_info = p->second;
char const *m = get_method_image_name (method);
char *n = mono_method_full_name (method, 0);
char str[256];
sbuf.sprintf ("[%s] %s [%08X]|%d\n", m, n, mono_method_get_token (method), count);
sbuf.sprintf ("[%s] %s [%08X]|%d|%d\n", m, n, mono_method_get_token (method), call_info.times, call_info.order);
g_free (n);
}
if (!compress_data (sbuf.getBuffPtr (), sbuf.getBuffSize (), &writer)) {
Expand All @@ -338,19 +344,24 @@ static void send_trace_log (std::map<MonoMethod*, int> const &dict) {
pthread_mutex_t trace_list_mutex = PTHREAD_MUTEX_INITIALIZER;
static void func_trace (MonoMethod *method) {
pthread_mutex_lock (&trace_list_mutex);
static std::map<MonoMethod*, int>trace_log;
static std::map<MonoMethod*, CallInfo>trace_log;
static uint32_t order = 0;
if (trace_switch == false) {
order = 0;
if (!trace_log.empty ()) {
send_trace_log (trace_log);
trace_log.clear ();
}
pthread_mutex_unlock (&trace_list_mutex);
return; /*Fixme : 这个地方再考虑, 重复代码*/
}
if (trace_log.find (method) != trace_log.end ())
trace_log[method] += 1;
else
trace_log[method] = 1;
if (trace_log.find (method) != trace_log.end ()) {
trace_log[method].times += 1;
} else {
trace_log[method] = CallInfo ();
trace_log[method].order = order++;
trace_log[method].times = 1;
}
pthread_mutex_unlock (&trace_list_mutex);
return;
}
Expand Down

0 comments on commit ebbfbcb

Please sign in to comment.