From 193c83f6468f84cb3b9e8a3d44a9c972b1e80305 Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Mon, 6 Dec 2004 16:35:33 +0000 Subject: [PATCH] Properly respect a disassemble x,y command (prior behavior would do y-x instructions, no matter how wide each instruction was). --- programs/winedbg/debugger.h | 2 +- programs/winedbg/memory.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 0b9f9e9c4cb..0849c3df48d 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -314,7 +314,7 @@ extern BOOL memory_get_current_stack(ADDRESS* address); extern BOOL memory_get_current_frame(ADDRESS* address); extern BOOL memory_get_string(HANDLE hp, void* addr, BOOL in_debuggee, BOOL unicode, char* buffer, int size); extern BOOL memory_get_string_indirect(HANDLE hp, void* addr, BOOL unicode, char* buffer, int size); -extern void memory_disassemble(const struct dbg_lvalue*, const struct dbg_lvalue*, int offset); +extern void memory_disassemble(const struct dbg_lvalue*, const struct dbg_lvalue*, int instruction_count); extern BOOL memory_disasm_one_insn(ADDRESS* addr); extern void print_bare_address(const ADDRESS* addr); extern void print_address(const ADDRESS* addr, BOOLEAN with_line); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 0537726ef35..7e7b8175003 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -598,9 +598,11 @@ BOOL memory_disasm_one_insn(ADDRESS* addr) } void memory_disassemble(const struct dbg_lvalue* xstart, - const struct dbg_lvalue* xend, int offset) + const struct dbg_lvalue* xend, int instruction_count) { static ADDRESS last = {0,0,0}; + int stop = 0; + int i; if (!xstart && !xend) { @@ -613,7 +615,10 @@ void memory_disassemble(const struct dbg_lvalue* xstart, last.Mode = AddrModeFlat; last.Offset = types_extract_as_integer(xstart); } - if (xend) offset = types_extract_as_integer(xend) - last.Offset + 1; + if (xend) + stop = types_extract_as_integer(xend); } - while (offset-- > 0 && memory_disasm_one_insn(&last)); + for (i = 0; (instruction_count == 0 || i < instruction_count) && + (stop == 0 || last.Offset <= stop); i++) + memory_disasm_one_insn(&last); }