//------------------------------------------------------------------------- static void LoadLocals(WATCHDATA *ptr) { NAMELIST *names = FindEnclosedAutos(activeScope); WATCHINFO *p = ptr->watchinfo_list; int i; for (i=0; i < ptr->watchinfo_count; i++) if (!strcmp(ptr->watchinfo_list[i].info->membername, "this")) { WATCHINFO *x = &ptr->watchinfo_list[i]; int j; FreeTree(x->info, ptr); FreeVarInfo(x->info); for (j = i; j < ptr->watchinfo_count - 1; j++) { ptr->watchinfo_list[j] = ptr->watchinfo_list[j + 1]; RenumberDeleteItems(ptr->watchinfo_list[j].info); } ptr->watchinfo_count--; i--; } else { p[i].marked = TRUE; } while (names) { NAMELIST *next = names->next; DEBUG_INFO *dbg; VARINFO *var = EvalExpr(&dbg, activeScope, (char*) names->data+1, FALSE); if (var) { AddItem(dbg, var, activeScope->address, ptr); } free(names->data); free(names); names = next; } p = ptr->watchinfo_list; for (i=0; i < ptr->watchinfo_count; i++) if (p[i].marked) { WATCHINFO *x = &ptr->watchinfo_list[i]; int j; FreeTree(x->info, ptr); FreeVarInfo(x->info); for (j = i; j < ptr->watchinfo_count - 1; j++) { ptr->watchinfo_list[j] = ptr->watchinfo_list[j + 1]; RenumberDeleteItems(ptr->watchinfo_list[j].info); } ptr->watchinfo_count--; i--; } }
void ExpandPointer(VARINFO *v, int code, int page) { if (v->pointer) { if (code == TVE_EXPAND) { int val; int outofscope = (val = v->derefaddress) == -1 && !ReadValue(v->address, &val, 4, v) || !val; if (!v->subtype && watchinfo_list[page][v->watchindex].dbg_info) { TreeView_DeleteItem(hwndTree[page], v->hTreeHolder); ExpandPointerInfo(watchinfo_list[page][v->watchindex].dbg_info, v); if (v->subtype->structure) { InsertSubTree(v->hTreeItem, 0, v->subtype->subtype, v->watchindex, page); } else InsertSubTree(v->hTreeItem, 0, v->subtype, v->watchindex, page); } RefreshAddresses(v->subtype, val, NULL, outofscope); RefreshData(watchinfo_list[page][v->watchindex].dbg_info, v); } else if (code == TVE_COLLAPSE) { if (v->subtype) { FreeTree(v->subtype, page); FreeVarInfo(v->subtype); v->subtype = 0; v->hTreeHolder = InsertItem(v->hTreeItem, TVI_LAST, v, page); } } } }
void DeleteItem(POINT *pt, int page) { int i; WATCHINFO *x; TV_HITTESTINFO t; HTREEITEM titem; TV_ITEM item; VARINFO *v; ScreenToClient(hwndTree[page], pt); t.pt = *pt; titem = TreeView_HitTest(hwndTree[page], &t); if (titem) { int c; item.mask = TVIF_PARAM; item.hItem = titem; TreeView_GetItem(hwndTree[page], &item); v = (VARINFO*)item.lParam; x = &watchinfo_list[page][c = v->watchindex]; FreeTree(x->info, page); FreeVarInfo(x->info); for (i = c; i < watchinfo_count[page] - 1; i++) { watchinfo_list[page][i] = watchinfo_list[page][i + 1]; RenumberDeleteItems(watchinfo_list[page][i].info); } watchinfo_count[page]--; } }
void AddItem(DEBUG_INFO *dbg, VARINFO *var, int cursoreip, int page) { WATCHINFO *x = MatchItem(var, page); if (x) { FreeVarInfo(var); } else { HTREEITEM previous = 0; if (watchinfo_count[page] >= watchinfo_max[page]) { if (watchinfo_max[page] >= 128) { ExtendedMessageBox("Watch Error", MB_SETFOREGROUND | MB_SYSTEMMODAL, "There are too many items in the watch window\nNot adding the current selection"); return ; } watchinfo_max[page] += 64; watchinfo_list[page] = realloc(watchinfo_list[page], watchinfo_max[page] *sizeof (WATCHINFO)); } if (watchinfo_count[page]) previous = watchinfo_list[page][watchinfo_count[page] - 1].info->hTreeItem; memset(&watchinfo_list[page][watchinfo_count[page]], 0, sizeof(watchinfo_list[page][0])); watchinfo_list[page][watchinfo_count[page]].info = var; watchinfo_list[page][watchinfo_count[page]].dbg_info = dbg; watchinfo_list[page][watchinfo_count[page]++].cursoreip = cursoreip; RefreshItem(&watchinfo_list[page][watchinfo_count[page] - 1], var->address, NULL); InsertSubTree(0, previous, var, watchinfo_count[page] - 1, page); } }
static void DeleteItem(POINT *pt, WATCHDATA *ptr) { int i; WATCHINFO *x; TV_HITTESTINFO t; HTREEITEM titem; TV_ITEM item; VARINFO *v; ScreenToClient(ptr->hwndWatchTree, pt); t.pt = *pt; titem = TreeView_HitTest(ptr->hwndWatchTree, &t); if (titem) { int c; item.mask = TVIF_PARAM; item.hItem = titem; TreeView_GetItem(ptr->hwndWatchTree, &item); v = (VARINFO*)item.lParam; x = &ptr->watchinfo_list[c = v->watchindex]; FreeTree(x->info, ptr); FreeVarInfo(x->info); for (i = c; i < ptr->watchinfo_count - 1; i++) { ptr->watchinfo_list[i] = ptr->watchinfo_list[i + 1]; RenumberDeleteItems(ptr->watchinfo_list[i].info); } ptr->watchinfo_count--; } }
static void AddItem(DEBUG_INFO *dbg, VARINFO *var, int cursoreip, WATCHDATA *ptr) { WATCHINFO *x = MatchItem(var, ptr); if (x) { x->marked = FALSE; FreeVarInfo(var); } else { HTREEITEM previous = 0; if (ptr->watchinfo_count >= ptr->watchinfo_max) { if (ptr->watchinfo_max >= 128) { ExtendedMessageBox("Watch Error", MB_SETFOREGROUND | MB_SYSTEMMODAL, "There are too many items in the watch window\nNot adding the current selection"); return ; } ptr->watchinfo_max += 64; ptr->watchinfo_list = realloc(ptr->watchinfo_list, ptr->watchinfo_max *sizeof (WATCHINFO)); } if (ptr->watchinfo_count) previous = ptr->watchinfo_list[ptr->watchinfo_count - 1].info->hTreeItem; memset(&ptr->watchinfo_list[ptr->watchinfo_count], 0, sizeof(ptr->watchinfo_list[0])); ptr->watchinfo_list[ptr->watchinfo_count].info = var; ptr->watchinfo_list[ptr->watchinfo_count].dbg_info = dbg; ptr->watchinfo_list[ptr->watchinfo_count++].cursoreip = cursoreip; RefreshItem(ptr, &ptr->watchinfo_list[ptr->watchinfo_count - 1], var->address, NULL, TRUE); InsertSubTree(0, previous, var, ptr->watchinfo_count - 1, ptr); } }
static int resolvenametoaddr(int index, int doErrors) { int offset, addr, linoffs; DEBUG_INFO *dbg; VARINFO *var; char buf[256]; strcpy(buf, hdwebp[index].name); var = EvalExpr(&dbg, &lastScope, buf, doErrors); if (var) { if (var->constant) addr = var->ival; else if (var->address < 0x1000) { char data[20]; ReadValue(var->address, &data, 4, var); addr = *(int*)data; } else addr = var->address; FreeVarInfo(var); hdwebp[index].address = addr; return 1; } else { return 0; } }
void DeleteAllItems(int page) { int i; TreeView_DeleteAllItems(hwndTree[page]); for (i = 0; i < watchinfo_count[page]; i++) FreeVarInfo(watchinfo_list[page][i].info); watchinfo_count[page] = 0; }
static void DeleteAllItems(WATCHDATA *ptr) { int i; TreeView_DeleteAllItems(ptr->hwndWatchTree); for (i = 0; i < ptr->watchinfo_count; i++) FreeVarInfo(ptr->watchinfo_list[i].info); ptr->watchinfo_count = 0; }
void RefreshItems(int page) { int i; char *types, *syms; int offset; DEBUG_INFO *dbg; for (i = 0; i < watchinfo_count[page]; i++) { WATCHINFO *wi = &watchinfo_list[page][i]; VARINFO *var; int level; var = EvalExpr(&wi->dbg_info, activeScope, (char*)wi->info->membername, FALSE); if (!var) { Unscope(wi, page); offset = 0; } else { wi->info->outofscopereg = var->outofscopereg; if (var->outofscopereg) { Unscope(wi, page); offset = 0; } else { int ebp, level; Rescope(wi, i, page); offset = var->address; wi->cursoreip = activeScope->address; if (var->pointer) { wi->info->derefaddress = var->derefaddress; } } FreeVarInfo(var); } RefreshItem(wi, offset, activeThread); } InvalidateRect(hwndTree[page], 0, 0); }
void ReloadVars(WATCHDATA *ptr) { int i; int len = ptr->watchinfo_count; for (i=0; i < ptr->watchinfo_count; i++) { FreeTree(ptr->watchinfo_list[i].info, ptr); } ptr->watchinfo_count = 0; for (i=0; i < len; i++) { DEBUG_INFO *dbg; VARINFO *var = EvalExpr(&dbg, activeScope, (char*)ptr->watchinfo_list[i].info->membername , FALSE); if (var) FreeVarInfo(ptr->watchinfo_list[i].info); else var = ptr->watchinfo_list[i].info; AddItem(dbg, var, activeScope->address, ptr); } }
static void ExpandPointer(VARINFO *v, int code, WATCHDATA *ptr) { if (v->pointer) { if (code == TVE_EXPAND) { int val; int outofscope; outofscope = ((val = v->derefaddress) == -1 && !ReadValue(v->address, &val, 4, v)) || !val; if (!v->subtype && ptr->watchinfo_list[v->watchindex].dbg_info) { TreeView_DeleteItem(ptr->hwndWatchTree, v->hTreeHolder); ExpandPointerInfo(ptr->watchinfo_list[v->watchindex].dbg_info, v); if (v->subtype->structure) { InsertSubTree(v->hTreeItem, 0, v->subtype->subtype, v->watchindex, ptr); } else InsertSubTree(v->hTreeItem, 0, v->subtype, v->watchindex, ptr); } ptr->structNesting[ptr->nestingCount++] = v; RefreshAddresses(ptr, v->subtype, val, NULL, outofscope); ptr->nestingCount--; RefreshData(ptr->watchinfo_list[v->watchindex].dbg_info, v, TRUE); } else if (code == TVE_COLLAPSE) { if (v->subtype && !v->derefaddress) { FreeTree(v->subtype, ptr); FreeVarInfo(v->subtype); v->subtype = 0; v->hTreeHolder = InsertItem(v->hTreeItem, TVI_LAST, v, ptr); } } } }
static int resolvenametoaddr(char *name, int doErrors, DWORD *size, DWORD *addr) { DEBUG_INFO *dbg; VARINFO *var; var = EvalExpr(&dbg, &lastScope, name, doErrors); if (var) { if (var->constant) { *addr = var->ival; *size = 4; } else if (var->address < 0x1000) { char data[20]; //if (!var->explicitreg) //ExtendedMessageBox("Address error", MB_SETFOREGROUND | //MB_SYSTEMMODAL, //"Address is a register. Using its value as the address."); ReadValue(var->address, &data, 4, var); *addr = *(int*)data; *size = 4; } else { *addr = var->address; *size = var->size; } FreeVarInfo(var); return 1; } else { return 0; } }
void ChangeData(VARINFO *info, char *text, int page) { if (info->type >= eFloat && info->type <= eImaginaryLongDouble) { float v; double v2; char data[10]; sscanf(text, "%f", &v); switch (info->type) { case eFloat: case eImaginary: WriteValue(info->address, &v, 4, &info->thread->regs); break; case eDouble: case eImaginaryDouble: v2 = v; WriteValue(info->address, &v2, 8, &info->thread->regs); break; case eLongDouble: case eImaginaryLongDouble: *(long double*)data = v; WriteValue(info->address, data, 10, &info->thread->regs); break; default: break; } } else if (info->type >= eComplex && info->type <= eComplexLongDouble) { float v[2]; double v2[2]; long double v4[2]; sscanf(text, "%f + %f * I", &v[0],&v[1]); switch (info->type) { case eComplex: WriteValue(info->address, &v[0], 8, &info->thread->regs); break ; case eComplexDouble: v2[0] = v[0]; v2[1] = v[1]; WriteValue(info->address, &v2[0], 16, &info->thread->regs); break ; case eComplexLongDouble: v4[0] = v[0]; v4[1] = v[1]; WriteValue(info->address, &v4[0], 20, &info->thread->regs); break ; } } else { LLONG_TYPE value; int size; if (info->enumx && !isdigit(text[0])) { value = GetEnumValue(watchinfo_list[page][info->watchindex].dbg_info, info, text); size = 4; } else { if (text[0] == '0' && text[1] == 'x') sscanf(text + 2, "%Lx", &value); else if ((text[strlen(text) - 1] & 0xDF) == 'H') sscanf(text, "%Lx", &value); else sscanf(text, "%Ld", &value); switch (info->type) { case eBool: case eBit: case eChar: case eUChar: size = 1; break; case eShort: case eUShort: case eChar16T: case eWcharT: size = 2; break; case eInt: case eLong: case eUInt: case eULong: size = 4; break; case eLongLong: case eULongLong: size = 8; break; } } if (info->bitfield) { char data[10]; int signedx; int v; HintBasicValue(info, &signedx, &data); v = *(int*)data; v &= ~(bitmask[info->bitlength - 1] << info->bitstart); value = v | ((value &bitmask[info->bitlength - 1]) << info ->bitstart); } WriteValue(info->address, &value, size, &info->thread->regs); if (info->pointer) { if (!value && info->subtype) { VARINFO *inf = info->subtype; info->subtype = 0; FreeTree(inf, page); FreeVarInfo(inf); } else RefreshAddresses(info->subtype, value, NULL, info->outofscope); } } RefreshData(watchinfo_list[page][info->watchindex].dbg_info, info); }