diff --git a/gdb-port/tests/unit/top-level-parse.py b/gdb-port/tests/unit/top-level-parse.py index 376381c7dddf06d82037a4d1f1289a05a3bc2fb8..48b17d18eef334fc4eeb7cc0be77df7217a4c9a2 100644 --- a/gdb-port/tests/unit/top-level-parse.py +++ b/gdb-port/tests/unit/top-level-parse.py @@ -4,11 +4,11 @@ class TopLevelParseStateManagement(unittest.TestCase): @classmethod def setUpClass(cls): cls._harena_t = gdb.lookup_type("HArena") - cls._arena = gdb.parse_and_eval("malloc(sizeof(HArena))").cast(cls._harena_t.pointer()).dereference() # Quick and dirty way to allocate something in the process GDB is debugging (the inferior) + cls._arena = gdb.parse_and_eval("malloc(sizeof(HArena))").cast(cls._harena_t.pointer()) # Quick and dirty way to allocate something in the process GDB is debugging (the inferior) cls._hps_t = gdb.lookup_type("HParseState") cls._test_parse_state = gdb.parse_and_eval("malloc(sizeof(HParseState))").cast(cls._hps_t.pointer()).dereference() # TODO: make this independent of endianness and pointer size - gdb.selected_inferior().write_memory(int(cls._test_parse_state.address)+(cls._hps_t['arena'].bitpos//8), int(cls._arena.address).to_bytes(8, 'little')) # horrible, horrible way to set the + gdb.selected_inferior().write_memory(int(cls._test_parse_state.address)+(cls._hps_t['arena'].bitpos//8), int(cls._arena).to_bytes(8, 'little')) # horrible, horrible way to set parse_state->arena cls._hps_t = cls._test_parse_state.address.dereference() # "refresh" the gdb.Value, since the effects of .write_memory() don't seem to show up def setUp(self): @@ -87,7 +87,7 @@ class TopLevelParseStateManagement(unittest.TestCase): self.top_level_parse.parser_objs[32] = self.parser1 self.top_level_parse.enter_h_do_parse(16, self._arena, self.parser1.address) self.top_level_parse.enter_h_arena_malloc_raw(256) - self.assertEqual(self.parser1.bytes_used[int(self._arena.address)], 256) + self.assertEqual(self.parser1.bytes_used[int(self._arena)], 256) # A bit hacky: relying on the top_level_parse initialized by top-level-parse.py, because we have no reference to the testcase @unittest.skipIf(top_level_parse.memory_stat_method == HammerMemoryStatisticsMethod.DETAILED_ARENA_STATS, "malloc-based allocation counts disabled") @@ -96,7 +96,9 @@ class TopLevelParseStateManagement(unittest.TestCase): self.top_level_parse.parser_objs[32] = self.parser1 self.ps1.push(self.parser1, self._arena) self.top_level_parse.enter_h_arena_malloc_raw(256) - self.assertEqual(self.top_level_parse.parser_stacks[-1].p_stack[-1].bytes_used[int(self._arena.address)], 256) + # If breakpoint mode doesn't use HArena* already + #self.assertEqual(self.top_level_parse.parser_stacks[-1].p_stack[-1].bytes_used[int(self._arena.address)], 256) + self.assertEqual(self.top_level_parse.parser_stacks[-1].p_stack[-1].bytes_used[int(self._arena)], 256) def test_enter_h_arena_malloc_raw_no_parser(self): self.top_level_parse.parser_stacks.append(self.ps1)