diff --git a/gui/xmono.py b/gui/xmono.py index eb470cd..2124755 100644 --- a/gui/xmono.py +++ b/gui/xmono.py @@ -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): diff --git a/jni/xmono.cpp b/jni/xmono.cpp index 0c59dc5..22cbba9 100644 --- a/jni/xmono.cpp +++ b/jni/xmono.cpp @@ -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 const &dict) { +struct CallInfo{ + CallInfo () : order(0), times(0){} + uint32_t order; + uint32_t times; +}; + +static void send_trace_log (std::map const &dict) { MemWriter sbuf(0x100000); MemWriter writer(0x100000); - std::map::const_iterator p; + std::map::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)) { @@ -338,8 +344,10 @@ static void send_trace_log (std::map 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::maptrace_log; + static std::maptrace_log; + static uint32_t order = 0; if (trace_switch == false) { + order = 0; if (!trace_log.empty ()) { send_trace_log (trace_log); trace_log.clear (); @@ -347,10 +355,13 @@ static void func_trace (MonoMethod *method) { 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; }