mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 06:39:01 +08:00
utils.py:add profile command to profile python command
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
import cProfile
|
||||
import re
|
||||
import shlex
|
||||
from typing import List, Tuple, Union
|
||||
@@ -349,6 +350,22 @@ class Addr2Line(gdb.Command):
|
||||
Addr2Line()
|
||||
|
||||
|
||||
class Profile(gdb.Command):
|
||||
"""Profile a gdb command
|
||||
|
||||
Usage: profile <gdb command>
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(Profile, self).__init__("profile", gdb.COMMAND_USER)
|
||||
|
||||
def invoke(self, args, from_tty):
|
||||
cProfile.run(f"gdb.execute('{args}')", sort="cumulative")
|
||||
|
||||
|
||||
Profile()
|
||||
|
||||
|
||||
def nitems(array):
|
||||
array_type = array.type
|
||||
element_type = array_type.target()
|
||||
|
||||
Reference in New Issue
Block a user