2 * File types.c - management of types (hierarchical tree)
4 * Copyright (C) 1997, Eric Youngdale.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * Note: This really doesn't do much at the moment, but it forms the framework
22 * upon which full support for datatype handling will eventually be built.
25 #define NONAMELESSUNION
35 #include "wine/debug.h"
36 #include "dbghelp_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp
);
39 WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt
);
41 static const char* symt_get_tag_str(DWORD tag
)
45 case SymTagNull
: return "SymTagNull";
46 case SymTagExe
: return "SymTagExe";
47 case SymTagCompiland
: return "SymTagCompiland";
48 case SymTagCompilandDetails
: return "SymTagCompilandDetails";
49 case SymTagCompilandEnv
: return "SymTagCompilandEnv";
50 case SymTagFunction
: return "SymTagFunction";
51 case SymTagBlock
: return "SymTagBlock";
52 case SymTagData
: return "SymTagData";
53 case SymTagAnnotation
: return "SymTagAnnotation";
54 case SymTagLabel
: return "SymTagLabel";
55 case SymTagPublicSymbol
: return "SymTagPublicSymbol";
56 case SymTagUDT
: return "SymTagUDT";
57 case SymTagEnum
: return "SymTagEnum";
58 case SymTagFunctionType
: return "SymTagFunctionType";
59 case SymTagPointerType
: return "SymTagPointerType";
60 case SymTagArrayType
: return "SymTagArrayType";
61 case SymTagBaseType
: return "SymTagBaseType";
62 case SymTagTypedef
: return "SymTagTypedef,";
63 case SymTagBaseClass
: return "SymTagBaseClass";
64 case SymTagFriend
: return "SymTagFriend";
65 case SymTagFunctionArgType
: return "SymTagFunctionArgType,";
66 case SymTagFuncDebugStart
: return "SymTagFuncDebugStart,";
67 case SymTagFuncDebugEnd
: return "SymTagFuncDebugEnd";
68 case SymTagUsingNamespace
: return "SymTagUsingNamespace,";
69 case SymTagVTableShape
: return "SymTagVTableShape";
70 case SymTagVTable
: return "SymTagVTable";
71 case SymTagCustom
: return "SymTagCustom";
72 case SymTagThunk
: return "SymTagThunk";
73 case SymTagCustomType
: return "SymTagCustomType";
74 case SymTagManagedType
: return "SymTagManagedType";
75 case SymTagDimension
: return "SymTagDimension";
76 default: return "---";
80 const char* symt_get_name(const struct symt
* sym
)
85 case SymTagData
: return ((const struct symt_data
*)sym
)->hash_elt
.name
;
86 case SymTagFunction
: return ((const struct symt_function
*)sym
)->hash_elt
.name
;
87 case SymTagPublicSymbol
: return ((const struct symt_public
*)sym
)->hash_elt
.name
;
88 case SymTagBaseType
: return ((const struct symt_basic
*)sym
)->hash_elt
.name
;
89 case SymTagLabel
: return ((const struct symt_hierarchy_point
*)sym
)->hash_elt
.name
;
90 case SymTagThunk
: return ((const struct symt_thunk
*)sym
)->hash_elt
.name
;
92 case SymTagEnum
: return ((const struct symt_enum
*)sym
)->name
;
93 case SymTagTypedef
: return ((const struct symt_typedef
*)sym
)->hash_elt
.name
;
94 case SymTagUDT
: return ((const struct symt_udt
*)sym
)->hash_elt
.name
;
96 FIXME("Unsupported sym-tag %s\n", symt_get_tag_str(sym
->tag
));
99 case SymTagPointerType
:
100 case SymTagFunctionType
:
105 static struct symt
* symt_find_type_by_name(const struct module
* module
,
106 enum SymTagEnum sym_tag
,
107 const char* typename
)
110 struct symt_ht
* type
;
111 struct hash_table_iter hti
;
116 hash_table_iter_init(&module
->ht_types
, &hti
, typename
);
117 while ((ptr
= hash_table_iter_up(&hti
)))
119 type
= GET_ENTRY(ptr
, struct symt_ht
, hash_elt
);
121 if ((sym_tag
== SymTagNull
|| type
->symt
.tag
== sym_tag
) &&
122 type
->hash_elt
.name
&& !strcmp(type
->hash_elt
.name
, typename
))
125 SetLastError(ERROR_INVALID_NAME
); /* FIXME ?? */
129 static void symt_add_type(struct module
* module
, struct symt
* symt
)
132 p
= vector_add(&module
->vtypes
, &module
->pool
);
137 struct symt_basic
* symt_new_basic(struct module
* module
, enum BasicType bt
,
138 const char* typename
, unsigned size
)
140 struct symt_basic
* sym
;
144 sym
= (struct symt_basic
*)symt_find_type_by_name(module
, SymTagBaseType
,
146 if (sym
&& sym
->bt
== bt
&& sym
->size
== size
)
149 if ((sym
= pool_alloc(&module
->pool
, sizeof(*sym
))))
151 sym
->symt
.tag
= SymTagBaseType
;
154 sym
->hash_elt
.name
= pool_strdup(&module
->pool
, typename
);
155 hash_table_add(&module
->ht_types
, &sym
->hash_elt
);
156 } else sym
->hash_elt
.name
= NULL
;
159 symt_add_type(module
, &sym
->symt
);
164 struct symt_udt
* symt_new_udt(struct module
* module
, const char* typename
,
165 unsigned size
, enum UdtKind kind
)
167 struct symt_udt
* sym
;
169 TRACE_(dbghelp_symt
)("Adding udt %s:%s\n",
170 debugstr_w(module
->module
.ModuleName
), typename
);
171 if ((sym
= pool_alloc(&module
->pool
, sizeof(*sym
))))
173 sym
->symt
.tag
= SymTagUDT
;
178 sym
->hash_elt
.name
= pool_strdup(&module
->pool
, typename
);
179 hash_table_add(&module
->ht_types
, &sym
->hash_elt
);
180 } else sym
->hash_elt
.name
= NULL
;
181 vector_init(&sym
->vchildren
, sizeof(struct symt
*), 8);
182 symt_add_type(module
, &sym
->symt
);
187 BOOL
symt_set_udt_size(struct module
* module
, struct symt_udt
* udt
, unsigned size
)
189 assert(udt
->symt
.tag
== SymTagUDT
);
190 if (vector_length(&udt
->vchildren
) != 0)
192 if (udt
->size
!= size
)
193 FIXME_(dbghelp_symt
)("Changing size for %s from %u to %u\n",
194 udt
->hash_elt
.name
, udt
->size
, size
);
201 /******************************************************************
202 * symt_add_udt_element
204 * add an element to a udt (struct, class, union)
205 * the size & offset parameters are expressed in bits (not bytes) so that
206 * we can mix in the single call bytes aligned elements (regular fields) and
207 * the others (bit fields)
209 BOOL
symt_add_udt_element(struct module
* module
, struct symt_udt
* udt_type
,
210 const char* name
, struct symt
* elt_type
,
211 unsigned offset
, unsigned size
)
216 assert(udt_type
->symt
.tag
== SymTagUDT
);
218 TRACE_(dbghelp_symt
)("Adding %s to UDT %s\n", name
, udt_type
->hash_elt
.name
);
222 for (i
=0; i
<vector_length(&udt_type
->vchildren
); i
++)
224 m
= *(struct symt_data
**)vector_at(&udt_type
->vchildren
, i
);
226 assert(m
->symt
.tag
== SymTagData
);
227 if (strcmp(m
->hash_elt
.name
, name
) == 0)
232 if ((m
= pool_alloc(&module
->pool
, sizeof(*m
))) == NULL
) return FALSE
;
233 memset(m
, 0, sizeof(*m
));
234 m
->symt
.tag
= SymTagData
;
235 m
->hash_elt
.name
= name
? pool_strdup(&module
->pool
, name
) : "";
236 m
->hash_elt
.next
= NULL
;
238 m
->kind
= DataIsMember
;
239 m
->container
= &udt_type
->symt
;
241 m
->u
.member
.offset
= offset
;
242 m
->u
.member
.length
= ((offset
& 7) || (size
& 7)) ? size
: 0;
243 p
= vector_add(&udt_type
->vchildren
, &module
->pool
);
249 struct symt_enum
* symt_new_enum(struct module
* module
, const char* typename
,
250 struct symt
* basetype
)
252 struct symt_enum
* sym
;
254 if ((sym
= pool_alloc(&module
->pool
, sizeof(*sym
))))
256 sym
->symt
.tag
= SymTagEnum
;
257 sym
->name
= (typename
) ? pool_strdup(&module
->pool
, typename
) : NULL
;
258 sym
->base_type
= basetype
;
259 vector_init(&sym
->vchildren
, sizeof(struct symt
*), 8);
264 BOOL
symt_add_enum_element(struct module
* module
, struct symt_enum
* enum_type
,
265 const char* name
, int value
)
270 assert(enum_type
->symt
.tag
== SymTagEnum
);
271 e
= pool_alloc(&module
->pool
, sizeof(*e
));
272 if (e
== NULL
) return FALSE
;
274 e
->symt
.tag
= SymTagData
;
275 e
->hash_elt
.name
= pool_strdup(&module
->pool
, name
);
276 e
->hash_elt
.next
= NULL
;
277 e
->kind
= DataIsConstant
;
278 e
->container
= &enum_type
->symt
;
279 e
->type
= enum_type
->base_type
;
280 e
->u
.value
.n1
.n2
.vt
= VT_I4
;
281 e
->u
.value
.n1
.n2
.n3
.lVal
= value
;
283 p
= vector_add(&enum_type
->vchildren
, &module
->pool
);
284 if (!p
) return FALSE
; /* FIXME we leak e */
290 struct symt_array
* symt_new_array(struct module
* module
, int min
, int max
,
291 struct symt
* base
, struct symt
* index
)
293 struct symt_array
* sym
;
295 if ((sym
= pool_alloc(&module
->pool
, sizeof(*sym
))))
297 sym
->symt
.tag
= SymTagArrayType
;
300 sym
->base_type
= base
;
301 sym
->index_type
= index
;
302 symt_add_type(module
, &sym
->symt
);
307 static inline DWORD
symt_array_count(struct module
* module
, const struct symt_array
* array
)
312 /* One could want to also set the array->end field in array, but we won't do it
313 * as long as all the get_type() helpers use const objects
315 if (symt_get_info(module
, array
->base_type
, TI_GET_LENGTH
, &elem_size
) && elem_size
)
316 return -array
->end
/ (DWORD
)elem_size
;
319 return array
->end
- array
->start
+ 1;
322 struct symt_function_signature
* symt_new_function_signature(struct module
* module
,
323 struct symt
* ret_type
,
324 enum CV_call_e call_conv
)
326 struct symt_function_signature
* sym
;
328 if ((sym
= pool_alloc(&module
->pool
, sizeof(*sym
))))
330 sym
->symt
.tag
= SymTagFunctionType
;
331 sym
->rettype
= ret_type
;
332 vector_init(&sym
->vchildren
, sizeof(struct symt
*), 4);
333 sym
->call_conv
= call_conv
;
334 symt_add_type(module
, &sym
->symt
);
339 BOOL
symt_add_function_signature_parameter(struct module
* module
,
340 struct symt_function_signature
* sig_type
,
344 struct symt_function_arg_type
* arg
;
346 assert(sig_type
->symt
.tag
== SymTagFunctionType
);
347 arg
= pool_alloc(&module
->pool
, sizeof(*arg
));
348 if (!arg
) return FALSE
;
349 arg
->symt
.tag
= SymTagFunctionArgType
;
350 arg
->arg_type
= param
;
351 arg
->container
= &sig_type
->symt
;
352 p
= vector_add(&sig_type
->vchildren
, &module
->pool
);
353 if (!p
) return FALSE
; /* FIXME we leak arg */
359 struct symt_pointer
* symt_new_pointer(struct module
* module
, struct symt
* ref_type
)
361 struct symt_pointer
* sym
;
363 if ((sym
= pool_alloc(&module
->pool
, sizeof(*sym
))))
365 sym
->symt
.tag
= SymTagPointerType
;
366 sym
->pointsto
= ref_type
;
367 symt_add_type(module
, &sym
->symt
);
372 struct symt_typedef
* symt_new_typedef(struct module
* module
, struct symt
* ref
,
375 struct symt_typedef
* sym
;
377 if ((sym
= pool_alloc(&module
->pool
, sizeof(*sym
))))
379 sym
->symt
.tag
= SymTagTypedef
;
381 sym
->hash_elt
.name
= pool_strdup(&module
->pool
, name
);
382 hash_table_add(&module
->ht_types
, &sym
->hash_elt
);
383 symt_add_type(module
, &sym
->symt
);
388 /******************************************************************
389 * SymEnumTypes (DBGHELP.@)
392 BOOL WINAPI
SymEnumTypes(HANDLE hProcess
, ULONG64 BaseOfDll
,
393 PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback
,
396 struct module_pair pair
;
397 char buffer
[sizeof(SYMBOL_INFO
) + 256];
398 SYMBOL_INFO
* sym_info
= (SYMBOL_INFO
*)buffer
;
404 TRACE("(%p %s %p %p)\n",
405 hProcess
, wine_dbgstr_longlong(BaseOfDll
), EnumSymbolsCallback
,
408 if (!(pair
.pcs
= process_find_by_handle(hProcess
))) return FALSE
;
409 pair
.requested
= module_find_by_addr(pair
.pcs
, BaseOfDll
, DMT_UNKNOWN
);
410 if (!module_get_debug(&pair
)) return FALSE
;
412 sym_info
->SizeOfStruct
= sizeof(SYMBOL_INFO
);
413 sym_info
->MaxNameLen
= sizeof(buffer
) - sizeof(SYMBOL_INFO
);
415 for (i
=0; i
<vector_length(&pair
.effective
->vtypes
); i
++)
417 type
= *(struct symt
**)vector_at(&pair
.effective
->vtypes
, i
);
418 sym_info
->TypeIndex
= symt_ptr2index(pair
.effective
, type
);
419 sym_info
->info
= 0; /* FIXME */
420 symt_get_info(pair
.effective
, type
, TI_GET_LENGTH
, &size
);
421 sym_info
->Size
= size
;
422 sym_info
->ModBase
= pair
.requested
->module
.BaseOfImage
;
423 sym_info
->Flags
= 0; /* FIXME */
424 sym_info
->Value
= 0; /* FIXME */
425 sym_info
->Address
= 0; /* FIXME */
426 sym_info
->Register
= 0; /* FIXME */
427 sym_info
->Scope
= 0; /* FIXME */
428 sym_info
->Tag
= type
->tag
;
429 tmp
= symt_get_name(type
);
432 sym_info
->NameLen
= min(strlen(tmp
),sym_info
->MaxNameLen
-1);
433 memcpy(sym_info
->Name
, tmp
, sym_info
->NameLen
);
434 sym_info
->Name
[sym_info
->NameLen
] = '\0';
437 sym_info
->Name
[sym_info
->NameLen
= 0] = '\0';
438 if (!EnumSymbolsCallback(sym_info
, sym_info
->Size
, UserContext
)) break;
443 struct enum_types_AtoW
445 char buffer
[sizeof(SYMBOL_INFOW
) + 256 * sizeof(WCHAR
)];
447 PSYM_ENUMERATESYMBOLS_CALLBACKW callback
;
450 static BOOL CALLBACK
enum_types_AtoW(PSYMBOL_INFO si
, ULONG addr
, PVOID _et
)
452 struct enum_types_AtoW
* et
= _et
;
453 SYMBOL_INFOW
* siW
= (SYMBOL_INFOW
*)et
->buffer
;
455 copy_symbolW(siW
, si
);
456 return et
->callback(siW
, addr
, et
->user
);
459 /******************************************************************
460 * SymEnumTypesW (DBGHELP.@)
463 BOOL WINAPI
SymEnumTypesW(HANDLE hProcess
, ULONG64 BaseOfDll
,
464 PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback
,
467 struct enum_types_AtoW et
;
469 et
.callback
= EnumSymbolsCallback
;
470 et
.user
= UserContext
;
472 return SymEnumTypes(hProcess
, BaseOfDll
, enum_types_AtoW
, &et
);
475 /******************************************************************
478 * Retrieves information about a symt (either symbol or type)
480 BOOL
symt_get_info(struct module
* module
, const struct symt
* type
,
481 IMAGEHLP_SYMBOL_TYPE_INFO req
, void* pInfo
)
485 if (!type
) return FALSE
;
487 /* helper to typecast pInfo to its expected type (_t) */
488 #define X(_t) (*((_t*)pInfo))
492 case TI_FINDCHILDREN
:
494 const struct vector
* v
;
497 TI_FINDCHILDREN_PARAMS
* tifp
= pInfo
;
501 case SymTagUDT
: v
= &((const struct symt_udt
*)type
)->vchildren
; break;
502 case SymTagEnum
: v
= &((const struct symt_enum
*)type
)->vchildren
; break;
503 case SymTagFunctionType
: v
= &((const struct symt_function_signature
*)type
)->vchildren
; break;
504 case SymTagFunction
: v
= &((const struct symt_function
*)type
)->vchildren
; break;
506 FIXME("Unsupported sym-tag %s for find-children\n",
507 symt_get_tag_str(type
->tag
));
510 for (i
= 0; i
< tifp
->Count
; i
++)
512 if (!(pt
= vector_at(v
, tifp
->Start
+ i
))) return FALSE
;
513 tifp
->ChildId
[i
] = symt_ptr2index(module
, *pt
);
522 switch (((const struct symt_data
*)type
)->kind
)
525 case DataIsFileStatic
:
526 X(ULONG64
) = ((const struct symt_data
*)type
)->u
.var
.offset
;
528 default: return FALSE
;
532 X(ULONG64
) = ((const struct symt_function
*)type
)->address
;
534 case SymTagPublicSymbol
:
535 X(ULONG64
) = ((const struct symt_public
*)type
)->address
;
537 case SymTagFuncDebugStart
:
538 case SymTagFuncDebugEnd
:
540 if (!symt_get_info(module
, ((const struct symt_hierarchy_point
*)type
)->parent
,
543 X(ULONG64
) += ((const struct symt_hierarchy_point
*)type
)->loc
.offset
;
546 X(ULONG64
) = ((const struct symt_thunk
*)type
)->address
;
548 case SymTagCompiland
:
549 X(ULONG64
) = ((const struct symt_compiland
*)type
)->address
;
552 FIXME("Unsupported sym-tag %s for get-address\n",
553 symt_get_tag_str(type
->tag
));
558 case TI_GET_BASETYPE
:
562 X(DWORD
) = ((const struct symt_basic
*)type
)->bt
;
572 case TI_GET_BITPOSITION
:
573 if (type
->tag
== SymTagData
&&
574 ((const struct symt_data
*)type
)->kind
== DataIsMember
&&
575 ((const struct symt_data
*)type
)->u
.member
.length
!= 0)
576 X(DWORD
) = ((const struct symt_data
*)type
)->u
.member
.offset
& 7;
580 case TI_GET_CHILDRENCOUNT
:
584 X(DWORD
) = vector_length(&((const struct symt_udt
*)type
)->vchildren
);
587 X(DWORD
) = vector_length(&((const struct symt_enum
*)type
)->vchildren
);
589 case SymTagFunctionType
:
590 X(DWORD
) = vector_length(&((const struct symt_function_signature
*)type
)->vchildren
);
593 X(DWORD
) = vector_length(&((const struct symt_function
*)type
)->vchildren
);
595 case SymTagPointerType
: /* MS does it that way */
596 case SymTagArrayType
: /* MS does it that way */
597 case SymTagThunk
: /* MS does it that way */
601 FIXME("Unsupported sym-tag %s for get-children-count\n",
602 symt_get_tag_str(type
->tag
));
605 case SymTagPublicSymbol
:
614 case SymTagArrayType
:
615 X(DWORD
) = symt_array_count(module
, (const struct symt_array
*)type
);
617 case SymTagFunctionType
:
618 /* this seems to be wrong for (future) C++ methods, where 'this' parameter
619 * should be included in this value (and not in GET_CHILDREN_COUNT)
621 X(DWORD
) = vector_length(&((const struct symt_function_signature
*)type
)->vchildren
);
623 default: return FALSE
;
627 case TI_GET_DATAKIND
:
628 if (type
->tag
!= SymTagData
) return FALSE
;
629 X(DWORD
) = ((const struct symt_data
*)type
)->kind
;
636 X(DWORD64
) = ((const struct symt_basic
*)type
)->size
;
639 X(DWORD64
) = ((const struct symt_function
*)type
)->size
;
641 case SymTagPointerType
:
642 X(DWORD64
) = sizeof(void*);
645 X(DWORD64
) = ((const struct symt_udt
*)type
)->size
;
648 X(DWORD64
) = sizeof(int); /* FIXME: should be size of base-type of enum !!! */
651 if (((const struct symt_data
*)type
)->kind
!= DataIsMember
||
652 !((const struct symt_data
*)type
)->u
.member
.length
)
654 X(DWORD64
) = ((const struct symt_data
*)type
)->u
.member
.length
;
656 case SymTagArrayType
:
657 if (!symt_get_info(module
, ((const struct symt_array
*)type
)->base_type
,
658 TI_GET_LENGTH
, pInfo
))
660 X(DWORD64
) *= symt_array_count(module
, (const struct symt_array
*)type
);
662 case SymTagPublicSymbol
:
663 X(DWORD64
) = ((const struct symt_public
*)type
)->size
;
666 return symt_get_info(module
, ((const struct symt_typedef
*)type
)->type
, TI_GET_LENGTH
, pInfo
);
668 X(DWORD64
) = ((const struct symt_thunk
*)type
)->size
;
674 FIXME("Unsupported sym-tag %s for get-length\n",
675 symt_get_tag_str(type
->tag
));
677 case SymTagFunctionType
:
682 case TI_GET_LEXICALPARENT
:
686 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_block
*)type
)->container
);
689 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_data
*)type
)->container
);
692 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_function
*)type
)->container
);
695 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_thunk
*)type
)->container
);
697 case SymTagFunctionArgType
:
698 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_function_arg_type
*)type
)->container
);
701 FIXME("Unsupported sym-tag %s for get-lexical-parent\n",
702 symt_get_tag_str(type
->tag
));
723 switch (((const struct symt_data
*)type
)->kind
)
727 X(ULONG
) = ((const struct symt_data
*)type
)->u
.var
.offset
;
730 X(ULONG
) = ((const struct symt_data
*)type
)->u
.member
.offset
>> 3;
733 FIXME("Unknown kind (%u) for get-offset\n",
734 ((const struct symt_data
*)type
)->kind
);
739 FIXME("Unsupported sym-tag %s for get-offset\n",
740 symt_get_tag_str(type
->tag
));
747 const char* name
= symt_get_name(type
);
748 if (!name
) return FALSE
;
749 len
= MultiByteToWideChar(CP_ACP
, 0, name
, -1, NULL
, 0);
750 X(WCHAR
*) = HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
751 if (!X(WCHAR
*)) return FALSE
;
752 MultiByteToWideChar(CP_ACP
, 0, name
, -1, X(WCHAR
*), len
);
757 X(DWORD
) = type
->tag
;
764 /* hierarchical => hierarchical */
765 case SymTagArrayType
:
766 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_array
*)type
)->base_type
);
768 case SymTagPointerType
:
769 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_pointer
*)type
)->pointsto
);
771 case SymTagFunctionType
:
772 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_function_signature
*)type
)->rettype
);
775 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_typedef
*)type
)->type
);
777 /* lexical => hierarchical */
779 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_data
*)type
)->type
);
782 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_function
*)type
)->type
);
785 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_enum
*)type
)->base_type
);
787 case SymTagFunctionArgType
:
788 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_function_arg_type
*)type
)->arg_type
);
791 FIXME("Unsupported sym-tag %s for get-type\n",
792 symt_get_tag_str(type
->tag
));
793 case SymTagPublicSymbol
:
801 if (type
->tag
!= SymTagUDT
) return FALSE
;
802 X(DWORD
) = ((const struct symt_udt
*)type
)->kind
;
806 if (type
->tag
!= SymTagData
) return FALSE
;
807 switch (((const struct symt_data
*)type
)->kind
)
809 case DataIsConstant
: X(VARIANT
) = ((const struct symt_data
*)type
)->u
.value
; break;
813 struct location loc
= ((const struct symt_data
*)type
)->u
.var
;
815 struct module_format
* modfmt
;
817 if (loc
.kind
< loc_user
) return FALSE
;
818 for (i
= 0; i
< DFI_LAST
; i
++)
820 modfmt
= module
->format_info
[i
];
821 if (modfmt
&& modfmt
->loc_compute
)
823 modfmt
->loc_compute(module
->process
, modfmt
,
824 (const struct symt_function
*)((const struct symt_data
*)type
)->container
, &loc
);
828 if (loc
.kind
!= loc_absolute
) return FALSE
;
829 X(VARIANT
).n1
.n2
.vt
= VT_UI4
; /* FIXME */
830 X(VARIANT
).n1
.n2
.n3
.uiVal
= loc
.offset
;
833 default: return FALSE
;
837 case TI_GET_CALLING_CONVENTION
:
838 if (type
->tag
!= SymTagFunctionType
) return FALSE
;
839 if (((const struct symt_function_signature
*)type
)->call_conv
== -1)
841 FIXME("No support for calling convention for this signature\n");
842 X(DWORD
) = CV_CALL_FAR_C
; /* FIXME */
844 else X(DWORD
) = ((const struct symt_function_signature
*)type
)->call_conv
;
846 case TI_GET_ARRAYINDEXTYPEID
:
847 if (type
->tag
!= SymTagArrayType
) return FALSE
;
848 X(DWORD
) = symt_ptr2index(module
, ((const struct symt_array
*)type
)->index_type
);
851 case TI_GET_CLASSPARENTID
:
852 /* FIXME: we don't support properly C++ for now, pretend this symbol doesn't
853 * belong to a parent class
859 case TI_GET_ADDRESSOFFSET
:
860 case TI_GET_SYMINDEX
:
861 case TI_GET_THISADJUST
:
862 case TI_GET_VIRTUALBASECLASS
:
863 case TI_GET_VIRTUALBASEPOINTEROFFSET
:
864 case TI_GET_VIRTUALTABLESHAPEID
:
866 FIXME("Unsupported GetInfo request (%u)\n", req
);
869 FIXME("Unknown GetInfo request (%u)\n", req
);
876 /******************************************************************
877 * SymGetTypeInfo (DBGHELP.@)
880 BOOL WINAPI
SymGetTypeInfo(HANDLE hProcess
, DWORD64 ModBase
,
881 ULONG TypeId
, IMAGEHLP_SYMBOL_TYPE_INFO GetType
,
884 struct module_pair pair
;
886 pair
.pcs
= process_find_by_handle(hProcess
);
887 if (!pair
.pcs
) return FALSE
;
889 pair
.requested
= module_find_by_addr(pair
.pcs
, ModBase
, DMT_UNKNOWN
);
890 if (!module_get_debug(&pair
))
892 FIXME("Someone didn't properly set ModBase (%s)\n", wine_dbgstr_longlong(ModBase
));
896 return symt_get_info(pair
.effective
, symt_index2ptr(pair
.effective
, TypeId
), GetType
, pInfo
);
899 /******************************************************************
900 * SymGetTypeFromName (DBGHELP.@)
903 BOOL WINAPI
SymGetTypeFromName(HANDLE hProcess
, ULONG64 BaseOfDll
,
904 PCSTR Name
, PSYMBOL_INFO Symbol
)
906 struct process
* pcs
= process_find_by_handle(hProcess
);
907 struct module_pair pair
;
910 if (!pcs
) return FALSE
;
911 pair
.requested
= module_find_by_addr(pcs
, BaseOfDll
, DMT_UNKNOWN
);
912 if (!module_get_debug(&pair
)) return FALSE
;
913 type
= symt_find_type_by_name(pair
.effective
, SymTagNull
, Name
);
914 if (!type
) return FALSE
;
915 Symbol
->TypeIndex
= symt_ptr2index(pair
.effective
, type
);