mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
tools/gdb: fix regression on older version of GDB
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
+9
-2
@@ -23,7 +23,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
|
||||||
|
|
||||||
import gdb
|
import gdb
|
||||||
import utils
|
import utils
|
||||||
@@ -53,6 +52,14 @@ def parse_args(args):
|
|||||||
|
|
||||||
class NXGcore(gdb.Command):
|
class NXGcore(gdb.Command):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.tempfile = utils.import_check(
|
||||||
|
"tempfile",
|
||||||
|
errmsg="No tempfile module found, please try gdb-multiarch instead.\n",
|
||||||
|
)
|
||||||
|
|
||||||
|
if not self.tempfile:
|
||||||
|
return
|
||||||
|
|
||||||
super(NXGcore, self).__init__("nxgcore", gdb.COMMAND_USER)
|
super(NXGcore, self).__init__("nxgcore", gdb.COMMAND_USER)
|
||||||
|
|
||||||
def invoke(self, args, from_tty):
|
def invoke(self, args, from_tty):
|
||||||
@@ -63,7 +70,7 @@ class NXGcore(gdb.Command):
|
|||||||
|
|
||||||
objfile = gdb.current_progspace().objfiles()[0]
|
objfile = gdb.current_progspace().objfiles()[0]
|
||||||
elffile = objfile.filename
|
elffile = objfile.filename
|
||||||
tmpfile = tempfile.NamedTemporaryFile(suffix=".elf")
|
tmpfile = self.tempfile.NamedTemporaryFile(suffix=".elf")
|
||||||
|
|
||||||
# Create temporary ELF file with sections for each memory region
|
# Create temporary ELF file with sections for each memory region
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -646,6 +646,12 @@ class Memleak(gdb.Command):
|
|||||||
"""Memleak check"""
|
"""Memleak check"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.elf = utils.import_check(
|
||||||
|
"elftools.elf.elffile", "ELFFile", "Plase pip install pyelftools\n"
|
||||||
|
)
|
||||||
|
if not self.elf:
|
||||||
|
return
|
||||||
|
|
||||||
super(Memleak, self).__init__("memleak", gdb.COMMAND_USER)
|
super(Memleak, self).__init__("memleak", gdb.COMMAND_USER)
|
||||||
|
|
||||||
def check_alive(self, pid):
|
def check_alive(self, pid):
|
||||||
@@ -756,12 +762,6 @@ class Memleak(gdb.Command):
|
|||||||
return {"simple": args.simple, "detail": args.detail}
|
return {"simple": args.simple, "detail": args.detail}
|
||||||
|
|
||||||
def invoke(self, args, from_tty):
|
def invoke(self, args, from_tty):
|
||||||
self.elf = utils.import_check(
|
|
||||||
"elftools.elf.elffile", "ELFFile", "Plase pip install pyelftools\n"
|
|
||||||
)
|
|
||||||
if not self.elf:
|
|
||||||
return
|
|
||||||
|
|
||||||
if sizeof_size_t == 4:
|
if sizeof_size_t == 4:
|
||||||
align = 11
|
align = 11
|
||||||
else:
|
else:
|
||||||
@@ -898,6 +898,14 @@ have {i} some backtrace leak, total leak memory is {int(leaksize)} bytes\n"
|
|||||||
|
|
||||||
class Memmap(gdb.Command):
|
class Memmap(gdb.Command):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.np = utils.import_check("numpy", errmsg="Please pip install numpy\n")
|
||||||
|
self.plt = utils.import_check(
|
||||||
|
"matplotlib", "pyplot", errmsg="Please pip install matplotlib\n"
|
||||||
|
)
|
||||||
|
self.math = utils.import_check("math")
|
||||||
|
if not self.np or not self.plt or not self.math:
|
||||||
|
return
|
||||||
|
|
||||||
super(Memmap, self).__init__("memmap", gdb.COMMAND_USER)
|
super(Memmap, self).__init__("memmap", gdb.COMMAND_USER)
|
||||||
|
|
||||||
def save_memory_map(self, mallinfo, output_file):
|
def save_memory_map(self, mallinfo, output_file):
|
||||||
@@ -946,14 +954,6 @@ class Memmap(gdb.Command):
|
|||||||
return args.output
|
return args.output
|
||||||
|
|
||||||
def invoke(self, args, from_tty):
|
def invoke(self, args, from_tty):
|
||||||
self.np = utils.import_check("numpy", errmsg="Please pip install numpy\n")
|
|
||||||
self.plt = utils.import_check(
|
|
||||||
"matplotlib", "pyplot", errmsg="Please pip install matplotlib\n"
|
|
||||||
)
|
|
||||||
self.math = utils.import_check("math")
|
|
||||||
if not self.np or not self.plt or not self.math:
|
|
||||||
return
|
|
||||||
|
|
||||||
output_file = self.parse_arguments(args.split(" "))
|
output_file = self.parse_arguments(args.split(" "))
|
||||||
meminfo = self.allocinfo()
|
meminfo = self.allocinfo()
|
||||||
self.save_memory_map(meminfo, output_file + ".png")
|
self.save_memory_map(meminfo, output_file + ".png")
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import utils
|
|||||||
from lists import dq_for_every, sq_for_every
|
from lists import dq_for_every, sq_for_every
|
||||||
|
|
||||||
socket = utils.import_check(
|
socket = utils.import_check(
|
||||||
"socket", errmsg="No socket module found, please try gdb-multiarch instead."
|
"socket", errmsg="No socket module found, please try gdb-multiarch instead.\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
NET_IPv4 = utils.get_symbol_value("CONFIG_NET_IPv4")
|
NET_IPv4 = utils.get_symbol_value("CONFIG_NET_IPv4")
|
||||||
|
|||||||
+8
-2
@@ -20,7 +20,6 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
import cProfile
|
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
from typing import List, Tuple, Union
|
from typing import List, Tuple, Union
|
||||||
@@ -359,10 +358,17 @@ class Profile(gdb.Command):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.cProfile = import_check(
|
||||||
|
"cProfile", errmsg="cProfile module not found, try gdb-multiarch.\n"
|
||||||
|
)
|
||||||
|
if not self.cProfile:
|
||||||
|
return
|
||||||
|
|
||||||
super(Profile, self).__init__("profile", gdb.COMMAND_USER)
|
super(Profile, self).__init__("profile", gdb.COMMAND_USER)
|
||||||
|
|
||||||
def invoke(self, args, from_tty):
|
def invoke(self, args, from_tty):
|
||||||
cProfile.run(f"gdb.execute('{args}')", sort="cumulative")
|
|
||||||
|
self.cProfile.run(f"gdb.execute('{args}')", sort="cumulative")
|
||||||
|
|
||||||
|
|
||||||
Profile()
|
Profile()
|
||||||
|
|||||||
Reference in New Issue
Block a user