2004-06-04 00:59:16 +00:00
|
|
|
/*
|
|
|
|
* Generate hash tables for Wine debugger symbols
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993, Eric Youngdale.
|
2006-02-06 10:27:32 +00:00
|
|
|
* 2004-2005, Eric Pouech.
|
2004-06-04 00:59:16 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-06-04 00:59:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "debugger.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
|
|
|
|
|
2006-12-02 16:43:03 +00:00
|
|
|
static BOOL symbol_get_debug_start(const struct dbg_type* func, ULONG64* start)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
|
|
|
DWORD count, tag;
|
|
|
|
char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
|
|
|
|
TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
|
|
|
|
int i;
|
2006-12-02 16:43:03 +00:00
|
|
|
struct dbg_type child;
|
2004-06-04 00:59:16 +00:00
|
|
|
|
2006-12-02 16:43:03 +00:00
|
|
|
if (!func->id) return FALSE; /* native dbghelp not always fills the info field */
|
2004-08-22 22:35:36 +00:00
|
|
|
|
2006-12-02 16:43:03 +00:00
|
|
|
if (!types_get_info(func, TI_GET_CHILDRENCOUNT, &count)) return FALSE;
|
2004-06-04 00:59:16 +00:00
|
|
|
fcp->Start = 0;
|
|
|
|
while (count)
|
|
|
|
{
|
|
|
|
fcp->Count = min(count, 256);
|
2006-12-02 16:43:03 +00:00
|
|
|
if (types_get_info(func, TI_FINDCHILDREN, fcp))
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
|
|
|
for (i = 0; i < min(fcp->Count, count); i++)
|
|
|
|
{
|
2006-12-02 16:43:03 +00:00
|
|
|
child.module = func->module;
|
|
|
|
child.id = fcp->ChildId[i];
|
|
|
|
types_get_info(&child, TI_GET_SYMTAG, &tag);
|
2004-06-04 00:59:16 +00:00
|
|
|
if (tag != SymTagFuncDebugStart) continue;
|
2006-12-02 16:43:03 +00:00
|
|
|
return types_get_info(&child, TI_GET_ADDRESS, start);
|
2004-06-04 00:59:16 +00:00
|
|
|
}
|
|
|
|
count -= min(count, 256);
|
|
|
|
fcp->Start += 256;
|
2006-12-02 16:43:03 +00:00
|
|
|
fcp->Start += 256;
|
2004-06-04 00:59:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-12-10 14:23:45 +00:00
|
|
|
static BOOL fill_sym_lvalue(const SYMBOL_INFO* sym, ULONG_PTR base,
|
2006-12-02 16:43:34 +00:00
|
|
|
struct dbg_lvalue* lvalue, char* buffer, size_t sz)
|
|
|
|
{
|
|
|
|
if (buffer) buffer[0] = '\0';
|
|
|
|
if (sym->Flags & SYMFLAG_REGISTER)
|
|
|
|
{
|
2022-04-29 09:43:12 +00:00
|
|
|
if (!memory_get_register(sym->Register, lvalue, buffer, sz))
|
2006-12-02 16:43:34 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (sym->Flags & SYMFLAG_REGREL)
|
|
|
|
{
|
2012-06-24 11:03:09 +00:00
|
|
|
size_t l;
|
2006-12-02 16:43:34 +00:00
|
|
|
|
2012-06-24 11:03:09 +00:00
|
|
|
*buffer++ = '['; sz--;
|
2022-04-29 09:43:12 +00:00
|
|
|
if (!memory_get_register(sym->Register, lvalue, buffer, sz))
|
2006-12-02 16:43:34 +00:00
|
|
|
return FALSE;
|
2012-06-24 11:03:09 +00:00
|
|
|
l = strlen(buffer);
|
|
|
|
sz -= l;
|
|
|
|
buffer += l;
|
2022-04-29 09:43:12 +00:00
|
|
|
init_lvalue(lvalue, TRUE, (void*)(DWORD_PTR)(types_extract_as_integer(lvalue) + sym->Address));
|
2021-11-26 16:30:16 +00:00
|
|
|
if ((LONG64)sym->Address >= 0)
|
|
|
|
snprintf(buffer, sz, "+%I64d]", sym->Address);
|
2012-06-24 11:03:09 +00:00
|
|
|
else
|
2021-11-26 16:30:16 +00:00
|
|
|
snprintf(buffer, sz, "-%I64d]", -(LONG64)sym->Address);
|
2006-12-02 16:43:34 +00:00
|
|
|
}
|
2006-12-05 21:13:33 +00:00
|
|
|
else if (sym->Flags & SYMFLAG_VALUEPRESENT)
|
|
|
|
{
|
|
|
|
struct dbg_type type;
|
|
|
|
VARIANT v;
|
|
|
|
|
|
|
|
type.module = sym->ModBase;
|
2016-03-21 17:30:14 +00:00
|
|
|
type.id = sym->Index;
|
2006-12-05 21:13:33 +00:00
|
|
|
|
2009-10-03 11:15:49 +00:00
|
|
|
if (!types_get_info(&type, TI_GET_VALUE, &v))
|
2006-12-05 21:13:33 +00:00
|
|
|
{
|
2009-10-03 11:15:49 +00:00
|
|
|
if (buffer) snprintf(buffer, sz, "Couldn't get full value information for %s", sym->Name);
|
2006-12-05 21:13:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2021-11-26 16:30:34 +00:00
|
|
|
else if (V_ISBYREF(&v))
|
2009-10-03 11:15:49 +00:00
|
|
|
{
|
|
|
|
/* FIXME: this won't work for pointers or arrays, as we don't always
|
|
|
|
* know, if the value to be dereferenced lies in debuggee or
|
|
|
|
* debugger address space.
|
|
|
|
*/
|
|
|
|
if (sym->Tag == SymTagPointerType || sym->Tag == SymTagArrayType)
|
|
|
|
{
|
|
|
|
if (buffer) snprintf(buffer, sz, "Couldn't dereference pointer for const value for %s", sym->Name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* this is likely Wine's dbghelp which passes const values by reference
|
|
|
|
* (object is managed by dbghelp, hence in debugger address space)
|
|
|
|
*/
|
2021-12-08 13:43:56 +00:00
|
|
|
init_lvalue(lvalue, FALSE, (void*)(DWORD_PTR)sym->Value);
|
2009-10-03 11:15:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD* pdw = (DWORD*)lexeme_alloc_size(sizeof(*pdw));
|
2021-12-08 13:43:56 +00:00
|
|
|
init_lvalue(lvalue, FALSE, pdw);
|
2009-10-03 11:15:49 +00:00
|
|
|
*pdw = sym->Value;
|
|
|
|
}
|
2006-12-05 21:13:33 +00:00
|
|
|
}
|
2006-12-02 16:43:34 +00:00
|
|
|
else if (sym->Flags & SYMFLAG_LOCAL)
|
|
|
|
{
|
2021-12-08 13:43:56 +00:00
|
|
|
init_lvalue(lvalue, TRUE, (void*)(DWORD_PTR)(base + sym->Address));
|
2006-12-02 16:43:34 +00:00
|
|
|
}
|
2011-01-29 19:38:21 +00:00
|
|
|
else if (sym->Flags & SYMFLAG_TLSREL)
|
|
|
|
{
|
|
|
|
PROCESS_BASIC_INFORMATION pbi;
|
|
|
|
THREAD_BASIC_INFORMATION tbi;
|
|
|
|
DWORD_PTR addr;
|
|
|
|
PEB peb;
|
|
|
|
PEB_LDR_DATA ldr_data;
|
|
|
|
PLIST_ENTRY head, current;
|
2020-04-24 01:17:31 +00:00
|
|
|
LDR_DATA_TABLE_ENTRY ldr_module;
|
2011-01-29 19:38:21 +00:00
|
|
|
unsigned tlsindex = -1;
|
|
|
|
|
|
|
|
if (NtQueryInformationProcess(dbg_curr_process->handle, ProcessBasicInformation,
|
|
|
|
&pbi, sizeof(pbi), NULL) ||
|
|
|
|
NtQueryInformationThread(dbg_curr_thread->handle, ThreadBasicInformation,
|
|
|
|
&tbi, sizeof(tbi), NULL))
|
|
|
|
{
|
|
|
|
tls_error:
|
|
|
|
if (buffer) snprintf(buffer, sz, "Cannot read TLS address\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
addr = (DWORD_PTR)&(((TEB*)tbi.TebBaseAddress)->ThreadLocalStoragePointer);
|
|
|
|
if (!dbg_read_memory((void*)addr, &addr, sizeof(addr)) ||
|
|
|
|
!dbg_read_memory(pbi.PebBaseAddress, &peb, sizeof(peb)) ||
|
|
|
|
!dbg_read_memory(peb.LdrData, &ldr_data, sizeof(ldr_data)))
|
|
|
|
goto tls_error;
|
|
|
|
current = ldr_data.InLoadOrderModuleList.Flink;
|
|
|
|
head = &((PEB_LDR_DATA*)peb.LdrData)->InLoadOrderModuleList;
|
|
|
|
do
|
|
|
|
{
|
2020-04-24 01:17:34 +00:00
|
|
|
if (!dbg_read_memory(CONTAINING_RECORD(current, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks),
|
2011-01-29 19:38:21 +00:00
|
|
|
&ldr_module, sizeof(ldr_module))) goto tls_error;
|
2020-04-24 01:17:33 +00:00
|
|
|
if ((DWORD_PTR)ldr_module.DllBase == sym->ModBase)
|
2011-01-29 19:38:21 +00:00
|
|
|
{
|
|
|
|
tlsindex = ldr_module.TlsIndex;
|
|
|
|
break;
|
|
|
|
}
|
2020-04-24 01:17:34 +00:00
|
|
|
current = ldr_module.InLoadOrderLinks.Flink;
|
2011-01-29 19:38:21 +00:00
|
|
|
} while (current != head);
|
|
|
|
|
|
|
|
addr += tlsindex * sizeof(DWORD_PTR);
|
|
|
|
if (!dbg_read_memory((void*)addr, &addr, sizeof(addr))) goto tls_error;
|
2021-12-08 13:43:56 +00:00
|
|
|
init_lvalue(lvalue, TRUE, (void*)(DWORD_PTR)(addr + sym->Address));
|
2011-01-29 19:38:21 +00:00
|
|
|
}
|
2006-12-02 16:43:34 +00:00
|
|
|
else
|
|
|
|
{
|
2021-12-08 13:43:56 +00:00
|
|
|
init_lvalue(lvalue, TRUE, (void*)(DWORD_PTR)sym->Address);
|
2006-12-02 16:43:34 +00:00
|
|
|
}
|
|
|
|
lvalue->addr.Mode = AddrModeFlat;
|
|
|
|
lvalue->type.module = sym->ModBase;
|
|
|
|
lvalue->type.id = sym->TypeIndex;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-06-04 00:59:16 +00:00
|
|
|
struct sgv_data
|
|
|
|
{
|
|
|
|
#define NUMDBGV 100
|
2005-11-18 12:05:44 +00:00
|
|
|
struct
|
|
|
|
{
|
2004-06-04 00:59:16 +00:00
|
|
|
/* FIXME: NUMDBGV should be made variable */
|
|
|
|
struct dbg_lvalue lvalue;
|
|
|
|
DWORD flags;
|
2006-12-02 16:43:03 +00:00
|
|
|
DWORD sym_info;
|
2004-06-04 00:59:16 +00:00
|
|
|
} syms[NUMDBGV]; /* out : will be filled in with various found symbols */
|
|
|
|
int num; /* out : number of found symbols */
|
|
|
|
int num_thunks; /* out : number of thunks found */
|
|
|
|
const char* name; /* in : name of symbol to look up */
|
2006-12-02 16:43:03 +00:00
|
|
|
unsigned do_thunks : 1; /* in : whether we return thunks tags */
|
2005-11-18 12:05:44 +00:00
|
|
|
ULONG64 frame_offset; /* in : frame for local & parameter variables look up */
|
2004-06-04 00:59:16 +00:00
|
|
|
};
|
|
|
|
|
2007-09-17 22:40:19 +00:00
|
|
|
static BOOL CALLBACK sgv_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
2009-04-21 07:59:59 +00:00
|
|
|
struct sgv_data* sgv = ctx;
|
2006-12-02 16:43:34 +00:00
|
|
|
unsigned insp;
|
2006-12-05 21:13:33 +00:00
|
|
|
char tmp[64];
|
2004-06-04 00:59:16 +00:00
|
|
|
|
2006-12-02 16:43:34 +00:00
|
|
|
if (sym->Flags & SYMFLAG_THUNK)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
|
|
|
if (!sgv->do_thunks) return TRUE;
|
|
|
|
sgv->num_thunks++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sgv->num >= NUMDBGV)
|
|
|
|
{
|
|
|
|
dbg_printf("Too many addresses for symbol '%s', limiting the first %d\n",
|
|
|
|
sgv->name, NUMDBGV);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-01-29 19:38:21 +00:00
|
|
|
WINE_TRACE("==> %s %s%s%s%s%s%s%s%s\n",
|
|
|
|
sym->Name,
|
2004-06-04 00:59:16 +00:00
|
|
|
(sym->Flags & SYMFLAG_FUNCTION) ? "func " : "",
|
|
|
|
(sym->Flags & SYMFLAG_FRAMEREL) ? "framerel " : "",
|
2011-01-29 19:38:21 +00:00
|
|
|
(sym->Flags & SYMFLAG_TLSREL) ? "tlsrel " : "",
|
2004-06-04 00:59:16 +00:00
|
|
|
(sym->Flags & SYMFLAG_REGISTER) ? "register " : "",
|
|
|
|
(sym->Flags & SYMFLAG_REGREL) ? "regrel " : "",
|
|
|
|
(sym->Flags & SYMFLAG_PARAMETER) ? "param " : "",
|
2005-11-18 12:05:44 +00:00
|
|
|
(sym->Flags & SYMFLAG_LOCAL) ? "local " : "",
|
2004-06-04 00:59:16 +00:00
|
|
|
(sym->Flags & SYMFLAG_THUNK) ? "thunk " : "");
|
|
|
|
|
|
|
|
/* always keep the thunks at end of the array */
|
|
|
|
insp = sgv->num;
|
|
|
|
if (sgv->num_thunks && !(sym->Flags & SYMFLAG_THUNK))
|
|
|
|
{
|
|
|
|
insp -= sgv->num_thunks;
|
|
|
|
memmove(&sgv->syms[insp + 1], &sgv->syms[insp],
|
|
|
|
sizeof(sgv->syms[0]) * sgv->num_thunks);
|
|
|
|
}
|
2006-12-02 16:43:34 +00:00
|
|
|
if (!fill_sym_lvalue(sym, sgv->frame_offset, &sgv->syms[insp].lvalue, tmp, sizeof(tmp)))
|
|
|
|
{
|
|
|
|
dbg_printf("%s: %s\n", sym->Name, tmp);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-06-04 00:59:16 +00:00
|
|
|
sgv->syms[insp].flags = sym->Flags;
|
2016-03-21 17:30:14 +00:00
|
|
|
sgv->syms[insp].sym_info = sym->Index;
|
2004-06-04 00:59:16 +00:00
|
|
|
sgv->num++;
|
2006-12-02 16:43:03 +00:00
|
|
|
|
2004-06-04 00:59:16 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-11-10 14:02:49 +00:00
|
|
|
enum sym_get_lval symbol_picker_interactive(const char* name, const struct sgv_data* sgv,
|
|
|
|
struct dbg_lvalue* rtn)
|
|
|
|
{
|
|
|
|
char buffer[512];
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
if (!dbg_interactiveP)
|
|
|
|
{
|
|
|
|
dbg_printf("More than one symbol named %s, picking the first one\n", name);
|
|
|
|
*rtn = sgv->syms[0].lvalue;
|
|
|
|
return sglv_found;
|
|
|
|
}
|
|
|
|
|
|
|
|
dbg_printf("Many symbols with name '%s', "
|
|
|
|
"choose the one you want (<cr> to abort):\n", name);
|
|
|
|
for (i = 0; i < sgv->num; i++)
|
|
|
|
{
|
|
|
|
if (sgv->num - sgv->num_thunks > 1 && (sgv->syms[i].flags & SYMFLAG_THUNK) && !DBG_IVAR(AlwaysShowThunks))
|
|
|
|
continue;
|
|
|
|
dbg_printf("[%d]: ", i + 1);
|
2010-03-30 19:37:15 +00:00
|
|
|
if (sgv->syms[i].flags & (SYMFLAG_LOCAL | SYMFLAG_PARAMETER))
|
2008-11-10 14:02:49 +00:00
|
|
|
{
|
|
|
|
dbg_printf("%s %sof %s\n",
|
|
|
|
sgv->syms[i].flags & SYMFLAG_PARAMETER ? "Parameter" : "Local variable",
|
|
|
|
sgv->syms[i].flags & (SYMFLAG_REGISTER|SYMFLAG_REGREL) ? "(in a register) " : "",
|
|
|
|
name);
|
|
|
|
}
|
|
|
|
else if (sgv->syms[i].flags & SYMFLAG_THUNK)
|
|
|
|
{
|
|
|
|
print_address(&sgv->syms[i].lvalue.addr, TRUE);
|
|
|
|
/* FIXME: should display where the thunks points to */
|
|
|
|
dbg_printf(" thunk %s\n", name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print_address(&sgv->syms[i].lvalue.addr, TRUE);
|
|
|
|
dbg_printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (input_read_line("=> ", buffer, sizeof(buffer)))
|
|
|
|
{
|
|
|
|
if (buffer[0] == '\0') return sglv_aborted;
|
|
|
|
i = atoi(buffer);
|
|
|
|
if (i < 1 || i > sgv->num)
|
|
|
|
dbg_printf("Invalid choice %d\n", i);
|
|
|
|
}
|
|
|
|
else return sglv_aborted;
|
|
|
|
} while (i < 1 || i > sgv->num);
|
|
|
|
|
|
|
|
/* The array is 0-based, but the choices are 1..n,
|
|
|
|
* so we have to subtract one before returning.
|
|
|
|
*/
|
|
|
|
*rtn = sgv->syms[i - 1].lvalue;
|
|
|
|
return sglv_found;
|
|
|
|
}
|
|
|
|
|
2008-11-10 14:03:10 +00:00
|
|
|
enum sym_get_lval symbol_picker_scoped(const char* name, const struct sgv_data* sgv,
|
|
|
|
struct dbg_lvalue* rtn)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
int local = -1;
|
|
|
|
|
|
|
|
for (i = 0; i < sgv->num; i++)
|
|
|
|
{
|
|
|
|
if (sgv->num - sgv->num_thunks > 1 && (sgv->syms[i].flags & SYMFLAG_THUNK) && !DBG_IVAR(AlwaysShowThunks))
|
|
|
|
continue;
|
2010-03-30 19:37:15 +00:00
|
|
|
if (sgv->syms[i].flags & (SYMFLAG_LOCAL | SYMFLAG_PARAMETER))
|
2008-11-10 14:03:10 +00:00
|
|
|
{
|
|
|
|
if (local == -1)
|
|
|
|
local = i;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME: several locals with same name... which one to pick ?? */
|
|
|
|
dbg_printf("Several local variables/parameters for %s, aborting\n", name);
|
|
|
|
return sglv_aborted;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (local != -1)
|
|
|
|
{
|
|
|
|
*rtn = sgv->syms[local].lvalue;
|
|
|
|
return sglv_found;
|
|
|
|
}
|
|
|
|
/* no locals found, multiple globals... abort for now */
|
|
|
|
dbg_printf("Several global variables for %s, aborting\n", name);
|
|
|
|
return sglv_aborted;
|
|
|
|
}
|
|
|
|
|
2008-11-10 14:02:49 +00:00
|
|
|
symbol_picker_t symbol_current_picker = symbol_picker_interactive;
|
|
|
|
|
2004-06-04 00:59:16 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* symbol_get_lvalue
|
|
|
|
*
|
|
|
|
* Get the address of a named symbol.
|
|
|
|
* Return values:
|
|
|
|
* sglv_found: if the symbol is found
|
|
|
|
* sglv_unknown: if the symbol isn't found
|
|
|
|
* sglv_aborted: some error occurred (likely, many symbols of same name exist,
|
|
|
|
* and user didn't pick one of them)
|
|
|
|
*/
|
|
|
|
enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno,
|
|
|
|
struct dbg_lvalue* rtn, BOOL bp_disp)
|
|
|
|
{
|
|
|
|
struct sgv_data sgv;
|
2006-12-02 16:43:03 +00:00
|
|
|
int i;
|
2004-06-04 00:59:16 +00:00
|
|
|
char buffer[512];
|
2019-06-06 23:44:31 +00:00
|
|
|
BOOL opt;
|
2021-10-26 09:46:01 +00:00
|
|
|
struct dbg_frame* frm;
|
2004-06-04 00:59:16 +00:00
|
|
|
|
|
|
|
if (strlen(name) + 4 > sizeof(buffer))
|
|
|
|
{
|
|
|
|
WINE_WARN("Too long symbol (%s)\n", name);
|
|
|
|
return sglv_unknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
sgv.num = 0;
|
|
|
|
sgv.num_thunks = 0;
|
|
|
|
sgv.name = &buffer[2];
|
|
|
|
sgv.do_thunks = DBG_IVAR(AlwaysShowThunks);
|
|
|
|
|
2005-11-17 11:04:39 +00:00
|
|
|
if (strchr(name, '!'))
|
|
|
|
{
|
|
|
|
strcpy(buffer, name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buffer[0] = '*';
|
|
|
|
buffer[1] = '!';
|
|
|
|
strcpy(&buffer[2], name);
|
|
|
|
}
|
2004-06-04 00:59:16 +00:00
|
|
|
|
2004-07-04 00:25:15 +00:00
|
|
|
/* this is a wine specific options to return also ELF modules in the
|
|
|
|
* enumeration
|
|
|
|
*/
|
2019-06-06 23:44:31 +00:00
|
|
|
opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE);
|
2006-08-13 18:46:58 +00:00
|
|
|
SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv);
|
2004-06-04 00:59:16 +00:00
|
|
|
|
2007-03-07 21:04:21 +00:00
|
|
|
if (!sgv.num)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
2007-03-07 21:04:21 +00:00
|
|
|
const char* ptr = strchr(name, '!');
|
|
|
|
if ((ptr && ptr[1] != '_') || (!ptr && *name != '_'))
|
2005-11-17 11:04:39 +00:00
|
|
|
{
|
2007-03-07 21:04:21 +00:00
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
int offset = ptr - name;
|
|
|
|
memcpy(buffer, name, offset + 1);
|
|
|
|
buffer[offset + 1] = '_';
|
|
|
|
strcpy(&buffer[offset + 2], ptr + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buffer[0] = '*';
|
|
|
|
buffer[1] = '!';
|
|
|
|
buffer[2] = '_';
|
|
|
|
strcpy(&buffer[3], name);
|
|
|
|
}
|
|
|
|
SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv);
|
2005-11-17 11:04:39 +00:00
|
|
|
}
|
2004-06-04 00:59:16 +00:00
|
|
|
}
|
2019-06-06 23:44:31 +00:00
|
|
|
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt);
|
2004-06-04 00:59:16 +00:00
|
|
|
|
|
|
|
/* now grab local symbols */
|
2021-12-01 14:30:35 +00:00
|
|
|
if ((frm = stack_get_curr_frame()) && sgv.num < NUMDBGV && !strchr(name, '!'))
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
2021-10-26 09:46:01 +00:00
|
|
|
sgv.frame_offset = frm->linear_frame;
|
2005-11-18 16:27:55 +00:00
|
|
|
SymEnumSymbols(dbg_curr_process->handle, 0, name, sgv_cb, (void*)&sgv);
|
2004-06-04 00:59:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!sgv.num)
|
|
|
|
{
|
|
|
|
dbg_printf("No symbols found for %s\n", name);
|
|
|
|
return sglv_unknown;
|
|
|
|
}
|
|
|
|
|
2006-12-02 16:43:03 +00:00
|
|
|
/* recompute potential offsets for functions (linenumber, skip prolog) */
|
|
|
|
for (i = 0; i < sgv.num; i++)
|
|
|
|
{
|
|
|
|
if (sgv.syms[i].flags & (SYMFLAG_REGISTER|SYMFLAG_REGREL|SYMFLAG_LOCAL|SYMFLAG_THUNK))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (lineno == -1)
|
|
|
|
{
|
|
|
|
struct dbg_type type;
|
|
|
|
ULONG64 addr;
|
|
|
|
|
|
|
|
type.module = sgv.syms[i].lvalue.type.module;
|
|
|
|
type.id = sgv.syms[i].sym_info;
|
|
|
|
if (bp_disp && symbol_get_debug_start(&type, &addr))
|
|
|
|
sgv.syms[i].lvalue.addr.Offset = addr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD disp;
|
2009-12-12 11:19:44 +00:00
|
|
|
IMAGEHLP_LINE64 il;
|
2006-12-02 16:43:03 +00:00
|
|
|
BOOL found = FALSE;
|
|
|
|
|
|
|
|
il.SizeOfStruct = sizeof(il);
|
2009-12-12 11:19:44 +00:00
|
|
|
SymGetLineFromAddr64(dbg_curr_process->handle,
|
|
|
|
(DWORD_PTR)memory_to_linear_addr(&sgv.syms[i].lvalue.addr),
|
|
|
|
&disp, &il);
|
2006-12-02 16:43:03 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (lineno == il.LineNumber)
|
|
|
|
{
|
|
|
|
sgv.syms[i].lvalue.addr.Offset = il.Address;
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2009-12-12 11:19:44 +00:00
|
|
|
} while (SymGetLineNext64(dbg_curr_process->handle, &il));
|
2006-12-02 16:43:03 +00:00
|
|
|
if (!found)
|
|
|
|
WINE_FIXME("No line (%d) found for %s (setting to symbol start)\n",
|
|
|
|
lineno, name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-10 14:02:49 +00:00
|
|
|
if (sgv.num - sgv.num_thunks > 1 || /* many symbols non thunks (and showing only non thunks) */
|
|
|
|
(sgv.num > 1 && DBG_IVAR(AlwaysShowThunks)) || /* many symbols (showing symbols & thunks) */
|
|
|
|
(sgv.num == sgv.num_thunks && sgv.num_thunks > 1))
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
2008-11-10 14:02:49 +00:00
|
|
|
return symbol_current_picker(name, &sgv, rtn);
|
2004-06-04 00:59:16 +00:00
|
|
|
}
|
2008-11-10 14:02:49 +00:00
|
|
|
/* first symbol is the one we want:
|
|
|
|
* - only one symbol found,
|
|
|
|
* - or many symbols but only one non thunk when AlwaysShowThunks is FALSE
|
|
|
|
*/
|
|
|
|
*rtn = sgv.syms[0].lvalue;
|
2004-06-04 00:59:16 +00:00
|
|
|
return sglv_found;
|
|
|
|
}
|
|
|
|
|
2004-09-28 02:13:27 +00:00
|
|
|
BOOL symbol_is_local(const char* name)
|
|
|
|
{
|
|
|
|
struct sgv_data sgv;
|
2021-10-26 09:46:01 +00:00
|
|
|
struct dbg_frame* frm;
|
2004-09-28 02:13:27 +00:00
|
|
|
|
|
|
|
sgv.num = 0;
|
|
|
|
sgv.num_thunks = 0;
|
|
|
|
sgv.name = name;
|
|
|
|
sgv.do_thunks = FALSE;
|
|
|
|
|
2021-10-26 09:46:01 +00:00
|
|
|
if ((frm = stack_get_curr_frame()))
|
2005-11-18 12:05:44 +00:00
|
|
|
{
|
2021-10-26 09:46:01 +00:00
|
|
|
sgv.frame_offset = frm->linear_frame;
|
2004-09-28 02:13:27 +00:00
|
|
|
SymEnumSymbols(dbg_curr_process->handle, 0, name, sgv_cb, (void*)&sgv);
|
2005-11-18 12:05:44 +00:00
|
|
|
}
|
2004-09-28 02:13:27 +00:00
|
|
|
return sgv.num > 0;
|
|
|
|
}
|
|
|
|
|
2004-06-04 00:59:16 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* symbol_read_symtable
|
|
|
|
*
|
|
|
|
* Read a symbol file into the hash table.
|
|
|
|
*/
|
2021-10-04 12:16:23 +00:00
|
|
|
void symbol_read_symtable(const char* filename, ULONG_PTR offset)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
|
|
|
dbg_printf("No longer supported\n");
|
|
|
|
|
|
|
|
#if 0
|
2004-09-28 02:13:27 +00:00
|
|
|
/* FIXME: have to implement SymAddSymbol in dbghelp, but likely we'll need to link
|
|
|
|
* this with an already loaded module !!
|
2004-06-04 00:59:16 +00:00
|
|
|
*/
|
|
|
|
FILE* symbolfile;
|
|
|
|
unsigned addr;
|
|
|
|
char type;
|
|
|
|
char* cpnt;
|
|
|
|
char buffer[256];
|
|
|
|
char name[256];
|
|
|
|
|
|
|
|
if (!(symbolfile = fopen(filename, "r")))
|
|
|
|
{
|
|
|
|
WINE_WARN("Unable to open symbol table %s\n", filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dbg_printf("Reading symbols from file %s\n", filename);
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
fgets(buffer, sizeof(buffer), symbolfile);
|
|
|
|
if (feof(symbolfile)) break;
|
|
|
|
|
|
|
|
/* Strip any text after a # sign (i.e. comments) */
|
|
|
|
cpnt = strchr(buffer, '#');
|
|
|
|
if (cpnt) *cpnt = '\0';
|
|
|
|
|
|
|
|
/* Quietly ignore any lines that have just whitespace */
|
|
|
|
for (cpnt = buffer; *cpnt; cpnt++)
|
|
|
|
{
|
|
|
|
if (*cpnt != ' ' && *cpnt != '\t') break;
|
|
|
|
}
|
|
|
|
if (!*cpnt || *cpnt == '\n') continue;
|
|
|
|
|
|
|
|
if (sscanf(buffer, "%lx %c %s", &addr, &type, name) == 3)
|
|
|
|
{
|
|
|
|
if (value.addr.off + offset < value.addr.off)
|
|
|
|
WINE_WARN("Address wrap around\n");
|
|
|
|
value.addr.off += offset;
|
|
|
|
SymAddSymbol(current_process->handle, BaseOfDll,
|
|
|
|
name, addr, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(symbolfile);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* symbol_get_function_line_status
|
|
|
|
*
|
|
|
|
* Find the symbol nearest to a given address.
|
|
|
|
*/
|
2006-07-26 09:57:27 +00:00
|
|
|
enum dbg_line_status symbol_get_function_line_status(const ADDRESS64* addr)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
2009-12-12 11:19:44 +00:00
|
|
|
IMAGEHLP_LINE64 il;
|
2005-11-17 11:51:53 +00:00
|
|
|
DWORD disp;
|
2005-12-03 17:09:59 +00:00
|
|
|
ULONG64 disp64, start;
|
2009-12-10 14:23:45 +00:00
|
|
|
DWORD_PTR lin = (DWORD_PTR)memory_to_linear_addr(addr);
|
2004-06-04 00:59:16 +00:00
|
|
|
char buffer[sizeof(SYMBOL_INFO) + 256];
|
|
|
|
SYMBOL_INFO* sym = (SYMBOL_INFO*)buffer;
|
2006-12-02 16:43:03 +00:00
|
|
|
struct dbg_type func;
|
2004-06-04 00:59:16 +00:00
|
|
|
|
|
|
|
il.SizeOfStruct = sizeof(il);
|
|
|
|
sym->SizeOfStruct = sizeof(SYMBOL_INFO);
|
|
|
|
sym->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
|
|
|
|
|
|
|
|
/* do we have some info for lin address ? */
|
2005-01-31 11:34:59 +00:00
|
|
|
if (!SymFromAddr(dbg_curr_process->handle, lin, &disp64, sym))
|
2011-01-08 13:09:03 +00:00
|
|
|
{
|
|
|
|
ADDRESS64 jumpee;
|
|
|
|
/* some compilers insert thunks in their code without debug info associated
|
|
|
|
* take care of this situation
|
|
|
|
*/
|
2018-06-12 22:53:16 +00:00
|
|
|
if (dbg_curr_process->be_cpu->is_jump((void*)lin, &jumpee))
|
2011-01-08 13:09:03 +00:00
|
|
|
return symbol_get_function_line_status(&jumpee);
|
2004-06-04 00:59:16 +00:00
|
|
|
return dbg_no_line_info;
|
2011-01-08 13:09:03 +00:00
|
|
|
}
|
2004-06-04 00:59:16 +00:00
|
|
|
|
|
|
|
switch (sym->Tag)
|
|
|
|
{
|
|
|
|
case SymTagThunk:
|
|
|
|
/* FIXME: so far dbghelp doesn't return the 16 <=> 32 thunks
|
|
|
|
* and furthermore, we no longer take care of them !!!
|
|
|
|
*/
|
|
|
|
return dbg_in_a_thunk;
|
|
|
|
case SymTagFunction:
|
|
|
|
case SymTagPublicSymbol: break;
|
|
|
|
default:
|
2022-02-07 07:40:49 +00:00
|
|
|
WINE_FIXME("Unexpected sym-tag 0x%08lx\n", sym->Tag);
|
2004-06-04 00:59:16 +00:00
|
|
|
case SymTagData:
|
|
|
|
return dbg_no_line_info;
|
|
|
|
}
|
|
|
|
/* we should have a function now */
|
2009-12-12 11:19:44 +00:00
|
|
|
if (!SymGetLineFromAddr64(dbg_curr_process->handle, lin, &disp, &il))
|
2004-06-04 00:59:16 +00:00
|
|
|
return dbg_no_line_info;
|
|
|
|
|
2006-12-02 16:43:03 +00:00
|
|
|
func.module = sym->ModBase;
|
2016-03-21 17:30:14 +00:00
|
|
|
func.id = sym->Index;
|
2006-12-02 16:43:03 +00:00
|
|
|
|
|
|
|
if (symbol_get_debug_start(&func, &start) && lin < start)
|
2004-06-04 00:59:16 +00:00
|
|
|
return dbg_not_on_a_line_number;
|
2006-12-02 16:43:03 +00:00
|
|
|
|
2005-12-03 17:09:59 +00:00
|
|
|
if (!sym->Size) sym->Size = 0x100000;
|
|
|
|
if (il.FileName && il.FileName[0] && disp < sym->Size)
|
2004-06-04 00:59:16 +00:00
|
|
|
return (disp == 0) ? dbg_on_a_line_number : dbg_not_on_a_line_number;
|
|
|
|
|
|
|
|
return dbg_no_line_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* symbol_get_line
|
|
|
|
*
|
|
|
|
* Find the symbol nearest to a given address.
|
|
|
|
* Returns sourcefile name and line number in a format that the listing
|
|
|
|
* handler can deal with.
|
|
|
|
*/
|
2009-12-12 11:19:44 +00:00
|
|
|
BOOL symbol_get_line(const char* filename, const char* name,
|
|
|
|
IMAGEHLP_LINE64* line)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
|
|
|
struct sgv_data sgv;
|
|
|
|
char buffer[512];
|
2009-12-10 14:23:45 +00:00
|
|
|
DWORD opt, disp;
|
2013-10-11 20:43:02 +00:00
|
|
|
unsigned i;
|
|
|
|
BOOL found = FALSE;
|
2009-12-12 11:19:44 +00:00
|
|
|
IMAGEHLP_LINE64 il;
|
2004-06-04 00:59:16 +00:00
|
|
|
|
|
|
|
sgv.num = 0;
|
|
|
|
sgv.num_thunks = 0;
|
|
|
|
sgv.name = &buffer[2];
|
|
|
|
sgv.do_thunks = FALSE;
|
|
|
|
|
|
|
|
buffer[0] = '*';
|
|
|
|
buffer[1] = '!';
|
|
|
|
strcpy(&buffer[2], name);
|
|
|
|
|
2004-07-04 00:25:15 +00:00
|
|
|
/* this is a wine specific options to return also ELF modules in the
|
|
|
|
* enumeration
|
|
|
|
*/
|
2019-06-06 23:44:31 +00:00
|
|
|
opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE);
|
2004-06-04 00:59:16 +00:00
|
|
|
if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv))
|
2004-07-04 00:25:15 +00:00
|
|
|
{
|
2019-06-06 23:44:31 +00:00
|
|
|
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt);
|
2006-12-02 16:42:58 +00:00
|
|
|
return FALSE;
|
2004-07-04 00:25:15 +00:00
|
|
|
}
|
2004-06-04 00:59:16 +00:00
|
|
|
|
|
|
|
if (!sgv.num && (name[0] != '_'))
|
|
|
|
{
|
|
|
|
buffer[2] = '_';
|
|
|
|
strcpy(&buffer[3], name);
|
|
|
|
if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv))
|
2004-07-04 00:25:15 +00:00
|
|
|
{
|
2019-06-06 23:44:31 +00:00
|
|
|
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt);
|
2006-12-02 16:42:58 +00:00
|
|
|
return FALSE;
|
2004-07-04 00:25:15 +00:00
|
|
|
}
|
2004-06-04 00:59:16 +00:00
|
|
|
}
|
2019-06-06 23:44:31 +00:00
|
|
|
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt);
|
2004-06-04 00:59:16 +00:00
|
|
|
|
2006-12-02 16:42:58 +00:00
|
|
|
for (i = 0; i < sgv.num; i++)
|
|
|
|
{
|
2009-12-10 14:23:45 +00:00
|
|
|
DWORD_PTR linear = (DWORD_PTR)memory_to_linear_addr(&sgv.syms[i].lvalue.addr);
|
2006-12-02 16:42:58 +00:00
|
|
|
|
|
|
|
il.SizeOfStruct = sizeof(il);
|
2009-12-12 11:19:44 +00:00
|
|
|
if (!SymGetLineFromAddr64(dbg_curr_process->handle, linear, &disp, &il))
|
2006-12-02 16:42:58 +00:00
|
|
|
continue;
|
2009-08-22 05:57:37 +00:00
|
|
|
if (filename && strcmp(il.FileName, filename)) continue;
|
2006-12-02 16:42:58 +00:00
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
WINE_FIXME("Several found, returning first (may not be what you want)...\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
found = TRUE;
|
|
|
|
*line = il;
|
|
|
|
}
|
|
|
|
if (!found)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
|
|
|
if (filename) dbg_printf("No such function %s in %s\n", name, filename);
|
|
|
|
else dbg_printf("No such function %s\n", name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-11-24 21:18:42 +00:00
|
|
|
/******************************************************************
|
2022-09-30 16:15:26 +00:00
|
|
|
* symbol_print_localvalue
|
2006-11-24 21:18:42 +00:00
|
|
|
*
|
|
|
|
* Overall format is:
|
2022-09-30 16:15:26 +00:00
|
|
|
* <value> in non detailed form
|
|
|
|
* <value> (local|pmt <where>) in detailed form
|
2006-11-24 21:18:42 +00:00
|
|
|
* Note <value> can be an error message in case of error
|
|
|
|
*/
|
2022-09-30 16:15:26 +00:00
|
|
|
void symbol_print_localvalue(const SYMBOL_INFO* sym, DWORD_PTR base, BOOL detailed)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
2006-11-24 21:18:42 +00:00
|
|
|
struct dbg_lvalue lvalue;
|
|
|
|
char buffer[64];
|
2004-06-04 00:59:16 +00:00
|
|
|
|
2006-12-02 16:43:34 +00:00
|
|
|
if (fill_sym_lvalue(sym, base, &lvalue, buffer, sizeof(buffer)))
|
2006-11-24 21:18:42 +00:00
|
|
|
{
|
2008-08-06 19:56:24 +00:00
|
|
|
print_value(&lvalue, 0, 1);
|
2006-12-02 16:43:34 +00:00
|
|
|
if (detailed)
|
2012-06-24 11:03:09 +00:00
|
|
|
dbg_printf(" (%s %s)",
|
2006-12-02 16:43:34 +00:00
|
|
|
(sym->Flags & SYMFLAG_PARAMETER) ? "parameter" : "local",
|
|
|
|
buffer);
|
2004-06-04 00:59:16 +00:00
|
|
|
}
|
2006-12-02 16:43:34 +00:00
|
|
|
else
|
2006-11-24 21:18:42 +00:00
|
|
|
{
|
2008-12-05 03:59:30 +00:00
|
|
|
dbg_printf("%s", buffer);
|
2006-12-02 16:43:34 +00:00
|
|
|
if (detailed)
|
|
|
|
dbg_printf(" (%s)",
|
|
|
|
(sym->Flags & SYMFLAG_PARAMETER) ? "parameter" : "local");
|
2006-11-24 21:18:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-17 22:40:19 +00:00
|
|
|
static BOOL CALLBACK info_locals_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx)
|
2006-11-24 21:18:42 +00:00
|
|
|
{
|
2022-09-30 16:15:26 +00:00
|
|
|
DWORD len;
|
|
|
|
WCHAR* nameW;
|
2006-11-24 21:18:42 +00:00
|
|
|
|
2022-09-30 16:15:26 +00:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, sym->Name, -1, NULL, 0);
|
|
|
|
nameW = malloc(len * sizeof(WCHAR));
|
|
|
|
if (nameW)
|
|
|
|
{
|
|
|
|
struct dbg_type type;
|
2006-11-24 21:18:42 +00:00
|
|
|
|
2022-09-30 16:15:26 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, sym->Name, -1, nameW, len);
|
|
|
|
|
|
|
|
type.module = sym->ModBase;
|
|
|
|
type.id = sym->TypeIndex;
|
|
|
|
|
|
|
|
dbg_printf("\t");
|
|
|
|
types_print_type(&type, FALSE, nameW);
|
|
|
|
dbg_printf("=");
|
|
|
|
|
|
|
|
symbol_print_localvalue(sym, (DWORD_PTR)ctx, TRUE);
|
|
|
|
dbg_printf("\n");
|
|
|
|
free(nameW);
|
|
|
|
}
|
2004-06-04 00:59:16 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-11-09 10:03:40 +00:00
|
|
|
BOOL symbol_info_locals(void)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
2006-07-26 09:57:27 +00:00
|
|
|
ADDRESS64 addr;
|
2021-10-26 09:46:01 +00:00
|
|
|
struct dbg_frame* frm;
|
|
|
|
|
|
|
|
if (!(frm = stack_get_curr_frame())) return FALSE;
|
2005-11-29 10:24:04 +00:00
|
|
|
|
|
|
|
addr.Mode = AddrModeFlat;
|
2021-10-26 09:46:01 +00:00
|
|
|
addr.Offset = frm->linear_pc;
|
2005-11-29 10:24:04 +00:00
|
|
|
print_address(&addr, FALSE);
|
2021-12-01 14:30:47 +00:00
|
|
|
dbg_printf(": (%0*Ix)\n", ADDRWIDTH, frm->linear_frame);
|
2021-10-26 09:46:01 +00:00
|
|
|
SymEnumSymbols(dbg_curr_process->handle, 0, NULL, info_locals_cb, (void*)frm->linear_frame);
|
2004-06-04 00:59:16 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-09-17 22:40:19 +00:00
|
|
|
static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
2004-08-22 22:35:36 +00:00
|
|
|
struct dbg_type type;
|
2004-09-28 02:13:27 +00:00
|
|
|
IMAGEHLP_MODULE mi;
|
|
|
|
|
|
|
|
mi.SizeOfStruct = sizeof(mi);
|
|
|
|
|
|
|
|
if (!SymGetModuleInfo(dbg_curr_process->handle, sym->ModBase, &mi))
|
|
|
|
mi.ModuleName[0] = '\0';
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size_t len = strlen(mi.ModuleName);
|
|
|
|
if (len > 5 && !strcmp(mi.ModuleName + len - 5, "<elf>"))
|
|
|
|
mi.ModuleName[len - 5] = '\0';
|
|
|
|
}
|
|
|
|
|
2021-11-26 16:30:16 +00:00
|
|
|
dbg_printf("%0*I64x: %s!%s", ADDRWIDTH, sym->Address, mi.ModuleName, sym->Name);
|
2004-09-28 02:13:27 +00:00
|
|
|
type.id = sym->TypeIndex;
|
|
|
|
type.module = sym->ModBase;
|
2004-06-04 00:59:16 +00:00
|
|
|
|
2005-12-05 11:00:54 +00:00
|
|
|
if (sym->TypeIndex != dbg_itype_none && sym->TypeIndex != 0)
|
2004-06-04 00:59:16 +00:00
|
|
|
{
|
2004-09-28 02:13:27 +00:00
|
|
|
dbg_printf(" ");
|
2022-09-30 16:15:26 +00:00
|
|
|
types_print_type(&type, FALSE, NULL);
|
2004-06-04 00:59:16 +00:00
|
|
|
}
|
2004-09-28 02:13:27 +00:00
|
|
|
dbg_printf("\n");
|
2004-06-04 00:59:16 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void symbol_info(const char* str)
|
|
|
|
{
|
|
|
|
char buffer[512];
|
2019-06-06 23:44:31 +00:00
|
|
|
BOOL opt;
|
2004-06-04 00:59:16 +00:00
|
|
|
|
|
|
|
if (strlen(str) + 3 >= sizeof(buffer))
|
|
|
|
{
|
|
|
|
dbg_printf("Symbol too long (%s)\n", str);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
buffer[0] = '*';
|
|
|
|
buffer[1] = '!';
|
|
|
|
strcpy(&buffer[2], str);
|
2004-07-04 00:25:15 +00:00
|
|
|
/* this is a wine specific options to return also ELF modules in the
|
|
|
|
* enumeration
|
|
|
|
*/
|
2019-06-06 23:44:31 +00:00
|
|
|
opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE);
|
2004-06-04 00:59:16 +00:00
|
|
|
SymEnumSymbols(dbg_curr_process->handle, 0, buffer, symbols_info_cb, NULL);
|
2019-06-06 23:44:31 +00:00
|
|
|
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt);
|
2004-06-04 00:59:16 +00:00
|
|
|
}
|