This updated version prevents an infinite loop in the (currently impossible) case of a poorly specified disassembly range. Truth is, this functions interface is a bit awkward.
Jeremy White wrote:
Changelog: Properly respect a disassemble x,y command (prior behavior would do y-x instructions, no matter how wide each instruction was)
Index: programs/winedbg/debugger.h
RCS file: /cvstrees/crossover/office/wine/programs/winedbg/debugger.h,v retrieving revision 1.17 diff -u -r1.17 debugger.h --- programs/winedbg/debugger.h 28 Nov 2004 16:23:50 -0000 1.17 +++ programs/winedbg/debugger.h 5 Dec 2004 04:30:24 -0000 @@ -317,7 +317,7 @@ 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); Index: programs/winedbg/memory.c =================================================================== RCS file: /cvstrees/crossover/office/wine/programs/winedbg/memory.c,v retrieving revision 1.1.1.13 diff -u -r1.1.1.13 memory.c --- programs/winedbg/memory.c 28 Nov 2004 15:36:39 -0000 1.1.1.13 +++ programs/winedbg/memory.c 5 Dec 2004 04:30:24 -0000 @@ -598,9 +598,11 @@ }
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 @@ 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);
}