2004-04-05 22:21:27 +00:00
|
|
|
/*
|
|
|
|
* File symbol.c - management of symbols (lexical tree)
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993, Eric Youngdale.
|
|
|
|
* 2004, Eric Pouech
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2004-04-19 02:58:27 +00:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-05-17 21:08:31 +00:00
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
#include "config.h"
|
2004-05-17 21:08:31 +00:00
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <assert.h>
|
2004-05-17 21:08:31 +00:00
|
|
|
#ifdef HAVE_REGEX_H
|
|
|
|
# include <regex.h>
|
|
|
|
#endif
|
2004-04-05 22:21:27 +00:00
|
|
|
|
2004-05-17 21:08:31 +00:00
|
|
|
#include "wine/debug.h"
|
2004-04-05 22:21:27 +00:00
|
|
|
#include "dbghelp_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
2004-04-30 04:15:41 +00:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
|
2004-04-05 22:21:27 +00:00
|
|
|
|
2004-11-22 18:30:10 +00:00
|
|
|
inline static int cmp_addr(ULONG64 a1, ULONG64 a2)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
if (a1 > a2) return 1;
|
|
|
|
if (a1 < a2) return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-11-22 18:30:10 +00:00
|
|
|
inline static int cmp_sorttab_addr(const struct module* module, int idx, ULONG64 addr)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
2004-11-22 18:30:10 +00:00
|
|
|
ULONG64 ref;
|
2004-04-05 22:21:27 +00:00
|
|
|
|
|
|
|
symt_get_info(&module->addr_sorttab[idx]->symt, TI_GET_ADDRESS, &ref);
|
|
|
|
return cmp_addr(ref, addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
int symt_cmp_addr(const void* p1, const void* p2)
|
|
|
|
{
|
2004-05-18 21:29:09 +00:00
|
|
|
const struct symt* sym1 = *(const struct symt* const *)p1;
|
|
|
|
const struct symt* sym2 = *(const struct symt* const *)p2;
|
2004-11-22 18:30:10 +00:00
|
|
|
ULONG64 a1, a2;
|
2004-04-05 22:21:27 +00:00
|
|
|
|
|
|
|
symt_get_info(sym1, TI_GET_ADDRESS, &a1);
|
|
|
|
symt_get_info(sym2, TI_GET_ADDRESS, &a2);
|
|
|
|
return cmp_addr(a1, a2);
|
|
|
|
}
|
|
|
|
|
2004-04-19 02:58:27 +00:00
|
|
|
static inline void re_append(char** mask, unsigned* len, char ch)
|
|
|
|
{
|
|
|
|
*mask = HeapReAlloc(GetProcessHeap(), 0, *mask, ++(*len));
|
|
|
|
(*mask)[*len - 2] = ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* transforms a dbghelp's regular expression into a POSIX one
|
|
|
|
* Here are the valid dbghelp reg ex characters:
|
|
|
|
* * 0 or more characters
|
|
|
|
* ? a single character
|
|
|
|
* [] list
|
|
|
|
* # 0 or more of preceding char
|
|
|
|
* + 1 or more of preceding char
|
|
|
|
* escapes \ on #, ?, [, ], *, +. don't work on -
|
|
|
|
*/
|
2005-12-19 17:16:35 +00:00
|
|
|
static void compile_regex(const char* str, int numchar, regex_t* re, BOOL _case)
|
2004-04-19 02:58:27 +00:00
|
|
|
{
|
|
|
|
char* mask = HeapAlloc(GetProcessHeap(), 0, 1);
|
|
|
|
unsigned len = 1;
|
|
|
|
BOOL in_escape = FALSE;
|
2005-12-19 17:16:35 +00:00
|
|
|
unsigned flags = REG_NOSUB;
|
2004-04-19 02:58:27 +00:00
|
|
|
|
|
|
|
re_append(&mask, &len, '^');
|
2004-05-24 19:08:19 +00:00
|
|
|
|
|
|
|
while (*str && numchar--)
|
2004-04-19 02:58:27 +00:00
|
|
|
{
|
|
|
|
/* FIXME: this shouldn't be valid on '-' */
|
|
|
|
if (in_escape)
|
|
|
|
{
|
|
|
|
re_append(&mask, &len, '\\');
|
|
|
|
re_append(&mask, &len, *str);
|
|
|
|
in_escape = FALSE;
|
|
|
|
}
|
|
|
|
else switch (*str)
|
|
|
|
{
|
|
|
|
case '\\': in_escape = TRUE; break;
|
|
|
|
case '*': re_append(&mask, &len, '.'); re_append(&mask, &len, '*'); break;
|
|
|
|
case '?': re_append(&mask, &len, '.'); break;
|
|
|
|
case '#': re_append(&mask, &len, '*'); break;
|
|
|
|
/* escape some valid characters in dbghelp reg exp:s */
|
|
|
|
case '$': re_append(&mask, &len, '\\'); re_append(&mask, &len, '$'); break;
|
|
|
|
/* +, [, ], - are the same in dbghelp & POSIX, use them as any other char */
|
|
|
|
default: re_append(&mask, &len, *str); break;
|
|
|
|
}
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
if (in_escape)
|
|
|
|
{
|
|
|
|
re_append(&mask, &len, '\\');
|
|
|
|
re_append(&mask, &len, '\\');
|
|
|
|
}
|
|
|
|
re_append(&mask, &len, '$');
|
|
|
|
mask[len - 1] = '\0';
|
2005-12-19 17:16:35 +00:00
|
|
|
if (_case) flags |= REG_ICASE;
|
|
|
|
if (regcomp(re, mask, flags)) FIXME("Couldn't compile %s\n", mask);
|
2004-04-19 02:58:27 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, mask);
|
|
|
|
}
|
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
struct symt_compiland* symt_new_compiland(struct module* module, const char* name)
|
|
|
|
{
|
|
|
|
struct symt_compiland* sym;
|
|
|
|
|
2004-04-30 04:15:41 +00:00
|
|
|
TRACE_(dbghelp_symt)("Adding compiland symbol %s:%s\n",
|
|
|
|
module->module.ModuleName, name);
|
2004-04-05 22:21:27 +00:00
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagCompiland;
|
|
|
|
sym->source = source_new(module, name);
|
|
|
|
vector_init(&sym->vchildren, sizeof(struct symt*), 32);
|
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct symt_public* symt_new_public(struct module* module,
|
|
|
|
struct symt_compiland* compiland,
|
|
|
|
const char* name,
|
|
|
|
unsigned long address, unsigned size,
|
|
|
|
BOOL in_code, BOOL is_func)
|
|
|
|
{
|
|
|
|
struct symt_public* sym;
|
|
|
|
struct symt** p;
|
|
|
|
|
2004-04-30 04:15:41 +00:00
|
|
|
TRACE_(dbghelp_symt)("Adding public symbol %s:%s @%lx\n",
|
|
|
|
module->module.ModuleName, name, address);
|
2004-08-30 19:31:13 +00:00
|
|
|
if ((dbghelp_options & SYMOPT_AUTO_PUBLICS) &&
|
|
|
|
symt_find_nearest(module, address) != -1)
|
|
|
|
return NULL;
|
2004-04-05 22:21:27 +00:00
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagPublicSymbol;
|
|
|
|
sym->hash_elt.name = pool_strdup(&module->pool, name);
|
|
|
|
hash_table_add(&module->ht_symbols, &sym->hash_elt);
|
|
|
|
module->sortlist_valid = FALSE;
|
|
|
|
sym->container = compiland ? &compiland->symt : NULL;
|
|
|
|
sym->address = address;
|
|
|
|
sym->size = size;
|
|
|
|
sym->in_code = in_code;
|
|
|
|
sym->is_function = is_func;
|
|
|
|
if (compiland)
|
|
|
|
{
|
|
|
|
p = vector_add(&compiland->vchildren, &module->pool);
|
|
|
|
*p = &sym->symt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct symt_data* symt_new_global_variable(struct module* module,
|
|
|
|
struct symt_compiland* compiland,
|
|
|
|
const char* name, unsigned is_static,
|
|
|
|
unsigned long addr, unsigned long size,
|
|
|
|
struct symt* type)
|
|
|
|
{
|
|
|
|
struct symt_data* sym;
|
|
|
|
struct symt** p;
|
2005-11-17 11:51:53 +00:00
|
|
|
DWORD64 tsz;
|
2004-04-05 22:21:27 +00:00
|
|
|
|
2004-04-30 04:15:41 +00:00
|
|
|
TRACE_(dbghelp_symt)("Adding global symbol %s:%s @%lx %p\n",
|
|
|
|
module->module.ModuleName, name, addr, type);
|
2004-04-05 22:21:27 +00:00
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagData;
|
|
|
|
sym->hash_elt.name = pool_strdup(&module->pool, name);
|
|
|
|
hash_table_add(&module->ht_symbols, &sym->hash_elt);
|
|
|
|
module->sortlist_valid = FALSE;
|
|
|
|
sym->kind = is_static ? DataIsFileStatic : DataIsGlobal;
|
|
|
|
sym->container = compiland ? &compiland->symt : NULL;
|
|
|
|
sym->type = type;
|
|
|
|
sym->u.address = addr;
|
2004-05-18 21:29:09 +00:00
|
|
|
if (type && size && symt_get_info(type, TI_GET_LENGTH, &tsz))
|
|
|
|
{
|
|
|
|
if (tsz != size)
|
2005-11-17 11:51:53 +00:00
|
|
|
FIXME("Size mismatch for %s.%s between type (%s) and src (%lu)\n",
|
|
|
|
module->module.ModuleName, name,
|
|
|
|
wine_dbgstr_longlong(tsz), size);
|
2004-05-18 21:29:09 +00:00
|
|
|
}
|
2004-04-05 22:21:27 +00:00
|
|
|
if (compiland)
|
|
|
|
{
|
|
|
|
p = vector_add(&compiland->vchildren, &module->pool);
|
|
|
|
*p = &sym->symt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct symt_function* symt_new_function(struct module* module,
|
|
|
|
struct symt_compiland* compiland,
|
|
|
|
const char* name,
|
|
|
|
unsigned long addr, unsigned long size,
|
2004-04-19 02:58:27 +00:00
|
|
|
struct symt* sig_type)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
struct symt_function* sym;
|
|
|
|
struct symt** p;
|
|
|
|
|
2004-04-30 04:15:41 +00:00
|
|
|
TRACE_(dbghelp_symt)("Adding global function %s:%s @%lx-%lx\n",
|
|
|
|
module->module.ModuleName, name, addr, addr + size - 1);
|
2004-04-19 02:58:27 +00:00
|
|
|
|
|
|
|
assert(!sig_type || sig_type->tag == SymTagFunctionType);
|
2004-04-05 22:21:27 +00:00
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagFunction;
|
|
|
|
sym->hash_elt.name = pool_strdup(&module->pool, name);
|
|
|
|
hash_table_add(&module->ht_symbols, &sym->hash_elt);
|
|
|
|
module->sortlist_valid = FALSE;
|
|
|
|
sym->container = &compiland->symt;
|
2004-05-18 21:29:09 +00:00
|
|
|
sym->address = addr;
|
2004-04-19 02:58:27 +00:00
|
|
|
sym->type = sig_type;
|
2004-04-05 22:21:27 +00:00
|
|
|
sym->size = size;
|
|
|
|
vector_init(&sym->vlines, sizeof(struct line_info), 64);
|
|
|
|
vector_init(&sym->vchildren, sizeof(struct symt*), 8);
|
|
|
|
if (compiland)
|
|
|
|
{
|
|
|
|
p = vector_add(&compiland->vchildren, &module->pool);
|
|
|
|
*p = &sym->symt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
void symt_add_func_line(struct module* module, struct symt_function* func,
|
|
|
|
unsigned source_idx, int line_num, unsigned long offset)
|
|
|
|
{
|
|
|
|
struct line_info* dli;
|
|
|
|
BOOL last_matches = FALSE;
|
|
|
|
|
|
|
|
if (func == NULL || !(dbghelp_options & SYMOPT_LOAD_LINES)) return;
|
|
|
|
|
2004-04-30 04:15:41 +00:00
|
|
|
TRACE_(dbghelp_symt)("(%p)%s:%lx %s:%u\n",
|
|
|
|
func, func->hash_elt.name, offset,
|
|
|
|
source_get(module, source_idx), line_num);
|
2004-04-05 22:21:27 +00:00
|
|
|
|
|
|
|
assert(func->symt.tag == SymTagFunction);
|
|
|
|
|
|
|
|
dli = NULL;
|
|
|
|
while ((dli = vector_iter_down(&func->vlines, dli)))
|
|
|
|
{
|
2004-04-30 04:15:41 +00:00
|
|
|
if (dli->is_source_file)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
last_matches = (source_idx == dli->u.source_file);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!last_matches)
|
|
|
|
{
|
|
|
|
/* we shouldn't have line changes on first line of function */
|
|
|
|
dli = vector_add(&func->vlines, &module->pool);
|
2004-04-30 04:15:41 +00:00
|
|
|
dli->is_source_file = 1;
|
|
|
|
dli->is_first = dli->is_last = 0;
|
|
|
|
dli->line_number = 0;
|
|
|
|
dli->u.source_file = source_idx;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
dli = vector_add(&func->vlines, &module->pool);
|
2004-04-30 04:15:41 +00:00
|
|
|
dli->is_source_file = 0;
|
|
|
|
dli->is_first = dli->is_last = 0;
|
|
|
|
dli->line_number = line_num;
|
2004-05-18 21:29:09 +00:00
|
|
|
dli->u.pc_offset = func->address + offset;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct symt_data* symt_add_func_local(struct module* module,
|
|
|
|
struct symt_function* func,
|
|
|
|
int regno, int offset,
|
|
|
|
struct symt_block* block,
|
|
|
|
struct symt* type, const char* name)
|
|
|
|
{
|
|
|
|
struct symt_data* locsym;
|
|
|
|
struct symt** p;
|
|
|
|
|
|
|
|
assert(func);
|
|
|
|
assert(func->symt.tag == SymTagFunction);
|
|
|
|
|
2004-04-30 04:15:41 +00:00
|
|
|
TRACE_(dbghelp_symt)("Adding local symbol (%s:%s): %s %p\n",
|
|
|
|
module->module.ModuleName, func->hash_elt.name,
|
|
|
|
name, type);
|
2004-04-05 22:21:27 +00:00
|
|
|
locsym = pool_alloc(&module->pool, sizeof(*locsym));
|
|
|
|
locsym->symt.tag = SymTagData;
|
|
|
|
locsym->hash_elt.name = pool_strdup(&module->pool, name);
|
|
|
|
locsym->hash_elt.next = NULL;
|
2004-04-19 02:58:27 +00:00
|
|
|
locsym->kind = (offset < 0) ? DataIsParam : DataIsLocal;
|
2004-04-05 22:21:27 +00:00
|
|
|
locsym->container = &block->symt;
|
|
|
|
locsym->type = type;
|
|
|
|
if (regno)
|
|
|
|
{
|
2004-04-30 04:15:41 +00:00
|
|
|
locsym->u.s.reg_id = regno;
|
|
|
|
locsym->u.s.offset = 0;
|
|
|
|
locsym->u.s.length = 0;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-04-30 04:15:41 +00:00
|
|
|
locsym->u.s.reg_id = 0;
|
|
|
|
locsym->u.s.offset = offset * 8;
|
|
|
|
locsym->u.s.length = 0;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
if (block)
|
|
|
|
p = vector_add(&block->vchildren, &module->pool);
|
|
|
|
else
|
|
|
|
p = vector_add(&func->vchildren, &module->pool);
|
|
|
|
*p = &locsym->symt;
|
|
|
|
return locsym;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct symt_block* symt_open_func_block(struct module* module,
|
|
|
|
struct symt_function* func,
|
|
|
|
struct symt_block* parent_block,
|
2004-04-19 02:58:27 +00:00
|
|
|
unsigned pc, unsigned len)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
struct symt_block* block;
|
|
|
|
struct symt** p;
|
|
|
|
|
|
|
|
assert(func);
|
|
|
|
assert(func->symt.tag == SymTagFunction);
|
|
|
|
|
|
|
|
assert(!parent_block || parent_block->symt.tag == SymTagBlock);
|
|
|
|
block = pool_alloc(&module->pool, sizeof(*block));
|
2004-04-19 02:58:27 +00:00
|
|
|
block->symt.tag = SymTagBlock;
|
2004-05-18 21:29:09 +00:00
|
|
|
block->address = func->address + pc;
|
2004-04-19 02:58:27 +00:00
|
|
|
block->size = len;
|
2004-04-05 22:21:27 +00:00
|
|
|
block->container = parent_block ? &parent_block->symt : &func->symt;
|
|
|
|
vector_init(&block->vchildren, sizeof(struct symt*), 4);
|
|
|
|
if (parent_block)
|
|
|
|
p = vector_add(&parent_block->vchildren, &module->pool);
|
|
|
|
else
|
|
|
|
p = vector_add(&func->vchildren, &module->pool);
|
|
|
|
*p = &block->symt;
|
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct symt_block* symt_close_func_block(struct module* module,
|
|
|
|
struct symt_function* func,
|
|
|
|
struct symt_block* block, unsigned pc)
|
|
|
|
{
|
|
|
|
assert(func->symt.tag == SymTagFunction);
|
|
|
|
|
2004-05-18 21:29:09 +00:00
|
|
|
if (pc) block->size = func->address + pc - block->address;
|
2004-04-05 22:21:27 +00:00
|
|
|
return (block->container->tag == SymTagBlock) ?
|
|
|
|
GET_ENTRY(block->container, struct symt_block, symt) : NULL;
|
|
|
|
}
|
|
|
|
|
2004-04-19 02:58:27 +00:00
|
|
|
struct symt_function_point* symt_add_function_point(struct module* module,
|
|
|
|
struct symt_function* func,
|
|
|
|
enum SymTagEnum point,
|
|
|
|
unsigned offset, const char* name)
|
|
|
|
{
|
|
|
|
struct symt_function_point* sym;
|
|
|
|
struct symt** p;
|
|
|
|
|
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = point;
|
|
|
|
sym->parent = func;
|
|
|
|
sym->offset = offset;
|
|
|
|
sym->name = name ? pool_strdup(&module->pool, name) : NULL;
|
|
|
|
p = vector_add(&func->vchildren, &module->pool);
|
|
|
|
*p = &sym->symt;
|
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
BOOL symt_normalize_function(struct module* module, struct symt_function* func)
|
|
|
|
{
|
|
|
|
unsigned len;
|
|
|
|
struct line_info* dli;
|
|
|
|
|
2004-04-19 02:58:27 +00:00
|
|
|
assert(func);
|
2004-04-05 22:21:27 +00:00
|
|
|
/* We aren't adding any more locals or line numbers to this function.
|
|
|
|
* Free any spare memory that we might have allocated.
|
|
|
|
*/
|
|
|
|
assert(func->symt.tag == SymTagFunction);
|
|
|
|
|
|
|
|
/* EPP vector_pool_normalize(&func->vlines, &module->pool); */
|
|
|
|
/* EPP vector_pool_normalize(&func->vchildren, &module->pool); */
|
|
|
|
|
|
|
|
len = vector_length(&func->vlines);
|
|
|
|
if (len--)
|
|
|
|
{
|
2004-04-30 04:15:41 +00:00
|
|
|
dli = vector_at(&func->vlines, 0); dli->is_first = 1;
|
|
|
|
dli = vector_at(&func->vlines, len); dli->is_last = 1;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-05-18 21:29:09 +00:00
|
|
|
struct symt_thunk* symt_new_thunk(struct module* module,
|
|
|
|
struct symt_compiland* compiland,
|
|
|
|
const char* name, THUNK_ORDINAL ord,
|
|
|
|
unsigned long addr, unsigned long size)
|
|
|
|
{
|
|
|
|
struct symt_thunk* sym;
|
|
|
|
|
|
|
|
TRACE_(dbghelp_symt)("Adding global thunk %s:%s @%lx-%lx\n",
|
|
|
|
module->module.ModuleName, name, addr, addr + size - 1);
|
|
|
|
|
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagThunk;
|
|
|
|
sym->hash_elt.name = pool_strdup(&module->pool, name);
|
|
|
|
hash_table_add(&module->ht_symbols, &sym->hash_elt);
|
|
|
|
module->sortlist_valid = FALSE;
|
|
|
|
sym->container = &compiland->symt;
|
|
|
|
sym->address = addr;
|
|
|
|
sym->size = size;
|
|
|
|
sym->ordinal = ord;
|
|
|
|
if (compiland)
|
|
|
|
{
|
|
|
|
struct symt** p;
|
|
|
|
p = vector_add(&compiland->vchildren, &module->pool);
|
|
|
|
*p = &sym->symt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
/* expect sym_info->MaxNameLen to be set before being called */
|
|
|
|
static void symt_fill_sym_info(const struct module* module,
|
|
|
|
const struct symt* sym, SYMBOL_INFO* sym_info)
|
|
|
|
{
|
|
|
|
const char* name;
|
2005-11-17 11:51:53 +00:00
|
|
|
DWORD64 size;
|
2004-04-05 22:21:27 +00:00
|
|
|
|
2005-12-05 11:00:54 +00:00
|
|
|
if (!symt_get_info(sym, TI_GET_TYPE, &sym_info->TypeIndex))
|
|
|
|
sym_info->TypeIndex = 0;
|
|
|
|
sym_info->info = (DWORD)sym;
|
2005-12-19 17:20:47 +00:00
|
|
|
if (!symt_get_info(sym, TI_GET_LENGTH, &size) &&
|
|
|
|
sym_info->TypeIndex &&
|
|
|
|
!symt_get_info((struct symt*)sym_info->TypeIndex, TI_GET_LENGTH, &size))
|
|
|
|
size = 0;
|
2005-11-17 11:51:53 +00:00
|
|
|
sym_info->Size = (DWORD)size;
|
2004-04-05 22:21:27 +00:00
|
|
|
sym_info->ModBase = module->module.BaseOfImage;
|
|
|
|
sym_info->Flags = 0;
|
|
|
|
switch (sym->tag)
|
|
|
|
{
|
|
|
|
case SymTagData:
|
|
|
|
{
|
2004-05-18 21:29:09 +00:00
|
|
|
const struct symt_data* data = (const struct symt_data*)sym;
|
2004-04-30 04:15:41 +00:00
|
|
|
switch (data->kind)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
2004-04-30 04:15:41 +00:00
|
|
|
case DataIsLocal:
|
|
|
|
case DataIsParam:
|
|
|
|
if (data->u.s.reg_id)
|
|
|
|
{
|
2005-11-18 12:05:44 +00:00
|
|
|
sym_info->Flags |= SYMFLAG_REGISTER;
|
2004-04-30 04:15:41 +00:00
|
|
|
sym_info->Register = data->u.s.reg_id;
|
|
|
|
sym_info->Address = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (data->u.s.offset < 0)
|
|
|
|
sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_FRAMEREL;
|
|
|
|
else
|
2005-11-18 12:05:44 +00:00
|
|
|
sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_PARAMETER | SYMFLAG_FRAMEREL;
|
2004-10-05 18:15:29 +00:00
|
|
|
/* FIXME: needed ? moreover, it's i386 dependent !!! */
|
2004-09-27 20:31:42 +00:00
|
|
|
sym_info->Register = CV_REG_EBP;
|
2005-11-18 12:05:44 +00:00
|
|
|
sym_info->Address = data->u.s.offset / 8;
|
2004-04-30 04:15:41 +00:00
|
|
|
}
|
2004-04-05 22:21:27 +00:00
|
|
|
break;
|
2004-04-30 04:15:41 +00:00
|
|
|
case DataIsGlobal:
|
|
|
|
case DataIsFileStatic:
|
2004-04-05 22:21:27 +00:00
|
|
|
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
|
|
|
|
sym_info->Register = 0;
|
|
|
|
break;
|
2004-04-30 04:15:41 +00:00
|
|
|
case DataIsConstant:
|
2004-04-05 22:21:27 +00:00
|
|
|
sym_info->Flags |= SYMFLAG_VALUEPRESENT;
|
2004-04-19 02:58:27 +00:00
|
|
|
switch (data->u.value.n1.n2.vt)
|
|
|
|
{
|
|
|
|
case VT_I4: sym_info->Value = (ULONG)data->u.value.n1.n2.n3.lVal; break;
|
|
|
|
case VT_I2: sym_info->Value = (ULONG)(long)data->u.value.n1.n2.n3.iVal; break;
|
|
|
|
case VT_I1: sym_info->Value = (ULONG)(long)data->u.value.n1.n2.n3.cVal; break;
|
|
|
|
case VT_UI4: sym_info->Value = (ULONG)data->u.value.n1.n2.n3.ulVal; break;
|
|
|
|
case VT_UI2: sym_info->Value = (ULONG)data->u.value.n1.n2.n3.uiVal; break;
|
|
|
|
case VT_UI1: sym_info->Value = (ULONG)data->u.value.n1.n2.n3.bVal; break;
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported variant type (%u)\n", data->u.value.n1.n2.vt);
|
|
|
|
}
|
2004-04-05 22:21:27 +00:00
|
|
|
break;
|
|
|
|
default:
|
2004-04-30 04:15:41 +00:00
|
|
|
FIXME("Unhandled kind (%u) in sym data\n", data->kind);
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SymTagPublicSymbol:
|
|
|
|
sym_info->Flags |= SYMFLAG_EXPORT;
|
|
|
|
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
|
|
|
|
break;
|
|
|
|
case SymTagFunction:
|
|
|
|
sym_info->Flags |= SYMFLAG_FUNCTION;
|
|
|
|
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
|
|
|
|
break;
|
2004-05-18 21:29:09 +00:00
|
|
|
case SymTagThunk:
|
|
|
|
sym_info->Flags |= SYMFLAG_THUNK;
|
|
|
|
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
|
|
|
|
break;
|
2004-04-05 22:21:27 +00:00
|
|
|
default:
|
|
|
|
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
|
|
|
|
sym_info->Register = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sym_info->Scope = 0; /* FIXME */
|
|
|
|
sym_info->Tag = sym->tag;
|
|
|
|
name = symt_get_name(sym);
|
|
|
|
if (sym_info->MaxNameLen)
|
|
|
|
{
|
2004-11-19 18:02:47 +00:00
|
|
|
if (sym->tag != SymTagPublicSymbol || !(dbghelp_options & SYMOPT_UNDNAME) ||
|
2005-03-29 11:30:57 +00:00
|
|
|
(sym_info->NameLen = UnDecorateSymbolName(name, sym_info->Name,
|
2004-11-19 18:02:47 +00:00
|
|
|
sym_info->MaxNameLen, UNDNAME_COMPLETE) == 0))
|
|
|
|
{
|
|
|
|
sym_info->NameLen = min(strlen(name), sym_info->MaxNameLen - 1);
|
2005-03-28 14:17:51 +00:00
|
|
|
memcpy(sym_info->Name, name, sym_info->NameLen);
|
2004-11-19 18:02:47 +00:00
|
|
|
sym_info->Name[sym_info->NameLen] = '\0';
|
|
|
|
}
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
2004-10-11 21:00:17 +00:00
|
|
|
TRACE_(dbghelp_symt)("%p => %s %lu %s\n",
|
|
|
|
sym, sym_info->Name, sym_info->Size,
|
|
|
|
wine_dbgstr_longlong(sym_info->Address));
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
|
2004-05-24 19:08:19 +00:00
|
|
|
static BOOL symt_enum_module(struct module* module, regex_t* regex,
|
2004-04-05 22:21:27 +00:00
|
|
|
PSYM_ENUMERATESYMBOLS_CALLBACK cb, PVOID user)
|
|
|
|
{
|
|
|
|
char buffer[sizeof(SYMBOL_INFO) + 256];
|
|
|
|
SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
|
|
|
|
void* ptr;
|
|
|
|
struct symt_ht* sym = NULL;
|
|
|
|
struct hash_table_iter hti;
|
|
|
|
|
|
|
|
hash_table_iter_init(&module->ht_symbols, &hti, NULL);
|
|
|
|
while ((ptr = hash_table_iter_up(&hti)))
|
|
|
|
{
|
|
|
|
sym = GET_ENTRY(ptr, struct symt_ht, hash_elt);
|
|
|
|
if (sym->hash_elt.name &&
|
2004-05-24 19:08:19 +00:00
|
|
|
regexec(regex, sym->hash_elt.name, 0, NULL, 0) == 0)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
sym_info->SizeOfStruct = sizeof(SYMBOL_INFO);
|
|
|
|
sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
|
|
|
|
symt_fill_sym_info(module, &sym->symt, sym_info);
|
2004-07-04 00:10:54 +00:00
|
|
|
if (!cb(sym_info, sym_info->Size, user)) return TRUE;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
2004-07-04 00:10:54 +00:00
|
|
|
return FALSE;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* resort_symbols
|
|
|
|
*
|
|
|
|
* Rebuild sorted list of symbols for a module.
|
|
|
|
*/
|
|
|
|
static BOOL resort_symbols(struct module* module)
|
|
|
|
{
|
|
|
|
int nsym = 0;
|
|
|
|
void* ptr;
|
|
|
|
struct symt_ht* sym;
|
|
|
|
struct hash_table_iter hti;
|
|
|
|
|
|
|
|
hash_table_iter_init(&module->ht_symbols, &hti, NULL);
|
|
|
|
while ((ptr = hash_table_iter_up(&hti)))
|
|
|
|
nsym++;
|
|
|
|
|
|
|
|
if (!(module->module.NumSyms = nsym)) return FALSE;
|
|
|
|
|
|
|
|
if (module->addr_sorttab)
|
|
|
|
module->addr_sorttab = HeapReAlloc(GetProcessHeap(), 0,
|
|
|
|
module->addr_sorttab,
|
|
|
|
nsym * sizeof(struct symt_ht*));
|
|
|
|
else
|
|
|
|
module->addr_sorttab = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
nsym * sizeof(struct symt_ht*));
|
|
|
|
if (!module->addr_sorttab) return FALSE;
|
|
|
|
|
|
|
|
nsym = 0;
|
|
|
|
hash_table_iter_init(&module->ht_symbols, &hti, NULL);
|
|
|
|
while ((ptr = hash_table_iter_up(&hti)))
|
|
|
|
{
|
|
|
|
sym = GET_ENTRY(ptr, struct symt_ht, hash_elt);
|
|
|
|
assert(sym);
|
|
|
|
module->addr_sorttab[nsym++] = sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort(module->addr_sorttab, nsym, sizeof(struct symt_ht*), symt_cmp_addr);
|
|
|
|
return module->sortlist_valid = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* assume addr is in module */
|
2004-05-18 21:29:09 +00:00
|
|
|
int symt_find_nearest(struct module* module, DWORD addr)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
int mid, high, low;
|
2005-11-17 11:51:53 +00:00
|
|
|
ULONG64 ref_addr, ref_size;
|
2004-04-05 22:21:27 +00:00
|
|
|
|
2004-08-09 18:50:21 +00:00
|
|
|
if (!module->sortlist_valid || !module->addr_sorttab)
|
|
|
|
{
|
|
|
|
if (!resort_symbols(module)) return -1;
|
|
|
|
}
|
2004-04-05 22:21:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Binary search to find closest symbol.
|
|
|
|
*/
|
|
|
|
low = 0;
|
|
|
|
high = module->module.NumSyms;
|
2004-05-18 21:29:09 +00:00
|
|
|
|
2004-05-24 19:08:19 +00:00
|
|
|
symt_get_info(&module->addr_sorttab[0]->symt, TI_GET_ADDRESS, &ref_addr);
|
|
|
|
if (addr < ref_addr) return -1;
|
2004-05-18 21:29:09 +00:00
|
|
|
if (high)
|
|
|
|
{
|
2004-05-24 19:08:19 +00:00
|
|
|
symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_ADDRESS, &ref_addr);
|
|
|
|
if (!symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_LENGTH, &ref_size) || !ref_size)
|
|
|
|
ref_size = 0x1000; /* arbitrary value */
|
|
|
|
if (addr >= ref_addr + ref_size) return -1;
|
2004-05-18 21:29:09 +00:00
|
|
|
}
|
2004-04-05 22:21:27 +00:00
|
|
|
|
|
|
|
while (high > low + 1)
|
|
|
|
{
|
|
|
|
mid = (high + low) / 2;
|
|
|
|
if (cmp_sorttab_addr(module, mid, addr) < 0)
|
|
|
|
low = mid;
|
|
|
|
else
|
|
|
|
high = mid;
|
|
|
|
}
|
|
|
|
if (low != high && high != module->module.NumSyms &&
|
|
|
|
cmp_sorttab_addr(module, high, addr) <= 0)
|
|
|
|
low = high;
|
|
|
|
|
|
|
|
/* If found symbol is a public symbol, check if there are any other entries that
|
|
|
|
* might also have the same address, but would get better information
|
|
|
|
*/
|
|
|
|
if (module->addr_sorttab[low]->symt.tag == SymTagPublicSymbol)
|
|
|
|
{
|
2004-05-24 19:08:19 +00:00
|
|
|
symt_get_info(&module->addr_sorttab[low]->symt, TI_GET_ADDRESS, &ref_addr);
|
2004-04-05 22:21:27 +00:00
|
|
|
if (low > 0 &&
|
|
|
|
module->addr_sorttab[low - 1]->symt.tag != SymTagPublicSymbol &&
|
2004-05-24 19:08:19 +00:00
|
|
|
!cmp_sorttab_addr(module, low - 1, ref_addr))
|
2004-04-05 22:21:27 +00:00
|
|
|
low--;
|
|
|
|
else if (low < module->module.NumSyms - 1 &&
|
|
|
|
module->addr_sorttab[low + 1]->symt.tag != SymTagPublicSymbol &&
|
2004-05-24 19:08:19 +00:00
|
|
|
!cmp_sorttab_addr(module, low + 1, ref_addr))
|
2004-04-05 22:21:27 +00:00
|
|
|
low++;
|
|
|
|
}
|
2004-05-24 19:08:19 +00:00
|
|
|
/* finally check that we fit into the found symbol */
|
|
|
|
symt_get_info(&module->addr_sorttab[low]->symt, TI_GET_ADDRESS, &ref_addr);
|
|
|
|
if (addr < ref_addr) return -1;
|
|
|
|
if (!symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_LENGTH, &ref_size) || !ref_size)
|
|
|
|
ref_size = 0x1000; /* arbitrary value */
|
|
|
|
if (addr >= ref_addr + ref_size) return -1;
|
2004-04-05 22:21:27 +00:00
|
|
|
|
|
|
|
return low;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL symt_enum_locals_helper(struct process* pcs, struct module* module,
|
|
|
|
regex_t* preg, PSYM_ENUMERATESYMBOLS_CALLBACK cb,
|
|
|
|
PVOID user, SYMBOL_INFO* sym_info,
|
|
|
|
struct vector* v)
|
|
|
|
{
|
|
|
|
struct symt** plsym = NULL;
|
|
|
|
struct symt* lsym = NULL;
|
|
|
|
DWORD pc = pcs->ctx_frame.InstructionOffset;
|
|
|
|
|
|
|
|
while ((plsym = vector_iter_up(v, plsym)))
|
|
|
|
{
|
|
|
|
lsym = *plsym;
|
|
|
|
switch (lsym->tag)
|
|
|
|
{
|
|
|
|
case SymTagBlock:
|
|
|
|
{
|
|
|
|
struct symt_block* block = (struct symt_block*)lsym;
|
|
|
|
if (pc < block->address || block->address + block->size <= pc)
|
|
|
|
continue;
|
|
|
|
if (!symt_enum_locals_helper(pcs, module, preg, cb, user,
|
|
|
|
sym_info, &block->vchildren))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SymTagData:
|
|
|
|
if (regexec(preg, symt_get_name(lsym), 0, NULL, 0) == 0)
|
|
|
|
{
|
|
|
|
symt_fill_sym_info(module, lsym, sym_info);
|
|
|
|
if (!cb(sym_info, sym_info->Size, user))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2004-04-19 02:58:27 +00:00
|
|
|
case SymTagLabel:
|
|
|
|
case SymTagFuncDebugStart:
|
|
|
|
case SymTagFuncDebugEnd:
|
|
|
|
break;
|
2004-04-05 22:21:27 +00:00
|
|
|
default:
|
|
|
|
FIXME("Unknown type: %u (%x)\n", lsym->tag, lsym->tag);
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL symt_enum_locals(struct process* pcs, const char* mask,
|
|
|
|
PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
|
|
|
|
PVOID UserContext)
|
|
|
|
{
|
|
|
|
struct module* module;
|
|
|
|
struct symt_ht* sym;
|
|
|
|
char buffer[sizeof(SYMBOL_INFO) + 256];
|
|
|
|
SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
|
|
|
|
DWORD pc = pcs->ctx_frame.InstructionOffset;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
sym_info->SizeOfStruct = sizeof(*sym_info);
|
|
|
|
sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
|
|
|
|
|
|
|
|
module = module_find_by_addr(pcs, pc, DMT_UNKNOWN);
|
|
|
|
if (!(module = module_get_debug(pcs, module))) return FALSE;
|
|
|
|
if ((idx = symt_find_nearest(module, pc)) == -1) return FALSE;
|
|
|
|
|
|
|
|
sym = module->addr_sorttab[idx];
|
|
|
|
if (sym->symt.tag == SymTagFunction)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
regex_t preg;
|
|
|
|
|
2005-12-26 11:57:26 +00:00
|
|
|
compile_regex(mask ? mask : "*", -1, &preg,
|
|
|
|
dbghelp_options & SYMOPT_CASE_INSENSITIVE);
|
2004-04-05 22:21:27 +00:00
|
|
|
ret = symt_enum_locals_helper(pcs, module, &preg, EnumSymbolsCallback,
|
|
|
|
UserContext, sym_info,
|
|
|
|
&((struct symt_function*)sym)->vchildren);
|
|
|
|
regfree(&preg);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
symt_fill_sym_info(module, &sym->symt, sym_info);
|
|
|
|
return EnumSymbolsCallback(sym_info, sym_info->Size, UserContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymEnumSymbols (DBGHELP.@)
|
|
|
|
*
|
2004-05-24 19:08:19 +00:00
|
|
|
* cases BaseOfDll = 0
|
|
|
|
* !foo fails always (despite what MSDN states)
|
|
|
|
* RE1!RE2 looks up all modules matching RE1, and in all these modules, lookup RE2
|
|
|
|
* no ! in Mask, lookup in local Context
|
|
|
|
* cases BaseOfDll != 0
|
|
|
|
* !foo fails always (despite what MSDN states)
|
|
|
|
* RE1!RE2 gets RE2 from BaseOfDll (whatever RE1 is)
|
2004-04-05 22:21:27 +00:00
|
|
|
*/
|
2004-10-11 21:00:17 +00:00
|
|
|
BOOL WINAPI SymEnumSymbols(HANDLE hProcess, ULONG64 BaseOfDll, PCSTR Mask,
|
2004-04-05 22:21:27 +00:00
|
|
|
PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
|
|
|
|
PVOID UserContext)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
2004-05-24 19:08:19 +00:00
|
|
|
struct module* dbg_module;
|
|
|
|
const char* bang;
|
|
|
|
regex_t mod_regex, sym_regex;
|
2004-04-05 22:21:27 +00:00
|
|
|
|
2004-10-11 21:00:17 +00:00
|
|
|
TRACE("(%p %s %s %p %p)\n",
|
|
|
|
hProcess, wine_dbgstr_longlong(BaseOfDll), debugstr_a(Mask),
|
|
|
|
EnumSymbolsCallback, UserContext);
|
2004-04-05 22:21:27 +00:00
|
|
|
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
|
|
|
|
if (BaseOfDll == 0)
|
|
|
|
{
|
2004-05-24 19:08:19 +00:00
|
|
|
/* do local variables ? */
|
|
|
|
if (!Mask || !(bang = strchr(Mask, '!')))
|
|
|
|
return symt_enum_locals(pcs, Mask, EnumSymbolsCallback, UserContext);
|
|
|
|
|
|
|
|
if (bang == Mask) return FALSE;
|
|
|
|
|
2005-12-26 11:57:26 +00:00
|
|
|
compile_regex(Mask, bang - Mask, &mod_regex,
|
|
|
|
dbghelp_options & SYMOPT_CASE_INSENSITIVE);
|
|
|
|
compile_regex(bang + 1, -1, &sym_regex,
|
|
|
|
dbghelp_options & SYMOPT_CASE_INSENSITIVE);
|
2004-05-24 19:08:19 +00:00
|
|
|
|
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
2004-05-24 19:08:19 +00:00
|
|
|
if (module->type == DMT_PE && (dbg_module = module_get_debug(pcs, module)))
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
2004-07-04 00:10:54 +00:00
|
|
|
if (regexec(&mod_regex, module->module.ModuleName, 0, NULL, 0) == 0 &&
|
|
|
|
symt_enum_module(dbg_module, &sym_regex,
|
|
|
|
EnumSymbolsCallback, UserContext))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* not found in PE modules, retry on the ELF ones
|
|
|
|
*/
|
|
|
|
if (!module && (dbghelp_options & SYMOPT_WINE_WITH_ELF_MODULES))
|
|
|
|
{
|
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
|
|
|
{
|
|
|
|
if (module->type == DMT_ELF &&
|
|
|
|
!module_get_containee(pcs, module) &&
|
|
|
|
(dbg_module = module_get_debug(pcs, module)))
|
|
|
|
{
|
|
|
|
if (regexec(&mod_regex, module->module.ModuleName, 0, NULL, 0) == 0 &&
|
|
|
|
symt_enum_module(dbg_module, &sym_regex, EnumSymbolsCallback, UserContext))
|
|
|
|
break;
|
|
|
|
}
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
2004-05-24 19:08:19 +00:00
|
|
|
regfree(&mod_regex);
|
|
|
|
regfree(&sym_regex);
|
|
|
|
return TRUE;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
2004-05-24 19:08:19 +00:00
|
|
|
module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
|
|
|
|
if (!(module = module_get_debug(pcs, module)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* we always ignore module name from Mask when BaseOfDll is defined */
|
|
|
|
if (Mask && (bang = strchr(Mask, '!')))
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
2004-05-24 19:08:19 +00:00
|
|
|
if (bang == Mask) return FALSE;
|
|
|
|
Mask = bang + 1;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
2004-05-24 19:08:19 +00:00
|
|
|
|
2005-12-26 11:57:26 +00:00
|
|
|
compile_regex(Mask ? Mask : "*", -1, &sym_regex,
|
|
|
|
dbghelp_options & SYMOPT_CASE_INSENSITIVE);
|
2004-05-24 19:08:19 +00:00
|
|
|
symt_enum_module(module, &sym_regex, EnumSymbolsCallback, UserContext);
|
|
|
|
regfree(&sym_regex);
|
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct sym_enumerate
|
|
|
|
{
|
|
|
|
void* ctx;
|
|
|
|
PSYM_ENUMSYMBOLS_CALLBACK cb;
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL CALLBACK sym_enumerate_cb(PSYMBOL_INFO syminfo, ULONG size, void* ctx)
|
|
|
|
{
|
|
|
|
struct sym_enumerate* se = (struct sym_enumerate*)ctx;
|
|
|
|
return (se->cb)(syminfo->Name, syminfo->Address, syminfo->Size, se->ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SymEnumerateSymbols (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymEnumerateSymbols(HANDLE hProcess, DWORD BaseOfDll,
|
|
|
|
PSYM_ENUMSYMBOLS_CALLBACK EnumSymbolsCallback,
|
|
|
|
PVOID UserContext)
|
|
|
|
{
|
|
|
|
struct sym_enumerate se;
|
|
|
|
|
|
|
|
se.ctx = UserContext;
|
|
|
|
se.cb = EnumSymbolsCallback;
|
|
|
|
|
|
|
|
return SymEnumSymbols(hProcess, BaseOfDll, NULL, sym_enumerate_cb, &se);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymFromAddr (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
2004-10-11 21:00:17 +00:00
|
|
|
BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address,
|
|
|
|
DWORD64* Displacement, PSYMBOL_INFO Symbol)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
struct symt_ht* sym;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
module = module_find_by_addr(pcs, Address, DMT_UNKNOWN);
|
|
|
|
if (!(module = module_get_debug(pcs, module))) return FALSE;
|
|
|
|
if ((idx = symt_find_nearest(module, Address)) == -1) return FALSE;
|
|
|
|
|
|
|
|
sym = module->addr_sorttab[idx];
|
|
|
|
|
|
|
|
symt_fill_sym_info(module, &sym->symt, Symbol);
|
2005-01-31 11:34:59 +00:00
|
|
|
*Displacement = Address - Symbol->Address;
|
2004-04-05 22:21:27 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymGetSymFromAddr (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetSymFromAddr(HANDLE hProcess, DWORD Address,
|
|
|
|
PDWORD Displacement, PIMAGEHLP_SYMBOL Symbol)
|
|
|
|
{
|
|
|
|
char buffer[sizeof(SYMBOL_INFO) + 256];
|
|
|
|
SYMBOL_INFO*si = (SYMBOL_INFO*)buffer;
|
|
|
|
size_t len;
|
2004-10-11 21:00:17 +00:00
|
|
|
DWORD64 Displacement64;
|
2004-04-05 22:21:27 +00:00
|
|
|
|
|
|
|
if (Symbol->SizeOfStruct < sizeof(*Symbol)) return FALSE;
|
|
|
|
si->SizeOfStruct = sizeof(*si);
|
|
|
|
si->MaxNameLen = 256;
|
2004-10-11 21:00:17 +00:00
|
|
|
if (!SymFromAddr(hProcess, Address, &Displacement64, si))
|
2004-04-05 22:21:27 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2004-10-11 21:00:17 +00:00
|
|
|
if (Displacement)
|
|
|
|
*Displacement = Displacement64;
|
2004-04-05 22:21:27 +00:00
|
|
|
Symbol->Address = si->Address;
|
|
|
|
Symbol->Size = si->Size;
|
|
|
|
Symbol->Flags = si->Flags;
|
|
|
|
len = min(Symbol->MaxNameLength, si->MaxNameLen);
|
2005-03-28 14:17:51 +00:00
|
|
|
lstrcpynA(Symbol->Name, si->Name, len);
|
2004-04-05 22:21:27 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymFromName (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymFromName(HANDLE hProcess, LPSTR Name, PSYMBOL_INFO Symbol)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
struct hash_table_iter hti;
|
|
|
|
void* ptr;
|
|
|
|
struct symt_ht* sym = NULL;
|
2004-05-24 19:08:19 +00:00
|
|
|
const char* name;
|
2004-04-05 22:21:27 +00:00
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", hProcess, Name, Symbol);
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
if (Symbol->SizeOfStruct < sizeof(*Symbol)) return FALSE;
|
2004-05-24 19:08:19 +00:00
|
|
|
name = strchr(Name, '!');
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
char tmp[128];
|
|
|
|
assert(name - Name < sizeof(tmp));
|
|
|
|
memcpy(tmp, Name, name - Name);
|
|
|
|
tmp[name - Name] = '\0';
|
|
|
|
module = module_find_by_name(pcs, tmp, DMT_UNKNOWN);
|
|
|
|
if (!module) return FALSE;
|
|
|
|
Name = (char*)(name + 1);
|
|
|
|
}
|
|
|
|
else module = pcs->lmodules;
|
|
|
|
|
|
|
|
/* FIXME: Name could be made out of a regular expression */
|
2004-07-04 00:10:54 +00:00
|
|
|
for (; module; module = (name) ? NULL : module->next)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
2004-05-24 19:08:19 +00:00
|
|
|
if (module->module.SymType == SymNone) continue;
|
|
|
|
if (module->module.SymType == SymDeferred)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
2004-05-24 19:08:19 +00:00
|
|
|
struct module* xmodule = module_get_debug(pcs, module);
|
|
|
|
if (!xmodule || xmodule != module) continue;
|
|
|
|
}
|
|
|
|
hash_table_iter_init(&module->ht_symbols, &hti, Name);
|
|
|
|
while ((ptr = hash_table_iter_up(&hti)))
|
|
|
|
{
|
|
|
|
sym = GET_ENTRY(ptr, struct symt_ht, hash_elt);
|
2004-04-05 22:21:27 +00:00
|
|
|
|
2004-05-24 19:08:19 +00:00
|
|
|
if (!strcmp(sym->hash_elt.name, Name))
|
|
|
|
{
|
|
|
|
symt_fill_sym_info(module, &sym->symt, Symbol);
|
|
|
|
return TRUE;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SymGetSymFromName (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetSymFromName(HANDLE hProcess, LPSTR Name, PIMAGEHLP_SYMBOL Symbol)
|
|
|
|
{
|
|
|
|
char buffer[sizeof(SYMBOL_INFO) + 256];
|
|
|
|
SYMBOL_INFO*si = (SYMBOL_INFO*)buffer;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
if (Symbol->SizeOfStruct < sizeof(*Symbol)) return FALSE;
|
|
|
|
si->SizeOfStruct = sizeof(*si);
|
|
|
|
si->MaxNameLen = 256;
|
|
|
|
if (!SymFromName(hProcess, Name, si)) return FALSE;
|
|
|
|
|
|
|
|
Symbol->Address = si->Address;
|
|
|
|
Symbol->Size = si->Size;
|
|
|
|
Symbol->Flags = si->Flags;
|
|
|
|
len = min(Symbol->MaxNameLength, si->MaxNameLen);
|
2005-03-28 14:17:51 +00:00
|
|
|
lstrcpynA(Symbol->Name, si->Name, len);
|
2004-04-05 22:21:27 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2004-04-19 02:58:27 +00:00
|
|
|
* sym_fill_func_line_info
|
2004-04-05 22:21:27 +00:00
|
|
|
*
|
|
|
|
* fills information about a file
|
|
|
|
*/
|
2004-04-19 02:58:27 +00:00
|
|
|
BOOL symt_fill_func_line_info(struct module* module, struct symt_function* func,
|
|
|
|
DWORD addr, IMAGEHLP_LINE* line)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
struct line_info* dli = NULL;
|
|
|
|
BOOL found = FALSE;
|
|
|
|
|
|
|
|
assert(func->symt.tag == SymTagFunction);
|
|
|
|
|
|
|
|
while ((dli = vector_iter_down(&func->vlines, dli)))
|
|
|
|
{
|
2004-04-30 04:15:41 +00:00
|
|
|
if (!dli->is_source_file)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
if (found || dli->u.pc_offset > addr) continue;
|
|
|
|
line->LineNumber = dli->line_number;
|
|
|
|
line->Address = dli->u.pc_offset;
|
|
|
|
line->Key = dli;
|
|
|
|
found = TRUE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
line->FileName = (char*)source_get(module, dli->u.source_file);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SymGetSymNext (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetSymNext(HANDLE hProcess, PIMAGEHLP_SYMBOL Symbol)
|
|
|
|
{
|
|
|
|
/* algo:
|
|
|
|
* get module from Symbol.Address
|
|
|
|
* get index in module.addr_sorttab of Symbol.Address
|
|
|
|
* increment index
|
|
|
|
* if out of module bounds, move to next module in process address space
|
|
|
|
*/
|
|
|
|
FIXME("(%p, %p): stub\n", hProcess, Symbol);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SymGetSymPrev (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL WINAPI SymGetSymPrev(HANDLE hProcess, PIMAGEHLP_SYMBOL Symbol)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub\n", hProcess, Symbol);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymGetLineFromAddr (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetLineFromAddr(HANDLE hProcess, DWORD dwAddr,
|
|
|
|
PDWORD pdwDisplacement, PIMAGEHLP_LINE Line)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
TRACE("%p %08lx %p %p\n", hProcess, dwAddr, pdwDisplacement, Line);
|
|
|
|
|
|
|
|
if (Line->SizeOfStruct < sizeof(*Line)) return FALSE;
|
|
|
|
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
|
|
|
|
if (!(module = module_get_debug(pcs, module))) return FALSE;
|
|
|
|
if ((idx = symt_find_nearest(module, dwAddr)) == -1) return FALSE;
|
|
|
|
|
|
|
|
if (module->addr_sorttab[idx]->symt.tag != SymTagFunction) return FALSE;
|
2004-04-19 02:58:27 +00:00
|
|
|
if (!symt_fill_func_line_info(module,
|
|
|
|
(struct symt_function*)module->addr_sorttab[idx],
|
|
|
|
dwAddr, Line)) return FALSE;
|
2005-01-31 11:34:59 +00:00
|
|
|
*pdwDisplacement = dwAddr - Line->Address;
|
2004-04-05 22:21:27 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-11-29 10:45:28 +00:00
|
|
|
/******************************************************************
|
|
|
|
* copy_line_64_from_32 (internal)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void copy_line_64_from_32(IMAGEHLP_LINE64* l64, const IMAGEHLP_LINE* l32)
|
|
|
|
|
|
|
|
{
|
|
|
|
l64->Key = l32->Key;
|
|
|
|
l64->LineNumber = l32->LineNumber;
|
|
|
|
l64->FileName = l32->FileName;
|
|
|
|
l64->Address = l32->Address;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* copy_line_32_from_64 (internal)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void copy_line_32_from_64(IMAGEHLP_LINE* l32, const IMAGEHLP_LINE64* l64)
|
|
|
|
|
|
|
|
{
|
|
|
|
l32->Key = l64->Key;
|
|
|
|
l32->LineNumber = l64->LineNumber;
|
|
|
|
l32->FileName = l64->FileName;
|
|
|
|
l32->Address = l64->Address;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymGetLineFromAddr64 (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetLineFromAddr64(HANDLE hProcess, DWORD64 dwAddr,
|
|
|
|
PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line)
|
|
|
|
{
|
|
|
|
IMAGEHLP_LINE line32;
|
|
|
|
|
|
|
|
if (Line->SizeOfStruct < sizeof(*Line)) return FALSE;
|
|
|
|
if (!validate_addr64(dwAddr)) return FALSE;
|
|
|
|
line32.SizeOfStruct = sizeof(line32);
|
|
|
|
if (!SymGetLineFromAddr(hProcess, (DWORD)dwAddr, pdwDisplacement, &line32))
|
|
|
|
return FALSE;
|
|
|
|
copy_line_64_from_32(Line, &line32);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
/******************************************************************
|
|
|
|
* SymGetLinePrev (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetLinePrev(HANDLE hProcess, PIMAGEHLP_LINE Line)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
struct line_info* li;
|
|
|
|
BOOL in_search = FALSE;
|
|
|
|
|
|
|
|
TRACE("(%p %p)\n", hProcess, Line);
|
|
|
|
|
|
|
|
if (Line->SizeOfStruct < sizeof(*Line)) return FALSE;
|
|
|
|
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
module = module_find_by_addr(pcs, Line->Address, DMT_UNKNOWN);
|
|
|
|
if (!(module = module_get_debug(pcs, module))) return FALSE;
|
|
|
|
|
|
|
|
if (Line->Key == 0) return FALSE;
|
|
|
|
li = (struct line_info*)Line->Key;
|
|
|
|
/* things are a bit complicated because when we encounter a DLIT_SOURCEFILE
|
|
|
|
* element we have to go back until we find the prev one to get the real
|
|
|
|
* source file name for the DLIT_OFFSET element just before
|
|
|
|
* the first DLIT_SOURCEFILE
|
|
|
|
*/
|
2004-04-30 04:15:41 +00:00
|
|
|
while (!li->is_first)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
li--;
|
2004-04-30 04:15:41 +00:00
|
|
|
if (!li->is_source_file)
|
2004-04-05 22:21:27 +00:00
|
|
|
{
|
|
|
|
Line->LineNumber = li->line_number;
|
|
|
|
Line->Address = li->u.pc_offset;
|
|
|
|
Line->Key = li;
|
|
|
|
if (!in_search) return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (in_search)
|
|
|
|
{
|
|
|
|
Line->FileName = (char*)source_get(module, li->u.source_file);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
in_search = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetLastError(ERROR_NO_MORE_ITEMS); /* FIXME */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-11-29 10:45:28 +00:00
|
|
|
/******************************************************************
|
|
|
|
* SymGetLinePrev64 (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetLinePrev64(HANDLE hProcess, PIMAGEHLP_LINE64 Line)
|
|
|
|
{
|
|
|
|
IMAGEHLP_LINE line32;
|
|
|
|
|
|
|
|
line32.SizeOfStruct = sizeof(line32);
|
|
|
|
copy_line_32_from_64(&line32, Line);
|
|
|
|
if (!SymGetLinePrev(hProcess, &line32)) return FALSE;
|
|
|
|
copy_line_64_from_32(Line, &line32);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-04-19 02:58:27 +00:00
|
|
|
BOOL symt_get_func_line_next(struct module* module, PIMAGEHLP_LINE line)
|
|
|
|
{
|
|
|
|
struct line_info* li;
|
|
|
|
|
|
|
|
if (line->Key == 0) return FALSE;
|
|
|
|
li = (struct line_info*)line->Key;
|
2004-04-30 04:15:41 +00:00
|
|
|
while (!li->is_last)
|
2004-04-19 02:58:27 +00:00
|
|
|
{
|
|
|
|
li++;
|
2004-04-30 04:15:41 +00:00
|
|
|
if (!li->is_source_file)
|
2004-04-19 02:58:27 +00:00
|
|
|
{
|
|
|
|
line->LineNumber = li->line_number;
|
|
|
|
line->Address = li->u.pc_offset;
|
|
|
|
line->Key = li;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
line->FileName = (char*)source_get(module, li->u.source_file);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
/******************************************************************
|
|
|
|
* SymGetLineNext (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetLineNext(HANDLE hProcess, PIMAGEHLP_LINE Line)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
TRACE("(%p %p)\n", hProcess, Line);
|
|
|
|
|
|
|
|
if (Line->SizeOfStruct < sizeof(*Line)) return FALSE;
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
module = module_find_by_addr(pcs, Line->Address, DMT_UNKNOWN);
|
|
|
|
if (!(module = module_get_debug(pcs, module))) return FALSE;
|
|
|
|
|
2004-04-19 02:58:27 +00:00
|
|
|
if (symt_get_func_line_next(module, Line)) return TRUE;
|
2004-04-05 22:21:27 +00:00
|
|
|
SetLastError(ERROR_NO_MORE_ITEMS); /* FIXME */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-11-29 10:45:28 +00:00
|
|
|
/******************************************************************
|
|
|
|
* SymGetLineNext64 (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetLineNext64(HANDLE hProcess, PIMAGEHLP_LINE64 Line)
|
|
|
|
{
|
|
|
|
IMAGEHLP_LINE line32;
|
|
|
|
|
|
|
|
line32.SizeOfStruct = sizeof(line32);
|
|
|
|
copy_line_32_from_64(&line32, Line);
|
|
|
|
if (!SymGetLineNext(hProcess, &line32)) return FALSE;
|
|
|
|
copy_line_64_from_32(Line, &line32);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* SymFunctionTableAccess (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI SymFunctionTableAccess(HANDLE hProcess, DWORD AddrBase)
|
|
|
|
{
|
|
|
|
FIXME("(%p, 0x%08lx): stub\n", hProcess, AddrBase);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SymUnDName (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymUnDName(PIMAGEHLP_SYMBOL sym, LPSTR UnDecName, DWORD UnDecNameLength)
|
|
|
|
{
|
2006-01-05 11:19:18 +00:00
|
|
|
TRACE("(%p %s %lu)\n", sym, UnDecName, UnDecNameLength);
|
2004-04-05 22:21:27 +00:00
|
|
|
return UnDecorateSymbolName(sym->Name, UnDecName, UnDecNameLength,
|
2004-11-19 18:02:47 +00:00
|
|
|
UNDNAME_COMPLETE) != 0;
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
|
|
|
|
2004-11-19 18:02:47 +00:00
|
|
|
static void* und_alloc(size_t len) { return HeapAlloc(GetProcessHeap(), 0, len); }
|
|
|
|
static void und_free (void* ptr) { HeapFree(GetProcessHeap(), 0, ptr); }
|
|
|
|
|
2004-04-05 22:21:27 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* UnDecorateSymbolName (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI UnDecorateSymbolName(LPCSTR DecoratedName, LPSTR UnDecoratedName,
|
|
|
|
DWORD UndecoratedLength, DWORD Flags)
|
|
|
|
{
|
2004-11-19 18:02:47 +00:00
|
|
|
/* undocumented from msvcrt */
|
|
|
|
static char* (*p_undname)(char*, const char*, int, void* (*)(size_t), void (*)(void*), unsigned short);
|
|
|
|
static WCHAR szMsvcrt[] = {'m','s','v','c','r','t','.','d','l','l',0};
|
|
|
|
|
2006-01-05 11:19:18 +00:00
|
|
|
TRACE("(%s, %p, %ld, 0x%08lx)\n",
|
2004-04-05 22:21:27 +00:00
|
|
|
debugstr_a(DecoratedName), UnDecoratedName, UndecoratedLength, Flags);
|
|
|
|
|
2004-11-19 18:02:47 +00:00
|
|
|
if (!p_undname)
|
|
|
|
{
|
|
|
|
if (!hMsvcrt) hMsvcrt = LoadLibraryW(szMsvcrt);
|
|
|
|
if (hMsvcrt) p_undname = (void*)GetProcAddress(hMsvcrt, "__unDName");
|
|
|
|
if (!p_undname) return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!UnDecoratedName) return 0;
|
|
|
|
if (!p_undname(UnDecoratedName, DecoratedName, UndecoratedLength,
|
|
|
|
und_alloc, und_free, Flags))
|
|
|
|
return 0;
|
|
|
|
return strlen(UnDecoratedName);
|
2004-04-05 22:21:27 +00:00
|
|
|
}
|
2005-12-19 17:16:35 +00:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymMatchString (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymMatchString(PCSTR string, PCSTR re, BOOL _case)
|
|
|
|
{
|
|
|
|
regex_t preg;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("%s %s %c\n", string, re, _case ? 'Y' : 'N');
|
|
|
|
|
|
|
|
compile_regex(re, -1, &preg, _case);
|
|
|
|
ret = regexec(&preg, string, 0, NULL, 0) == 0;
|
|
|
|
regfree(&preg);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-12-26 11:57:26 +00:00
|
|
|
/******************************************************************
|
|
|
|
* SymSearch (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymSearch(HANDLE hProcess, ULONG64 BaseOfDll, DWORD Index,
|
|
|
|
DWORD SymTag, PCSTR Mask, DWORD64 Address,
|
|
|
|
PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
|
|
|
|
PVOID UserContext, DWORD Options)
|
|
|
|
{
|
|
|
|
TRACE("(%p %s %lu %lu %s %s %p %p %lx)\n",
|
|
|
|
hProcess, wine_dbgstr_longlong(BaseOfDll), Index, SymTag, Mask,
|
|
|
|
wine_dbgstr_longlong(Address), EnumSymbolsCallback,
|
|
|
|
UserContext, Options);
|
|
|
|
|
|
|
|
if (Index != 0)
|
|
|
|
{
|
|
|
|
FIXME("Unsupported searching for a given Index (%lu)\n", Index);
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (SymTag != 0)
|
|
|
|
{
|
|
|
|
FIXME("Unsupported searching for a given SymTag (%lu)\n", SymTag);
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (Address != 0)
|
|
|
|
{
|
|
|
|
FIXME("Unsupported searching for a given Address (%s)\n", wine_dbgstr_longlong(Address));
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (Options != SYMSEARCH_GLOBALSONLY)
|
|
|
|
{
|
|
|
|
FIXME("Unsupported searching with options (%lx)\n", Options);
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return SymEnumSymbols(hProcess, BaseOfDll, Mask, EnumSymbolsCallback, UserContext);
|
|
|
|
}
|