2004-04-06 00:21:27 +02:00
|
|
|
/*
|
|
|
|
* File types.c - management of types (hierarchical tree)
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997, 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-06 00:21:27 +02:00
|
|
|
*
|
|
|
|
* Note: This really doesn't do much at the moment, but it forms the framework
|
|
|
|
* upon which full support for datatype handling will eventually be built.
|
|
|
|
*/
|
2008-02-27 20:02:39 +01:00
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dbghelp_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
2004-04-30 06:15:41 +02:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
static const char* symt_get_tag_str(DWORD tag)
|
|
|
|
{
|
|
|
|
switch (tag)
|
|
|
|
{
|
|
|
|
case SymTagNull: return "SymTagNull";
|
|
|
|
case SymTagExe: return "SymTagExe";
|
|
|
|
case SymTagCompiland: return "SymTagCompiland";
|
|
|
|
case SymTagCompilandDetails: return "SymTagCompilandDetails";
|
|
|
|
case SymTagCompilandEnv: return "SymTagCompilandEnv";
|
|
|
|
case SymTagFunction: return "SymTagFunction";
|
|
|
|
case SymTagBlock: return "SymTagBlock";
|
|
|
|
case SymTagData: return "SymTagData";
|
|
|
|
case SymTagAnnotation: return "SymTagAnnotation";
|
|
|
|
case SymTagLabel: return "SymTagLabel";
|
|
|
|
case SymTagPublicSymbol: return "SymTagPublicSymbol";
|
|
|
|
case SymTagUDT: return "SymTagUDT";
|
|
|
|
case SymTagEnum: return "SymTagEnum";
|
|
|
|
case SymTagFunctionType: return "SymTagFunctionType";
|
|
|
|
case SymTagPointerType: return "SymTagPointerType";
|
|
|
|
case SymTagArrayType: return "SymTagArrayType";
|
|
|
|
case SymTagBaseType: return "SymTagBaseType";
|
|
|
|
case SymTagTypedef: return "SymTagTypedef,";
|
|
|
|
case SymTagBaseClass: return "SymTagBaseClass";
|
|
|
|
case SymTagFriend: return "SymTagFriend";
|
|
|
|
case SymTagFunctionArgType: return "SymTagFunctionArgType,";
|
2021-09-28 17:21:49 +02:00
|
|
|
case SymTagFuncDebugStart: return "SymTagFuncDebugStart";
|
2004-04-06 00:21:27 +02:00
|
|
|
case SymTagFuncDebugEnd: return "SymTagFuncDebugEnd";
|
2021-09-28 17:21:49 +02:00
|
|
|
case SymTagUsingNamespace: return "SymTagUsingNamespace";
|
2004-04-06 00:21:27 +02:00
|
|
|
case SymTagVTableShape: return "SymTagVTableShape";
|
|
|
|
case SymTagVTable: return "SymTagVTable";
|
|
|
|
case SymTagCustom: return "SymTagCustom";
|
|
|
|
case SymTagThunk: return "SymTagThunk";
|
|
|
|
case SymTagCustomType: return "SymTagCustomType";
|
|
|
|
case SymTagManagedType: return "SymTagManagedType";
|
|
|
|
case SymTagDimension: return "SymTagDimension";
|
2021-09-28 17:21:49 +02:00
|
|
|
case SymTagCallSite: return "SymTagCallSite";
|
|
|
|
case SymTagInlineSite: return "SymTagInlineSite";
|
|
|
|
case SymTagBaseInterface: return "SymTagBaseInterface";
|
|
|
|
case SymTagVectorType: return "SymTagVectorType";
|
|
|
|
case SymTagMatrixType: return "SymTagMatrixType";
|
|
|
|
case SymTagHLSLType: return "SymTagHLSLType";
|
|
|
|
case SymTagCaller: return "SymTagCaller";
|
|
|
|
case SymTagCallee: return "SymTagCallee";
|
|
|
|
case SymTagExport: return "SymTagExport";
|
|
|
|
case SymTagHeapAllocationSite: return "SymTagHeapAllocationSite";
|
|
|
|
case SymTagCoffGroup: return "SymTagCoffGroup";
|
2021-10-06 10:01:17 +02:00
|
|
|
case SymTagInlinee: return "SymTagInlinee";
|
2004-04-06 00:21:27 +02:00
|
|
|
default: return "---";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* symt_get_name(const struct symt* sym)
|
|
|
|
{
|
|
|
|
switch (sym->tag)
|
|
|
|
{
|
|
|
|
/* lexical tree */
|
2004-05-18 23:29:09 +02:00
|
|
|
case SymTagData: return ((const struct symt_data*)sym)->hash_elt.name;
|
|
|
|
case SymTagFunction: return ((const struct symt_function*)sym)->hash_elt.name;
|
|
|
|
case SymTagPublicSymbol: return ((const struct symt_public*)sym)->hash_elt.name;
|
|
|
|
case SymTagBaseType: return ((const struct symt_basic*)sym)->hash_elt.name;
|
2008-02-06 21:55:47 +01:00
|
|
|
case SymTagLabel: return ((const struct symt_hierarchy_point*)sym)->hash_elt.name;
|
2004-05-18 23:29:09 +02:00
|
|
|
case SymTagThunk: return ((const struct symt_thunk*)sym)->hash_elt.name;
|
2021-10-06 10:02:31 +02:00
|
|
|
case SymTagCustom: return ((const struct symt_custom*)sym)->hash_elt.name;
|
2004-04-06 00:21:27 +02:00
|
|
|
/* hierarchy tree */
|
2021-08-30 09:24:48 +02:00
|
|
|
case SymTagEnum: return ((const struct symt_enum*)sym)->hash_elt.name;
|
2004-05-18 23:29:09 +02:00
|
|
|
case SymTagTypedef: return ((const struct symt_typedef*)sym)->hash_elt.name;
|
|
|
|
case SymTagUDT: return ((const struct symt_udt*)sym)->hash_elt.name;
|
2021-08-30 09:24:35 +02:00
|
|
|
case SymTagCompiland: return source_get(((const struct symt_compiland*)sym)->container->module,
|
|
|
|
((const struct symt_compiland*)sym)->source);
|
2004-04-06 00:21:27 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unsupported sym-tag %s\n", symt_get_tag_str(sym->tag));
|
|
|
|
/* fall through */
|
|
|
|
case SymTagArrayType:
|
|
|
|
case SymTagPointerType:
|
|
|
|
case SymTagFunctionType:
|
2021-10-06 10:01:36 +02:00
|
|
|
case SymTagFunctionArgType:
|
|
|
|
case SymTagBlock:
|
|
|
|
case SymTagFuncDebugStart:
|
|
|
|
case SymTagFuncDebugEnd:
|
2004-04-06 00:21:27 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-22 12:57:59 +01:00
|
|
|
WCHAR* symt_get_nameW(const struct symt* sym)
|
|
|
|
{
|
|
|
|
const char* name = symt_get_name(sym);
|
|
|
|
WCHAR* nameW;
|
|
|
|
DWORD sz;
|
|
|
|
|
|
|
|
if (!name) return NULL;
|
|
|
|
sz = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);
|
|
|
|
if ((nameW = HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR))))
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, sz);
|
|
|
|
return nameW;
|
|
|
|
}
|
|
|
|
|
2011-03-08 21:31:38 +01:00
|
|
|
BOOL symt_get_address(const struct symt* type, ULONG64* addr)
|
|
|
|
{
|
|
|
|
switch (type->tag)
|
|
|
|
{
|
|
|
|
case SymTagData:
|
|
|
|
switch (((const struct symt_data*)type)->kind)
|
|
|
|
{
|
|
|
|
case DataIsGlobal:
|
|
|
|
case DataIsFileStatic:
|
|
|
|
*addr = ((const struct symt_data*)type)->u.var.offset;
|
|
|
|
break;
|
|
|
|
default: return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2021-10-06 10:01:11 +02:00
|
|
|
case SymTagBlock:
|
|
|
|
*addr = ((const struct symt_block*)type)->address;
|
|
|
|
break;
|
2011-03-08 21:31:38 +01:00
|
|
|
case SymTagFunction:
|
|
|
|
*addr = ((const struct symt_function*)type)->address;
|
|
|
|
break;
|
|
|
|
case SymTagPublicSymbol:
|
|
|
|
*addr = ((const struct symt_public*)type)->address;
|
|
|
|
break;
|
|
|
|
case SymTagFuncDebugStart:
|
|
|
|
case SymTagFuncDebugEnd:
|
|
|
|
case SymTagLabel:
|
|
|
|
if (!((const struct symt_hierarchy_point*)type)->parent ||
|
|
|
|
!symt_get_address(((const struct symt_hierarchy_point*)type)->parent, addr))
|
2021-10-06 10:02:24 +02:00
|
|
|
*addr = 0;
|
2011-03-08 21:31:38 +01:00
|
|
|
*addr += ((const struct symt_hierarchy_point*)type)->loc.offset;
|
|
|
|
break;
|
|
|
|
case SymTagThunk:
|
|
|
|
*addr = ((const struct symt_thunk*)type)->address;
|
|
|
|
break;
|
2021-10-06 10:02:31 +02:00
|
|
|
case SymTagCustom:
|
|
|
|
*addr = ((const struct symt_custom*)type)->address;
|
|
|
|
break;
|
2011-03-08 21:31:38 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unsupported sym-tag %s for get-address\n", symt_get_tag_str(type->tag));
|
2021-10-06 10:00:41 +02:00
|
|
|
/* fall through */
|
|
|
|
case SymTagExe:
|
|
|
|
case SymTagCompiland:
|
2021-10-06 10:01:36 +02:00
|
|
|
case SymTagFunctionType:
|
|
|
|
case SymTagFunctionArgType:
|
|
|
|
case SymTagBaseType:
|
|
|
|
case SymTagUDT:
|
|
|
|
case SymTagEnum:
|
|
|
|
case SymTagTypedef:
|
|
|
|
case SymTagPointerType:
|
|
|
|
case SymTagArrayType:
|
2011-03-08 21:31:38 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-04-19 23:00:04 +02:00
|
|
|
static struct symt* symt_find_type_by_name(const struct module* module,
|
2004-04-06 00:21:27 +02:00
|
|
|
enum SymTagEnum sym_tag,
|
|
|
|
const char* typename)
|
|
|
|
{
|
|
|
|
void* ptr;
|
|
|
|
struct symt_ht* type;
|
|
|
|
struct hash_table_iter hti;
|
|
|
|
|
|
|
|
assert(typename);
|
|
|
|
assert(module);
|
|
|
|
|
|
|
|
hash_table_iter_init(&module->ht_types, &hti, typename);
|
|
|
|
while ((ptr = hash_table_iter_up(&hti)))
|
|
|
|
{
|
2016-03-08 11:44:26 +01:00
|
|
|
type = CONTAINING_RECORD(ptr, struct symt_ht, hash_elt);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
if ((sym_tag == SymTagNull || type->symt.tag == sym_tag) &&
|
|
|
|
type->hash_elt.name && !strcmp(type->hash_elt.name, typename))
|
|
|
|
return &type->symt;
|
|
|
|
}
|
|
|
|
SetLastError(ERROR_INVALID_NAME); /* FIXME ?? */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-27 22:31:42 +02:00
|
|
|
static void symt_add_type(struct module* module, struct symt* symt)
|
|
|
|
{
|
|
|
|
struct symt** p;
|
|
|
|
p = vector_add(&module->vtypes, &module->pool);
|
|
|
|
assert(p);
|
|
|
|
*p = symt;
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
struct symt_basic* symt_new_basic(struct module* module, enum BasicType bt,
|
|
|
|
const char* typename, unsigned size)
|
|
|
|
{
|
|
|
|
struct symt_basic* sym;
|
|
|
|
|
|
|
|
if (typename)
|
|
|
|
{
|
|
|
|
sym = (struct symt_basic*)symt_find_type_by_name(module, SymTagBaseType,
|
|
|
|
typename);
|
|
|
|
if (sym && sym->bt == bt && sym->size == size)
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagBaseType;
|
|
|
|
if (typename)
|
|
|
|
{
|
|
|
|
sym->hash_elt.name = pool_strdup(&module->pool, typename);
|
|
|
|
hash_table_add(&module->ht_types, &sym->hash_elt);
|
|
|
|
} else sym->hash_elt.name = NULL;
|
|
|
|
sym->bt = bt;
|
|
|
|
sym->size = size;
|
2004-09-27 22:31:42 +02:00
|
|
|
symt_add_type(module, &sym->symt);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct symt_udt* symt_new_udt(struct module* module, const char* typename,
|
|
|
|
unsigned size, enum UdtKind kind)
|
|
|
|
{
|
|
|
|
struct symt_udt* sym;
|
|
|
|
|
2007-03-13 17:26:33 +01:00
|
|
|
TRACE_(dbghelp_symt)("Adding udt %s:%s\n",
|
2021-09-06 10:40:08 +02:00
|
|
|
debugstr_w(module->modulename), typename);
|
2004-04-06 00:21:27 +02:00
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagUDT;
|
|
|
|
sym->kind = kind;
|
|
|
|
sym->size = size;
|
|
|
|
if (typename)
|
|
|
|
{
|
|
|
|
sym->hash_elt.name = pool_strdup(&module->pool, typename);
|
|
|
|
hash_table_add(&module->ht_types, &sym->hash_elt);
|
|
|
|
} else sym->hash_elt.name = NULL;
|
|
|
|
vector_init(&sym->vchildren, sizeof(struct symt*), 8);
|
2004-09-27 22:31:42 +02:00
|
|
|
symt_add_type(module, &sym->symt);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL symt_set_udt_size(struct module* module, struct symt_udt* udt, unsigned size)
|
|
|
|
{
|
|
|
|
assert(udt->symt.tag == SymTagUDT);
|
|
|
|
if (vector_length(&udt->vchildren) != 0)
|
|
|
|
{
|
|
|
|
if (udt->size != size)
|
2004-04-30 06:15:41 +02:00
|
|
|
FIXME_(dbghelp_symt)("Changing size for %s from %u to %u\n",
|
|
|
|
udt->hash_elt.name, udt->size, size);
|
2004-04-06 00:21:27 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
udt->size = size;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* symt_add_udt_element
|
|
|
|
*
|
|
|
|
* add an element to a udt (struct, class, union)
|
|
|
|
* the size & offset parameters are expressed in bits (not bytes) so that
|
|
|
|
* we can mix in the single call bytes aligned elements (regular fields) and
|
|
|
|
* the others (bit fields)
|
|
|
|
*/
|
|
|
|
BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type,
|
|
|
|
const char* name, struct symt* elt_type,
|
2021-08-30 09:24:23 +02:00
|
|
|
unsigned offset, unsigned bit_offset, unsigned bit_size)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct symt_data* m;
|
|
|
|
struct symt** p;
|
|
|
|
|
|
|
|
assert(udt_type->symt.tag == SymTagUDT);
|
|
|
|
|
2004-04-30 06:15:41 +02:00
|
|
|
TRACE_(dbghelp_symt)("Adding %s to UDT %s\n", name, udt_type->hash_elt.name);
|
2006-11-24 22:18:16 +01:00
|
|
|
if (name)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2008-09-24 21:50:05 +02:00
|
|
|
unsigned int i;
|
2007-05-15 02:05:12 +02:00
|
|
|
for (i=0; i<vector_length(&udt_type->vchildren); i++)
|
2006-11-24 22:18:16 +01:00
|
|
|
{
|
2007-05-15 02:05:12 +02:00
|
|
|
m = *(struct symt_data**)vector_at(&udt_type->vchildren, i);
|
2006-11-24 22:18:16 +01:00
|
|
|
assert(m);
|
|
|
|
assert(m->symt.tag == SymTagData);
|
|
|
|
if (strcmp(m->hash_elt.name, name) == 0)
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((m = pool_alloc(&module->pool, sizeof(*m))) == NULL) return FALSE;
|
|
|
|
memset(m, 0, sizeof(*m));
|
|
|
|
m->symt.tag = SymTagData;
|
2006-11-24 22:18:16 +01:00
|
|
|
m->hash_elt.name = name ? pool_strdup(&module->pool, name) : "";
|
2004-04-06 00:21:27 +02:00
|
|
|
m->hash_elt.next = NULL;
|
|
|
|
|
2006-11-24 22:17:38 +01:00
|
|
|
m->kind = DataIsMember;
|
|
|
|
m->container = &udt_type->symt;
|
|
|
|
m->type = elt_type;
|
|
|
|
m->u.member.offset = offset;
|
2021-08-30 09:24:23 +02:00
|
|
|
m->u.member.bit_offset = bit_offset;
|
|
|
|
m->u.member.bit_length = bit_size;
|
2004-04-06 00:21:27 +02:00
|
|
|
p = vector_add(&udt_type->vchildren, &module->pool);
|
|
|
|
*p = &m->symt;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-06 21:55:59 +01:00
|
|
|
struct symt_enum* symt_new_enum(struct module* module, const char* typename,
|
|
|
|
struct symt* basetype)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct symt_enum* sym;
|
|
|
|
|
2021-08-30 09:24:48 +02:00
|
|
|
TRACE_(dbghelp_symt)("Adding enum %s:%s\n",
|
2021-09-06 10:40:08 +02:00
|
|
|
debugstr_w(module->modulename), typename);
|
2004-04-06 00:21:27 +02:00
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagEnum;
|
2021-08-30 09:24:48 +02:00
|
|
|
if (typename)
|
|
|
|
{
|
|
|
|
sym->hash_elt.name = pool_strdup(&module->pool, typename);
|
|
|
|
hash_table_add(&module->ht_types, &sym->hash_elt);
|
|
|
|
} else sym->hash_elt.name = NULL;
|
2008-02-06 21:55:59 +01:00
|
|
|
sym->base_type = basetype;
|
2004-04-06 00:21:27 +02:00
|
|
|
vector_init(&sym->vchildren, sizeof(struct symt*), 8);
|
2021-08-30 09:24:48 +02:00
|
|
|
symt_add_type(module, &sym->symt);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL symt_add_enum_element(struct module* module, struct symt_enum* enum_type,
|
2004-04-19 04:58:27 +02:00
|
|
|
const char* name, int value)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct symt_data* e;
|
|
|
|
struct symt** p;
|
|
|
|
|
|
|
|
assert(enum_type->symt.tag == SymTagEnum);
|
|
|
|
e = pool_alloc(&module->pool, sizeof(*e));
|
|
|
|
if (e == NULL) return FALSE;
|
|
|
|
|
|
|
|
e->symt.tag = SymTagData;
|
|
|
|
e->hash_elt.name = pool_strdup(&module->pool, name);
|
|
|
|
e->hash_elt.next = NULL;
|
|
|
|
e->kind = DataIsConstant;
|
|
|
|
e->container = &enum_type->symt;
|
2008-02-06 21:55:59 +01:00
|
|
|
e->type = enum_type->base_type;
|
2004-04-19 04:58:27 +02:00
|
|
|
e->u.value.n1.n2.vt = VT_I4;
|
|
|
|
e->u.value.n1.n2.n3.lVal = value;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
p = vector_add(&enum_type->vchildren, &module->pool);
|
|
|
|
if (!p) return FALSE; /* FIXME we leak e */
|
|
|
|
*p = &e->symt;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-08-31 14:13:26 +02:00
|
|
|
struct symt_array* symt_new_array(struct module* module, int min, DWORD cnt,
|
2006-03-05 21:48:18 +01:00
|
|
|
struct symt* base, struct symt* index)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct symt_array* sym;
|
|
|
|
|
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
2006-03-05 21:48:18 +01:00
|
|
|
sym->symt.tag = SymTagArrayType;
|
|
|
|
sym->start = min;
|
2021-08-31 14:13:26 +02:00
|
|
|
sym->count = cnt;
|
2006-03-05 21:48:18 +01:00
|
|
|
sym->base_type = base;
|
|
|
|
sym->index_type = index;
|
2004-09-27 22:31:42 +02:00
|
|
|
symt_add_type(module, &sym->symt);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct symt_function_signature* symt_new_function_signature(struct module* module,
|
2005-12-19 18:22:54 +01:00
|
|
|
struct symt* ret_type,
|
|
|
|
enum CV_call_e call_conv)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-04-19 04:58:27 +02:00
|
|
|
struct symt_function_signature* sym;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagFunctionType;
|
|
|
|
sym->rettype = ret_type;
|
2004-04-19 04:58:27 +02:00
|
|
|
vector_init(&sym->vchildren, sizeof(struct symt*), 4);
|
2005-12-19 18:22:54 +01:00
|
|
|
sym->call_conv = call_conv;
|
2004-09-27 22:31:42 +02:00
|
|
|
symt_add_type(module, &sym->symt);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
2004-04-19 04:58:27 +02:00
|
|
|
BOOL symt_add_function_signature_parameter(struct module* module,
|
|
|
|
struct symt_function_signature* sig_type,
|
|
|
|
struct symt* param)
|
|
|
|
{
|
2005-11-17 13:53:41 +01:00
|
|
|
struct symt** p;
|
|
|
|
struct symt_function_arg_type* arg;
|
2004-04-19 04:58:27 +02:00
|
|
|
|
|
|
|
assert(sig_type->symt.tag == SymTagFunctionType);
|
2005-11-17 13:53:41 +01:00
|
|
|
arg = pool_alloc(&module->pool, sizeof(*arg));
|
|
|
|
if (!arg) return FALSE;
|
|
|
|
arg->symt.tag = SymTagFunctionArgType;
|
|
|
|
arg->arg_type = param;
|
2004-04-19 04:58:27 +02:00
|
|
|
p = vector_add(&sig_type->vchildren, &module->pool);
|
2005-11-17 13:53:41 +01:00
|
|
|
if (!p) return FALSE; /* FIXME we leak arg */
|
|
|
|
*p = &arg->symt;
|
2004-04-19 04:58:27 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-03-26 16:51:49 +01:00
|
|
|
struct symt_pointer* symt_new_pointer(struct module* module, struct symt* ref_type, ULONG_PTR size)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct symt_pointer* sym;
|
|
|
|
|
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagPointerType;
|
|
|
|
sym->pointsto = ref_type;
|
2011-01-13 20:09:44 +01:00
|
|
|
sym->size = size;
|
2004-09-27 22:31:42 +02:00
|
|
|
symt_add_type(module, &sym->symt);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
2004-04-19 04:58:27 +02:00
|
|
|
struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref,
|
|
|
|
const char* name)
|
|
|
|
{
|
|
|
|
struct symt_typedef* sym;
|
|
|
|
|
|
|
|
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
|
|
|
|
{
|
|
|
|
sym->symt.tag = SymTagTypedef;
|
|
|
|
sym->type = ref;
|
|
|
|
sym->hash_elt.name = pool_strdup(&module->pool, name);
|
|
|
|
hash_table_add(&module->ht_types, &sym->hash_elt);
|
2004-09-27 22:31:42 +02:00
|
|
|
symt_add_type(module, &sym->symt);
|
2004-04-19 04:58:27 +02:00
|
|
|
}
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/******************************************************************
|
|
|
|
* SymEnumTypes (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
2004-10-11 23:00:17 +02:00
|
|
|
BOOL WINAPI SymEnumTypes(HANDLE hProcess, ULONG64 BaseOfDll,
|
2004-04-06 00:21:27 +02:00
|
|
|
PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
|
2004-10-21 21:57:56 +02:00
|
|
|
PVOID UserContext)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-05-07 14:29:49 +02:00
|
|
|
struct module_pair pair;
|
2004-09-27 22:31:42 +02:00
|
|
|
char buffer[sizeof(SYMBOL_INFO) + 256];
|
|
|
|
SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
|
|
|
|
struct symt* type;
|
2005-11-17 12:51:53 +01:00
|
|
|
DWORD64 size;
|
2008-09-24 21:50:05 +02:00
|
|
|
unsigned int i;
|
2005-11-17 12:51:53 +01:00
|
|
|
|
2004-10-11 23:00:17 +02:00
|
|
|
TRACE("(%p %s %p %p)\n",
|
|
|
|
hProcess, wine_dbgstr_longlong(BaseOfDll), EnumSymbolsCallback,
|
|
|
|
UserContext);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-11-24 22:17:10 +01:00
|
|
|
if (!(pair.pcs = process_find_by_handle(hProcess))) return FALSE;
|
|
|
|
pair.requested = module_find_by_addr(pair.pcs, BaseOfDll, DMT_UNKNOWN);
|
|
|
|
if (!module_get_debug(&pair)) return FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
sym_info->SizeOfStruct = sizeof(SYMBOL_INFO);
|
|
|
|
sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
|
|
|
|
|
2007-05-15 02:05:12 +02:00
|
|
|
for (i=0; i<vector_length(&pair.effective->vtypes); i++)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2007-05-15 02:05:12 +02:00
|
|
|
type = *(struct symt**)vector_at(&pair.effective->vtypes, i);
|
2009-12-14 22:05:46 +01:00
|
|
|
sym_info->TypeIndex = symt_ptr2index(pair.effective, type);
|
2016-03-21 18:30:14 +01:00
|
|
|
sym_info->Index = 0; /* FIXME */
|
2009-12-14 22:05:46 +01:00
|
|
|
symt_get_info(pair.effective, type, TI_GET_LENGTH, &size);
|
2005-11-17 12:51:53 +01:00
|
|
|
sym_info->Size = size;
|
2006-05-07 14:29:49 +02:00
|
|
|
sym_info->ModBase = pair.requested->module.BaseOfImage;
|
2004-04-06 00:21:27 +02:00
|
|
|
sym_info->Flags = 0; /* FIXME */
|
|
|
|
sym_info->Value = 0; /* FIXME */
|
|
|
|
sym_info->Address = 0; /* FIXME */
|
|
|
|
sym_info->Register = 0; /* FIXME */
|
|
|
|
sym_info->Scope = 0; /* FIXME */
|
2004-09-27 22:31:42 +02:00
|
|
|
sym_info->Tag = type->tag;
|
2021-08-30 09:24:04 +02:00
|
|
|
symbol_setname(sym_info, symt_get_name(type));
|
2004-04-06 00:21:27 +02:00
|
|
|
if (!EnumSymbolsCallback(sym_info, sym_info->Size, UserContext)) break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-03-04 17:00:50 +01:00
|
|
|
struct enum_types_AtoW
|
|
|
|
{
|
|
|
|
char buffer[sizeof(SYMBOL_INFOW) + 256 * sizeof(WCHAR)];
|
|
|
|
void* user;
|
|
|
|
PSYM_ENUMERATESYMBOLS_CALLBACKW callback;
|
|
|
|
};
|
|
|
|
|
2021-09-10 15:52:02 +02:00
|
|
|
static BOOL CALLBACK enum_types_AtoW(PSYMBOL_INFO si, ULONG size, PVOID _et)
|
2007-03-04 17:00:50 +01:00
|
|
|
{
|
|
|
|
struct enum_types_AtoW* et = _et;
|
|
|
|
SYMBOL_INFOW* siW = (SYMBOL_INFOW*)et->buffer;
|
|
|
|
|
|
|
|
copy_symbolW(siW, si);
|
2021-09-10 15:52:02 +02:00
|
|
|
return et->callback(siW, size, et->user);
|
2007-03-04 17:00:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymEnumTypesW (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymEnumTypesW(HANDLE hProcess, ULONG64 BaseOfDll,
|
|
|
|
PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback,
|
|
|
|
PVOID UserContext)
|
|
|
|
{
|
|
|
|
struct enum_types_AtoW et;
|
|
|
|
|
|
|
|
et.callback = EnumSymbolsCallback;
|
|
|
|
et.user = UserContext;
|
|
|
|
|
|
|
|
return SymEnumTypes(hProcess, BaseOfDll, enum_types_AtoW, &et);
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/******************************************************************
|
|
|
|
* symt_get_info
|
|
|
|
*
|
2007-06-07 11:48:55 +02:00
|
|
|
* Retrieves information about a symt (either symbol or type)
|
2004-04-06 00:21:27 +02:00
|
|
|
*/
|
2009-12-14 22:05:46 +01:00
|
|
|
BOOL symt_get_info(struct module* module, const struct symt* type,
|
|
|
|
IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
unsigned len;
|
|
|
|
|
|
|
|
if (!type) return FALSE;
|
|
|
|
|
|
|
|
/* helper to typecast pInfo to its expected type (_t) */
|
|
|
|
#define X(_t) (*((_t*)pInfo))
|
|
|
|
|
|
|
|
switch (req)
|
|
|
|
{
|
|
|
|
case TI_FINDCHILDREN:
|
|
|
|
{
|
|
|
|
const struct vector* v;
|
|
|
|
struct symt** pt;
|
|
|
|
unsigned i;
|
|
|
|
TI_FINDCHILDREN_PARAMS* tifp = pInfo;
|
|
|
|
|
|
|
|
switch (type->tag)
|
|
|
|
{
|
2021-10-06 10:00:53 +02:00
|
|
|
case SymTagExe: v = &((const struct symt_module*)type)->vchildren; break;
|
2021-10-06 10:00:47 +02:00
|
|
|
case SymTagCompiland: v = &((const struct symt_compiland*)type)->vchildren; break;
|
2004-05-18 23:29:09 +02:00
|
|
|
case SymTagUDT: v = &((const struct symt_udt*)type)->vchildren; break;
|
|
|
|
case SymTagEnum: v = &((const struct symt_enum*)type)->vchildren; break;
|
|
|
|
case SymTagFunctionType: v = &((const struct symt_function_signature*)type)->vchildren; break;
|
|
|
|
case SymTagFunction: v = &((const struct symt_function*)type)->vchildren; break;
|
2021-10-06 10:01:05 +02:00
|
|
|
case SymTagBlock: v = &((const struct symt_block*)type)->vchildren; break;
|
2021-10-06 10:01:30 +02:00
|
|
|
case SymTagPointerType:
|
|
|
|
case SymTagArrayType:
|
|
|
|
case SymTagFunctionArgType:
|
|
|
|
case SymTagThunk:
|
|
|
|
case SymTagLabel:
|
|
|
|
case SymTagFuncDebugStart:
|
|
|
|
case SymTagFuncDebugEnd:
|
|
|
|
case SymTagTypedef:
|
|
|
|
case SymTagBaseType:
|
2021-10-06 10:02:31 +02:00
|
|
|
case SymTagCustom:
|
2021-10-06 10:01:30 +02:00
|
|
|
/* for those, CHILDRENCOUNT returns 0 */
|
|
|
|
return tifp->Count == 0;
|
2004-04-06 00:21:27 +02:00
|
|
|
default:
|
2004-04-19 04:58:27 +02:00
|
|
|
FIXME("Unsupported sym-tag %s for find-children\n",
|
|
|
|
symt_get_tag_str(type->tag));
|
2004-04-06 00:21:27 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
for (i = 0; i < tifp->Count; i++)
|
|
|
|
{
|
|
|
|
if (!(pt = vector_at(v, tifp->Start + i))) return FALSE;
|
2009-12-14 22:05:46 +01:00
|
|
|
tifp->ChildId[i] = symt_ptr2index(module, *pt);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_ADDRESS:
|
2011-03-08 21:31:38 +01:00
|
|
|
return symt_get_address(type, (ULONG64*)pInfo);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
case TI_GET_BASETYPE:
|
2004-04-19 04:58:27 +02:00
|
|
|
switch (type->tag)
|
|
|
|
{
|
|
|
|
case SymTagBaseType:
|
2004-05-18 23:29:09 +02:00
|
|
|
X(DWORD) = ((const struct symt_basic*)type)->bt;
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagEnum:
|
|
|
|
X(DWORD) = btInt;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_BITPOSITION:
|
2006-11-24 22:17:38 +01:00
|
|
|
if (type->tag == SymTagData &&
|
|
|
|
((const struct symt_data*)type)->kind == DataIsMember &&
|
2021-08-30 09:24:23 +02:00
|
|
|
((const struct symt_data*)type)->u.member.bit_length != 0)
|
|
|
|
X(DWORD) = ((const struct symt_data*)type)->u.member.bit_offset;
|
2006-11-24 22:17:38 +01:00
|
|
|
else return FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_CHILDRENCOUNT:
|
|
|
|
switch (type->tag)
|
|
|
|
{
|
2021-10-06 10:00:53 +02:00
|
|
|
case SymTagExe:
|
|
|
|
X(DWORD) = vector_length(&((const struct symt_module*)type)->vchildren);
|
|
|
|
break;
|
2021-10-06 10:00:47 +02:00
|
|
|
case SymTagCompiland:
|
|
|
|
X(DWORD) = vector_length(&((const struct symt_compiland*)type)->vchildren);
|
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
case SymTagUDT:
|
2004-05-18 23:29:09 +02:00
|
|
|
X(DWORD) = vector_length(&((const struct symt_udt*)type)->vchildren);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagEnum:
|
2004-05-18 23:29:09 +02:00
|
|
|
X(DWORD) = vector_length(&((const struct symt_enum*)type)->vchildren);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2004-04-19 04:58:27 +02:00
|
|
|
case SymTagFunctionType:
|
2004-05-18 23:29:09 +02:00
|
|
|
X(DWORD) = vector_length(&((const struct symt_function_signature*)type)->vchildren);
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagFunction:
|
2004-05-18 23:29:09 +02:00
|
|
|
X(DWORD) = vector_length(&((const struct symt_function*)type)->vchildren);
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
2021-10-06 10:01:05 +02:00
|
|
|
case SymTagBlock:
|
|
|
|
X(DWORD) = vector_length(&((const struct symt_block*)type)->vchildren);
|
|
|
|
break;
|
2021-10-06 10:01:30 +02:00
|
|
|
/* some SymTag:s return 0 */
|
|
|
|
case SymTagPointerType:
|
|
|
|
case SymTagArrayType:
|
|
|
|
case SymTagFunctionArgType:
|
|
|
|
case SymTagThunk:
|
|
|
|
case SymTagFuncDebugStart:
|
|
|
|
case SymTagFuncDebugEnd:
|
|
|
|
case SymTagLabel:
|
|
|
|
case SymTagTypedef:
|
|
|
|
case SymTagBaseType:
|
2021-10-06 10:02:31 +02:00
|
|
|
case SymTagCustom:
|
2004-04-19 04:58:27 +02:00
|
|
|
X(DWORD) = 0;
|
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
default:
|
2004-04-19 04:58:27 +02:00
|
|
|
FIXME("Unsupported sym-tag %s for get-children-count\n",
|
|
|
|
symt_get_tag_str(type->tag));
|
2004-04-06 00:21:27 +02:00
|
|
|
/* fall through */
|
2021-10-06 10:01:30 +02:00
|
|
|
/* some others return error */
|
2004-04-19 04:58:27 +02:00
|
|
|
case SymTagData:
|
2004-04-06 00:21:27 +02:00
|
|
|
case SymTagPublicSymbol:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_COUNT:
|
2006-03-05 21:48:07 +01:00
|
|
|
switch (type->tag)
|
|
|
|
{
|
|
|
|
case SymTagArrayType:
|
2021-08-31 14:13:26 +02:00
|
|
|
X(DWORD) = ((const struct symt_array*)type)->count;
|
2006-03-05 21:48:07 +01:00
|
|
|
break;
|
|
|
|
case SymTagFunctionType:
|
|
|
|
/* this seems to be wrong for (future) C++ methods, where 'this' parameter
|
|
|
|
* should be included in this value (and not in GET_CHILDREN_COUNT)
|
|
|
|
*/
|
|
|
|
X(DWORD) = vector_length(&((const struct symt_function_signature*)type)->vchildren);
|
|
|
|
break;
|
|
|
|
default: return FALSE;
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_DATAKIND:
|
|
|
|
if (type->tag != SymTagData) return FALSE;
|
2004-05-18 23:29:09 +02:00
|
|
|
X(DWORD) = ((const struct symt_data*)type)->kind;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_LENGTH:
|
|
|
|
switch (type->tag)
|
|
|
|
{
|
|
|
|
case SymTagBaseType:
|
2005-11-17 12:51:53 +01:00
|
|
|
X(DWORD64) = ((const struct symt_basic*)type)->size;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagFunction:
|
2005-11-17 12:51:53 +01:00
|
|
|
X(DWORD64) = ((const struct symt_function*)type)->size;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2021-10-06 10:01:11 +02:00
|
|
|
case SymTagBlock:
|
|
|
|
X(DWORD64) = ((const struct symt_block*)type)->size;
|
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
case SymTagPointerType:
|
2011-01-13 20:09:44 +01:00
|
|
|
X(DWORD64) = ((const struct symt_pointer*)type)->size;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagUDT:
|
2005-11-17 12:51:53 +01:00
|
|
|
X(DWORD64) = ((const struct symt_udt*)type)->size;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagEnum:
|
2021-08-30 09:24:54 +02:00
|
|
|
if (!symt_get_info(module, ((const struct symt_enum*)type)->base_type, TI_GET_LENGTH, pInfo))
|
|
|
|
return FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagData:
|
2004-05-18 23:29:09 +02:00
|
|
|
if (((const struct symt_data*)type)->kind != DataIsMember ||
|
2021-08-30 09:24:23 +02:00
|
|
|
!((const struct symt_data*)type)->u.member.bit_length)
|
2004-04-19 04:58:27 +02:00
|
|
|
return FALSE;
|
2021-08-30 09:24:23 +02:00
|
|
|
X(DWORD64) = ((const struct symt_data*)type)->u.member.bit_length;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2009-12-14 22:05:46 +01:00
|
|
|
case SymTagArrayType:
|
|
|
|
if (!symt_get_info(module, ((const struct symt_array*)type)->base_type,
|
2004-04-06 00:21:27 +02:00
|
|
|
TI_GET_LENGTH, pInfo))
|
|
|
|
return FALSE;
|
2021-08-31 14:13:26 +02:00
|
|
|
X(DWORD64) *= ((const struct symt_array*)type)->count;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagPublicSymbol:
|
2005-11-17 12:51:53 +01:00
|
|
|
X(DWORD64) = ((const struct symt_public*)type)->size;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2004-04-19 04:58:27 +02:00
|
|
|
case SymTagTypedef:
|
2009-12-14 22:05:46 +01:00
|
|
|
return symt_get_info(module, ((const struct symt_typedef*)type)->type, TI_GET_LENGTH, pInfo);
|
2004-05-18 23:29:09 +02:00
|
|
|
case SymTagThunk:
|
2005-11-17 12:51:53 +01:00
|
|
|
X(DWORD64) = ((const struct symt_thunk*)type)->size;
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
2021-10-06 10:02:31 +02:00
|
|
|
case SymTagCustom:
|
|
|
|
X(DWORD64) = ((const struct symt_custom*)type)->size;
|
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
default:
|
2004-04-19 04:58:27 +02:00
|
|
|
FIXME("Unsupported sym-tag %s for get-length\n",
|
|
|
|
symt_get_tag_str(type->tag));
|
2004-09-27 22:31:42 +02:00
|
|
|
/* fall through */
|
2021-10-06 10:00:41 +02:00
|
|
|
case SymTagExe:
|
|
|
|
case SymTagCompiland:
|
2004-09-27 22:31:42 +02:00
|
|
|
case SymTagFunctionType:
|
2021-10-06 10:01:36 +02:00
|
|
|
case SymTagFunctionArgType:
|
2021-10-06 10:01:42 +02:00
|
|
|
case SymTagLabel:
|
2014-04-28 20:04:41 +02:00
|
|
|
return FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_LEXICALPARENT:
|
|
|
|
switch (type->tag)
|
|
|
|
{
|
2021-10-06 10:00:53 +02:00
|
|
|
case SymTagCompiland:
|
|
|
|
X(DWORD) = symt_ptr2index(module, &((const struct symt_compiland*)type)->container->symt);
|
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
case SymTagBlock:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_block*)type)->container);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagData:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->container);
|
2004-05-18 23:29:09 +02:00
|
|
|
break;
|
|
|
|
case SymTagFunction:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->container);
|
2004-05-18 23:29:09 +02:00
|
|
|
break;
|
|
|
|
case SymTagThunk:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_thunk*)type)->container);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2021-10-06 10:01:54 +02:00
|
|
|
case SymTagFuncDebugStart:
|
|
|
|
case SymTagFuncDebugEnd:
|
|
|
|
case SymTagLabel:
|
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_hierarchy_point*)type)->parent);
|
|
|
|
break;
|
2021-08-30 09:24:41 +02:00
|
|
|
case SymTagUDT:
|
2021-08-30 09:28:13 +02:00
|
|
|
case SymTagEnum:
|
2021-10-06 10:01:48 +02:00
|
|
|
case SymTagFunctionType:
|
2021-10-06 10:01:24 +02:00
|
|
|
case SymTagFunctionArgType:
|
2021-10-06 10:01:48 +02:00
|
|
|
case SymTagPointerType:
|
|
|
|
case SymTagArrayType:
|
|
|
|
case SymTagBaseType:
|
|
|
|
case SymTagTypedef:
|
|
|
|
case SymTagBaseClass:
|
2021-10-06 10:02:00 +02:00
|
|
|
case SymTagPublicSymbol:
|
2021-10-06 10:02:31 +02:00
|
|
|
case SymTagCustom:
|
2021-08-30 09:24:41 +02:00
|
|
|
X(DWORD) = symt_ptr2index(module, &module->top->symt);
|
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
default:
|
2004-04-19 04:58:27 +02:00
|
|
|
FIXME("Unsupported sym-tag %s for get-lexical-parent\n",
|
|
|
|
symt_get_tag_str(type->tag));
|
2021-10-06 10:00:59 +02:00
|
|
|
/* fall through */
|
|
|
|
case SymTagExe:
|
2004-04-19 04:58:27 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_NESTED:
|
|
|
|
switch (type->tag)
|
|
|
|
{
|
|
|
|
case SymTagUDT:
|
|
|
|
case SymTagEnum:
|
|
|
|
X(DWORD) = 0;
|
|
|
|
break;
|
|
|
|
default:
|
2004-04-06 00:21:27 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_OFFSET:
|
|
|
|
switch (type->tag)
|
|
|
|
{
|
|
|
|
case SymTagData:
|
2004-05-18 23:29:09 +02:00
|
|
|
switch (((const struct symt_data*)type)->kind)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-04-19 04:58:27 +02:00
|
|
|
case DataIsParam:
|
|
|
|
case DataIsLocal:
|
2006-11-24 22:17:38 +01:00
|
|
|
X(ULONG) = ((const struct symt_data*)type)->u.var.offset;
|
|
|
|
break;
|
2004-04-19 04:58:27 +02:00
|
|
|
case DataIsMember:
|
2021-08-30 09:24:23 +02:00
|
|
|
X(ULONG) = ((const struct symt_data*)type)->u.member.offset;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
default:
|
2004-04-30 06:15:41 +02:00
|
|
|
FIXME("Unknown kind (%u) for get-offset\n",
|
2004-05-18 23:29:09 +02:00
|
|
|
((const struct symt_data*)type)->kind);
|
2004-04-19 04:58:27 +02:00
|
|
|
return FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2004-04-19 04:58:27 +02:00
|
|
|
FIXME("Unsupported sym-tag %s for get-offset\n",
|
|
|
|
symt_get_tag_str(type->tag));
|
2021-10-06 10:01:36 +02:00
|
|
|
/* fall through */
|
|
|
|
case SymTagExe:
|
|
|
|
case SymTagCompiland:
|
|
|
|
case SymTagUDT:
|
|
|
|
case SymTagFunctionType:
|
|
|
|
case SymTagFunctionArgType:
|
|
|
|
case SymTagPointerType:
|
|
|
|
case SymTagArrayType:
|
|
|
|
case SymTagBaseType:
|
|
|
|
case SymTagTypedef:
|
|
|
|
case SymTagBlock:
|
|
|
|
case SymTagFuncDebugStart:
|
|
|
|
case SymTagFuncDebugEnd:
|
|
|
|
case SymTagLabel:
|
2021-10-06 10:02:31 +02:00
|
|
|
case SymTagCustom:
|
2004-04-06 00:21:27 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_SYMNAME:
|
2021-08-30 09:24:29 +02:00
|
|
|
if (type->tag == SymTagExe)
|
|
|
|
{
|
|
|
|
DWORD len = (lstrlenW(module->modulename) + 1) * sizeof(WCHAR);
|
|
|
|
WCHAR* wname = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
if (!wname) return FALSE;
|
|
|
|
memcpy(wname, module->modulename, len);
|
|
|
|
X(WCHAR*) = wname;
|
|
|
|
}
|
|
|
|
else
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
const char* name = symt_get_name(type);
|
|
|
|
if (!name) return FALSE;
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);
|
|
|
|
X(WCHAR*) = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!X(WCHAR*)) return FALSE;
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, name, -1, X(WCHAR*), len);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_SYMTAG:
|
|
|
|
X(DWORD) = type->tag;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_TYPE:
|
2004-04-19 04:58:27 +02:00
|
|
|
case TI_GET_TYPEID:
|
2004-04-06 00:21:27 +02:00
|
|
|
switch (type->tag)
|
|
|
|
{
|
2004-04-19 04:58:27 +02:00
|
|
|
/* hierarchical => hierarchical */
|
2004-04-06 00:21:27 +02:00
|
|
|
case SymTagArrayType:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_array*)type)->base_type);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagPointerType:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_pointer*)type)->pointsto);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
case SymTagFunctionType:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_function_signature*)type)->rettype);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2004-04-19 04:58:27 +02:00
|
|
|
case SymTagTypedef:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_typedef*)type)->type);
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
|
|
|
/* lexical => hierarchical */
|
2004-04-06 00:21:27 +02:00
|
|
|
case SymTagData:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->type);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2004-04-19 04:58:27 +02:00
|
|
|
case SymTagFunction:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->type);
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
2008-02-06 21:55:59 +01:00
|
|
|
case SymTagEnum:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_enum*)type)->base_type);
|
2008-02-06 21:55:59 +01:00
|
|
|
break;
|
2005-11-17 13:53:41 +01:00
|
|
|
case SymTagFunctionArgType:
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_function_arg_type*)type)->arg_type);
|
2005-11-17 13:53:41 +01:00
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
default:
|
2004-04-19 04:58:27 +02:00
|
|
|
FIXME("Unsupported sym-tag %s for get-type\n",
|
|
|
|
symt_get_tag_str(type->tag));
|
2011-09-28 22:25:23 +02:00
|
|
|
/* fall through */
|
2005-12-05 12:00:54 +01:00
|
|
|
case SymTagPublicSymbol:
|
2004-05-18 23:29:09 +02:00
|
|
|
case SymTagThunk:
|
2021-10-06 10:01:36 +02:00
|
|
|
case SymTagBlock:
|
|
|
|
case SymTagFuncDebugStart:
|
|
|
|
case SymTagFuncDebugEnd:
|
2008-02-06 21:55:47 +01:00
|
|
|
case SymTagLabel:
|
2021-10-06 10:01:36 +02:00
|
|
|
case SymTagExe:
|
|
|
|
case SymTagCompiland:
|
|
|
|
case SymTagUDT:
|
|
|
|
case SymTagBaseType:
|
2021-10-06 10:02:31 +02:00
|
|
|
case SymTagCustom:
|
2004-04-06 00:21:27 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TI_GET_UDTKIND:
|
|
|
|
if (type->tag != SymTagUDT) return FALSE;
|
2004-05-18 23:29:09 +02:00
|
|
|
X(DWORD) = ((const struct symt_udt*)type)->kind;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-04-19 04:58:27 +02:00
|
|
|
case TI_GET_VALUE:
|
2010-06-07 21:50:46 +02:00
|
|
|
if (type->tag != SymTagData) return FALSE;
|
|
|
|
switch (((const struct symt_data*)type)->kind)
|
|
|
|
{
|
|
|
|
case DataIsConstant: X(VARIANT) = ((const struct symt_data*)type)->u.value; break;
|
|
|
|
case DataIsLocal:
|
|
|
|
case DataIsParam:
|
|
|
|
{
|
|
|
|
struct location loc = ((const struct symt_data*)type)->u.var;
|
|
|
|
unsigned i;
|
|
|
|
struct module_format* modfmt;
|
|
|
|
|
|
|
|
if (loc.kind < loc_user) return FALSE;
|
|
|
|
for (i = 0; i < DFI_LAST; i++)
|
|
|
|
{
|
|
|
|
modfmt = module->format_info[i];
|
|
|
|
if (modfmt && modfmt->loc_compute)
|
|
|
|
{
|
|
|
|
modfmt->loc_compute(module->process, modfmt,
|
|
|
|
(const struct symt_function*)((const struct symt_data*)type)->container, &loc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (loc.kind != loc_absolute) return FALSE;
|
|
|
|
X(VARIANT).n1.n2.vt = VT_UI4; /* FIXME */
|
|
|
|
X(VARIANT).n1.n2.n3.uiVal = loc.offset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: return FALSE;
|
|
|
|
}
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
|
|
|
|
2005-12-19 18:22:54 +01:00
|
|
|
case TI_GET_CALLING_CONVENTION:
|
|
|
|
if (type->tag != SymTagFunctionType) return FALSE;
|
|
|
|
if (((const struct symt_function_signature*)type)->call_conv == -1)
|
|
|
|
{
|
|
|
|
FIXME("No support for calling convention for this signature\n");
|
|
|
|
X(DWORD) = CV_CALL_FAR_C; /* FIXME */
|
|
|
|
}
|
|
|
|
else X(DWORD) = ((const struct symt_function_signature*)type)->call_conv;
|
|
|
|
break;
|
2006-03-05 21:48:18 +01:00
|
|
|
case TI_GET_ARRAYINDEXTYPEID:
|
|
|
|
if (type->tag != SymTagArrayType) return FALSE;
|
2009-12-14 22:05:46 +01:00
|
|
|
X(DWORD) = symt_ptr2index(module, ((const struct symt_array*)type)->index_type);
|
2006-03-05 21:48:18 +01:00
|
|
|
break;
|
2005-12-19 18:22:54 +01:00
|
|
|
|
2008-02-06 21:55:53 +01:00
|
|
|
case TI_GET_CLASSPARENTID:
|
|
|
|
/* FIXME: we don't support properly C++ for now, pretend this symbol doesn't
|
|
|
|
* belong to a parent class
|
|
|
|
*/
|
|
|
|
return FALSE;
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
#undef X
|
|
|
|
|
2005-12-19 18:22:54 +01:00
|
|
|
default:
|
2021-10-06 10:02:06 +02:00
|
|
|
{
|
|
|
|
static DWORD64 once;
|
|
|
|
if (!(once & ((DWORD64)1 << req)))
|
|
|
|
{
|
|
|
|
FIXME("Unsupported GetInfo request (%u)\n", req);
|
|
|
|
once |= (DWORD64)1 << req;
|
|
|
|
}
|
|
|
|
}
|
2005-12-19 18:22:54 +01:00
|
|
|
return FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymGetTypeInfo (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
2004-10-11 23:00:17 +02:00
|
|
|
BOOL WINAPI SymGetTypeInfo(HANDLE hProcess, DWORD64 ModBase,
|
2004-04-06 00:21:27 +02:00
|
|
|
ULONG TypeId, IMAGEHLP_SYMBOL_TYPE_INFO GetType,
|
|
|
|
PVOID pInfo)
|
|
|
|
{
|
2006-05-07 14:29:49 +02:00
|
|
|
struct module_pair pair;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-11-24 22:17:10 +01:00
|
|
|
pair.pcs = process_find_by_handle(hProcess);
|
|
|
|
if (!pair.pcs) return FALSE;
|
2004-05-24 21:08:19 +02:00
|
|
|
|
2006-11-24 22:17:10 +01:00
|
|
|
pair.requested = module_find_by_addr(pair.pcs, ModBase, DMT_UNKNOWN);
|
|
|
|
if (!module_get_debug(&pair))
|
2004-05-24 21:08:19 +02:00
|
|
|
{
|
2004-10-11 23:00:17 +02:00
|
|
|
FIXME("Someone didn't properly set ModBase (%s)\n", wine_dbgstr_longlong(ModBase));
|
2004-05-24 21:08:19 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2009-12-14 22:05:46 +01:00
|
|
|
return symt_get_info(pair.effective, symt_index2ptr(pair.effective, TypeId), GetType, pInfo);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymGetTypeFromName (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
2004-10-11 23:00:17 +02:00
|
|
|
BOOL WINAPI SymGetTypeFromName(HANDLE hProcess, ULONG64 BaseOfDll,
|
2006-01-23 16:37:48 +01:00
|
|
|
PCSTR Name, PSYMBOL_INFO Symbol)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2009-12-14 22:05:40 +01:00
|
|
|
struct module_pair pair;
|
2004-04-06 00:21:27 +02:00
|
|
|
struct symt* type;
|
2021-08-30 09:24:10 +02:00
|
|
|
DWORD64 size;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2021-07-02 10:21:01 +02:00
|
|
|
pair.pcs = process_find_by_handle(hProcess);
|
|
|
|
if (!pair.pcs) return FALSE;
|
|
|
|
pair.requested = module_find_by_addr(pair.pcs, BaseOfDll, DMT_UNKNOWN);
|
2009-12-14 22:05:40 +01:00
|
|
|
if (!module_get_debug(&pair)) return FALSE;
|
|
|
|
type = symt_find_type_by_name(pair.effective, SymTagNull, Name);
|
2004-04-06 00:21:27 +02:00
|
|
|
if (!type) return FALSE;
|
2021-08-30 09:24:10 +02:00
|
|
|
Symbol->Index = Symbol->TypeIndex = symt_ptr2index(pair.effective, type);
|
|
|
|
symbol_setname(Symbol, symt_get_name(type));
|
|
|
|
symt_get_info(pair.effective, type, TI_GET_LENGTH, &size);
|
|
|
|
Symbol->Size = size;
|
|
|
|
Symbol->ModBase = pair.requested->module.BaseOfImage;
|
|
|
|
Symbol->Tag = type->tag;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|