*
* Add a watchpoint.
*/
-void break_add_watch(const struct dbg_lvalue* lvalue, BOOL is_write)
+static void break_add_watch(const struct dbg_lvalue* lvalue, BOOL is_write)
{
int num;
DWORD l = 4;
dbg_printf("\n");
}
+/******************************************************************
+ * break_add_watch_from_lvalue
+ *
+ * Adds a watch point from an address (stored in a lvalue)
+ */
+void break_add_watch_from_lvalue(const struct dbg_lvalue* lvalue)
+{
+ struct dbg_lvalue lval;
+
+ lval.addr.Mode = AddrModeFlat;
+ lval.addr.Offset = types_extract_as_integer(lvalue);
+ lval.type.id = dbg_itype_none;
+
+ break_add_watch(&lval, TRUE);
+}
+
/***********************************************************************
* break_add_watch_from_id
*
- * Add a watchpoint from a symbol name (and eventually a line #)
+ * Add a watchpoint from a symbol name
*/
void break_add_watch_from_id(const char *name)
{
IMAGEHLP_STACK_FRAME isf;
IMAGEHLP_LINE il;
IMAGEHLP_MODULE im;
- struct sym_enum se;
- char tmp[1024];
DWORD64 disp;
- if (pc->Mode != AddrModeFlat)
- dbg_printf("0x%04x:0x%04lx", pc->Segment, pc->Offset);
- else
- dbg_printf("0x%08lx", pc->Offset);
+ print_bare_address(pc);
isf.InstructionOffset = (DWORD_PTR)memory_to_linear_addr(pc);
isf.FrameOffset = (DWORD_PTR)memory_to_linear_addr(frame);
+ /* grab module where symbol is. If we don't have a module, we cannot print more */
+ im.SizeOfStruct = sizeof(im);
+ if (!SymGetModuleInfo(dbg_curr_process->handle, isf.InstructionOffset, &im))
+ return;
+
si->SizeOfStruct = sizeof(*si);
si->MaxNameLen = 256;
- if (!SymFromAddr(dbg_curr_process->handle, isf.InstructionOffset, &disp, si))
- return;
+ if (SymFromAddr(dbg_curr_process->handle, isf.InstructionOffset, &disp, si))
+ {
+ struct sym_enum se;
+ char tmp[1024];
- dbg_printf(" %s", si->Name);
- if (disp) dbg_printf("+0x%lx", (DWORD_PTR)disp);
+ dbg_printf(" %s", si->Name);
+ if (disp) dbg_printf("+0x%lx", (DWORD_PTR)disp);
- SymSetContext(dbg_curr_process->handle, &isf, NULL);
- se.tmp = tmp;
- se.frame = isf.FrameOffset;
- tmp[0] = '\0';
- SymEnumSymbols(dbg_curr_process->handle, 0, NULL, sym_enum_cb, &se);
- if (tmp[0]) dbg_printf("(%s)", tmp);
-
- il.SizeOfStruct = sizeof(il);
- if (SymGetLineFromAddr(dbg_curr_process->handle, isf.InstructionOffset,
- NULL, &il))
- dbg_printf(" [%s:%lu]", il.FileName, il.LineNumber);
- im.SizeOfStruct = sizeof(im);
- if (SymGetModuleInfo(dbg_curr_process->handle, isf.InstructionOffset, &im))
+ SymSetContext(dbg_curr_process->handle, &isf, NULL);
+ se.tmp = tmp;
+ se.frame = isf.FrameOffset;
+ tmp[0] = '\0';
+ SymEnumSymbols(dbg_curr_process->handle, 0, NULL, sym_enum_cb, &se);
+ if (tmp[0]) dbg_printf("(%s)", tmp);
+
+ il.SizeOfStruct = sizeof(il);
+ if (SymGetLineFromAddr(dbg_curr_process->handle, isf.InstructionOffset,
+ NULL, &il))
+ dbg_printf(" [%s:%lu]", il.FileName, il.LineNumber);
dbg_printf(" in %s", im.ModuleName);
+ }
+ else dbg_printf(" in %s (+0x%lx)",
+ im.ModuleName, (DWORD_PTR)(isf.InstructionOffset - im.BaseOfImage));
}
BOOL memory_disasm_one_insn(ADDRESS* addr)