From e9c94fa58113f60c82be6d829fadd307195ecfb7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 26 Apr 2014 21:11:53 +1000 Subject: Debug: fixes for Nuttx.py debug gdb add-ons also fixed preceding mask calculation in show heaps --- Debug/Nuttx.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Debug') diff --git a/Debug/Nuttx.py b/Debug/Nuttx.py index 093edd0e0..7cc21b99f 100644 --- a/Debug/Nuttx.py +++ b/Debug/Nuttx.py @@ -306,12 +306,15 @@ class NX_show_heap (gdb.Command): def __init__(self): super(NX_show_heap, self).__init__('show heap', gdb.COMMAND_USER) - if gdb.lookup_type('struct mm_allocnode_s').sizeof == 8: - self._allocflag = 0x80000000 - self._allocnodesize = 8 - else: + struct_mm_allocnode_s = gdb.lookup_type('struct mm_allocnode_s') + preceding_size = struct_mm_allocnode_s['preceding'].type.sizeof + if preceding_size == 2: self._allocflag = 0x8000 - self._allocnodesize = 4 + elif preceding_size == 4: + self._allocflag = 0x80000000 + else: + raise gdb.GdbError('invalid mm_allocnode_s.preceding size %u' % preceding_size) + self._allocnodesize = struct_mm_allocnode_s.sizeof def _node_allocated(self, allocnode): if allocnode['preceding'] & self._allocflag: @@ -333,7 +336,8 @@ class NX_show_heap (gdb.Command): state = '' else: state = '(free)' - print ' {} {} {}'.format(allocnode.address + 8, self._node_size(allocnode), state) + print ' {} {} {}'.format(allocnode.address + self._allocnodesize, + self._node_size(allocnode), state) cursor += self._node_size(allocnode) / self._allocnodesize def invoke(self, args, from_tty): -- cgit v1.2.3 From f1258da61086b82ad04a9945dd36d52735efc6fb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 26 Apr 2014 21:12:06 +1000 Subject: Debug: fixes for gdb extension macros --- Debug/NuttX | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Debug') diff --git a/Debug/NuttX b/Debug/NuttX index 3b95e96b2..d34e9f5b4 100644 --- a/Debug/NuttX +++ b/Debug/NuttX @@ -34,10 +34,10 @@ define _showheap else set $MM_ALLOC_BIT = 0x80000000 end - printf "HEAP %d %p - %p\n", $index, g_heapstart[$index], g_heapend[$index] + printf "HEAP %d %p - %p\n", $index, g_mmheap.mm_heapstart[$index], g_mmheap.mm_heapend[$index] printf "ptr size\n" - set $node = (char *)g_heapstart[$index] + sizeof(struct mm_allocnode_s) - while $node < g_heapend[$index] + set $node = (char *)g_mmheap.mm_heapstart[$index] + sizeof(struct mm_allocnode_s) + while $node < g_mmheap.mm_heapend[$index] printf " %p", $node set $nodestruct = (struct mm_allocnode_s *)$node printf " %u", $nodestruct->size @@ -47,7 +47,7 @@ define _showheap else set $used = $used + $nodestruct->size end - if ($nodestruct->size > g_heapsize) || (($node + $nodestruct->size) > g_heapend[$index]) + if ($nodestruct->size > g_mmheap.mm_heapsize) || (($node + $nodestruct->size) > g_mmheap.mm_heapend[$index]) printf " (BAD SIZE)" end printf "\n" @@ -59,7 +59,7 @@ define _showheap end define showheap - set $nheaps = sizeof(g_heapstart) / sizeof(g_heapstart[0]) + set $nheaps = sizeof(g_mmheap.mm_heapstart) / sizeof(g_mmheap.mm_heapstart[0]) printf "Printing %d heaps\n", $nheaps set $heapindex = (int)0 while $heapindex < $nheaps -- cgit v1.2.3