[kgtp] r982 committed - Add lib name to output of hotcode.py

  • From: kgtp@xxxxxxxxxxxxxx
  • To: kgtp@xxxxxxxxxxxxx
  • Date: Mon, 19 Mar 2012 07:09:56 +0000

Revision: 982
Author:   teawater
Date:     Mon Mar 19 00:09:24 2012
Log:      Add lib name to output of hotcode.py

http://code.google.com/p/kgtp/source/detail?r=982

Modified:
 /trunk/add-ons/hotcode.py

=======================================
--- /trunk/add-ons/hotcode.py   Sun Mar 18 19:37:29 2012
+++ /trunk/add-ons/hotcode.py   Mon Mar 19 00:09:24 2012
@@ -109,7 +109,7 @@
        else:
                code_list[1][info[1]] = 1
        #line_list
-       line = info[1]+":"+info[0]
+       line = str(info[1]) + ":" + str(info[0])
        if line in code_list[2]:
                code_list[2][line] += 1
        else:
@@ -514,8 +514,8 @@
        #Get line_num and file_name
        begin = sym.find("Line ")
        end = sym.find("\" starts at address")
-       line_num = "Unknow"
-       file_name = "Unknow"
+       line_num = None
+       file_name = None
        if begin >= 0 and end > 0 and begin + len("Line ") < end:
                line = sym[begin + len("Line "):end]
                line = line.split(" of \"")
@@ -532,8 +532,13 @@
                end = function_name.rfind("+")
                if end > 0:
                        function_name = function_name[:end]
+ sym = gdb.execute("info symbol "+function_name, True, True).rstrip(os.linesep)
+               begin = sym.rfind(" of ")
+               if begin > 0:
+                       begin += len(" of ")
+                       function_name = sym[begin:] + ":" + function_name
        else:
-               function_name = "Unknow"
+               function_name = None
        return (line_num, file_name, function_name)

 if no_task:
@@ -562,21 +567,21 @@
raise gdb.error ("Cannot find inferior for pid "+ str(pid) +", drop one entry.")
                        if trace_user and long(gdb.parse_and_eval("regs->cs & 
3")) == 3:
                                is_user = True
-                               if task_list[pid][0] == 0:
-                                       sym = ""
-                               else:
-                                       ip = long(gdb.parse_and_eval("regs->ip - 
1"))
-                                       gdb.execute("inferior 
"+str(task_list[pid][0]), False, True)
-                                       sym = gdb.execute("info line 
*"+str(ip), True, True)
-                                       gdb.execute("inferior 1", False, True)
+                               ip = long(gdb.parse_and_eval("regs->ip - 1"))
+                               gdb.execute("inferior "+str(task_list[pid][0]), 
False, True)
+                               sym = gdb.execute("info line *"+str(ip), True, 
True)
                        else:
                                sym = gdb.execute("info line *(regs->ip - 1)", 
True, True)
                        line = get_line_from_sym(sym)
+                       if is_user:
+                               gdb.execute("inferior 1", False, True)
                        task_list_add_line(is_user, pid, line)
                except gdb.error, x:
                        print("Drop one entry because", x)
+                       gdb.execute("inferior 1", False, True)
                except gdb.MemoryError, x:
                        print("Drop one entry because", x)
+                       gdb.execute("inferior 1", False, True)
                try:
                        gdb.execute("tfind 1", False, True)
                except:

Other related posts:

  • » [kgtp] r982 committed - Add lib name to output of hotcode.py - kgtp