winedbg: Host references lookup.
[wine.git] / programs / winedbg / types.c
blobda6266966a1960c0127cf978edb5df8a8b71f307
1 /*
2 * File types.c - datatype handling stuff for internal debugger.
4 * Copyright (C) 1997, Eric Youngdale.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * Note: This really doesn't do much at the moment, but it forms the framework
21 * upon which full support for datatype handling will eventually be built.
24 #include "config.h"
25 #include <stdlib.h>
27 #include "debugger.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
32 /******************************************************************
33 * types_get_real_type
35 * Get rid of any potential typedef in the lvalue's type to get
36 * to the 'real' type (the one we can work upon).
38 BOOL types_get_real_type(struct dbg_type* type, DWORD* tag)
40 if (type->id == dbg_itype_none) return FALSE;
43 if (!types_get_info(type, TI_GET_SYMTAG, tag))
44 return FALSE;
45 if (*tag != SymTagTypedef) return TRUE;
46 } while (types_get_info(type, TI_GET_TYPE, &type->id));
47 return FALSE;
50 /******************************************************************
51 * types_extract_as_integer
53 * Given a lvalue, try to get an integral (or pointer/address) value
54 * out of it
56 long int types_extract_as_integer(const struct dbg_lvalue* lvalue)
58 long int rtn;
59 LONGLONG val;
60 DWORD tag, bt;
61 DWORD64 size;
62 struct dbg_type type = lvalue->type;
64 if (!types_get_real_type(&type, &tag))
65 RaiseException(DEBUG_STATUS_NOT_AN_INTEGER, 0, 0, NULL);
67 if (type.id == dbg_itype_segptr)
69 return (long int)memory_to_linear_addr(&lvalue->addr);
72 switch (tag)
74 case SymTagBaseType:
75 if (!types_get_info(&type, TI_GET_LENGTH, &size) ||
76 !types_get_info(&type, TI_GET_BASETYPE, &bt))
78 WINE_ERR("Couldn't get information\n");
79 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
81 if (size > sizeof(rtn))
83 WINE_ERR("Size too large (%s)\n", wine_dbgstr_longlong(size));
84 RaiseException(DEBUG_STATUS_NOT_AN_INTEGER, 0, 0, NULL);
86 switch (bt)
88 case btChar:
89 case btInt:
90 if (!be_cpu->fetch_integer(lvalue, (unsigned)size, TRUE, &val))
91 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
92 rtn = (long)val;
93 break;
94 case btUInt:
95 if (!be_cpu->fetch_integer(lvalue, (unsigned)size, FALSE, &val))
96 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
97 rtn = (DWORD)(DWORD64)val;
98 break;
99 case btFloat:
100 RaiseException(DEBUG_STATUS_NOT_AN_INTEGER, 0, 0, NULL);
102 break;
103 case SymTagPointerType:
104 if (!memory_read_value(lvalue, sizeof(void*), &rtn))
105 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
106 break;
107 case SymTagArrayType:
108 case SymTagUDT:
109 if (!memory_read_value(lvalue, sizeof(rtn), &rtn))
110 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
111 break;
112 case SymTagEnum:
113 if (!memory_read_value(lvalue, sizeof(rtn), &rtn))
114 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
115 break;
116 case SymTagFunctionType:
117 rtn = (unsigned)memory_to_linear_addr(&lvalue->addr);
118 break;
119 default:
120 WINE_FIXME("Unsupported tag %lu\n", tag);
121 RaiseException(DEBUG_STATUS_NOT_AN_INTEGER, 0, 0, NULL);
122 break;
125 return rtn;
128 /******************************************************************
129 * types_extract_as_address
133 void types_extract_as_address(const struct dbg_lvalue* lvalue, ADDRESS64* addr)
135 if (lvalue->type.id == dbg_itype_segptr && lvalue->type.module == 0)
137 *addr = lvalue->addr;
139 else
141 addr->Mode = AddrModeFlat;
142 addr->Offset = types_extract_as_integer( lvalue );
146 /******************************************************************
147 * types_deref
150 BOOL types_deref(const struct dbg_lvalue* lvalue, struct dbg_lvalue* result)
152 struct dbg_type type = lvalue->type;
153 DWORD tag;
155 memset(result, 0, sizeof(*result));
156 result->type.id = dbg_itype_none;
157 result->type.module = 0;
160 * Make sure that this really makes sense.
162 if (!types_get_real_type(&type, &tag) || tag != SymTagPointerType ||
163 !memory_read_value(lvalue, sizeof(result->addr.Offset), &result->addr.Offset) ||
164 !types_get_info(&type, TI_GET_TYPE, &result->type.id))
165 return FALSE;
166 result->type.module = type.module;
167 result->cookie = DLV_TARGET;
168 /* FIXME: this is currently buggy.
169 * there is no way to tell were the deref:ed value is...
170 * for example:
171 * x is a pointer to struct s, x being on the stack
172 * => lvalue is in debuggee, result is in debugger
173 * x is a pointer to struct s, x being optimized into a reg
174 * => lvalue is debugger, result is debuggee
175 * x is a pointer to internal variable x
176 * => lvalue is debugger, result is debuggee
177 * so we force debuggee address space, because dereferencing pointers to
178 * internal variables is very unlikely. A correct fix would be
179 * rather large.
181 result->addr.Mode = AddrModeFlat;
182 return TRUE;
185 /******************************************************************
186 * types_get_udt_element_lvalue
188 * Implement a structure derefencement
190 static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue,
191 const struct dbg_type* type, long int* tmpbuf)
193 DWORD offset, bitoffset;
194 DWORD bt;
195 DWORD64 length;
197 unsigned mask;
199 types_get_info(type, TI_GET_TYPE, &lvalue->type.id);
200 lvalue->type.module = type->module;
201 if (!types_get_info(type, TI_GET_OFFSET, &offset)) return FALSE;
202 lvalue->addr.Offset += offset;
204 if (types_get_info(type, TI_GET_BITPOSITION, &bitoffset))
206 types_get_info(type, TI_GET_LENGTH, &length);
207 /* FIXME: this test isn't sufficient, depending on start of bitfield
208 * (ie a 32 bit field can spread across 5 bytes)
210 if (length > 8 * sizeof(*tmpbuf)) return FALSE;
211 lvalue->addr.Offset += bitoffset >> 3;
213 * Bitfield operation. We have to extract the field and store
214 * it in a temporary buffer so that we get it all right.
216 if (!memory_read_value(lvalue, sizeof(*tmpbuf), tmpbuf)) return FALSE;
217 mask = 0xffffffff << (DWORD)length;
218 *tmpbuf >>= bitoffset & 7;
219 *tmpbuf &= ~mask;
221 lvalue->cookie = DLV_HOST;
222 lvalue->addr.Offset = (DWORD)tmpbuf;
225 * OK, now we have the correct part of the number.
226 * Check to see whether the basic type is signed or not, and if so,
227 * we need to sign extend the number.
229 if (types_get_info(&lvalue->type, TI_GET_BASETYPE, &bt) &&
230 bt == btInt && (*tmpbuf & (1 << ((DWORD)length - 1))))
232 *tmpbuf |= mask;
235 else
237 if (!memory_read_value(lvalue, sizeof(*tmpbuf), tmpbuf)) return FALSE;
239 return TRUE;
242 /******************************************************************
243 * types_udt_find_element
246 BOOL types_udt_find_element(struct dbg_lvalue* lvalue, const char* name, long int* tmpbuf)
248 DWORD tag, count;
249 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
250 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
251 WCHAR* ptr;
252 char tmp[256];
253 int i;
254 struct dbg_type type;
256 if (!types_get_info(&lvalue->type, TI_GET_SYMTAG, &tag) ||
257 tag != SymTagUDT)
258 return FALSE;
260 if (types_get_info(&lvalue->type, TI_GET_CHILDRENCOUNT, &count))
262 fcp->Start = 0;
263 while (count)
265 fcp->Count = min(count, 256);
266 if (types_get_info(&lvalue->type, TI_FINDCHILDREN, fcp))
268 type.module = lvalue->type.module;
269 for (i = 0; i < min(fcp->Count, count); i++)
271 ptr = NULL;
272 type.id = fcp->ChildId[i];
273 types_get_info(&type, TI_GET_SYMNAME, &ptr);
274 if (!ptr) continue;
275 WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
276 HeapFree(GetProcessHeap(), 0, ptr);
277 if (strcmp(tmp, name)) continue;
279 return types_get_udt_element_lvalue(lvalue, &type, tmpbuf);
282 count -= min(count, 256);
283 fcp->Start += 256;
286 return FALSE;
289 /******************************************************************
290 * types_array_index
292 * Grab an element from an array
294 BOOL types_array_index(const struct dbg_lvalue* lvalue, int index,
295 struct dbg_lvalue* result)
297 struct dbg_type type = lvalue->type;
298 DWORD tag, count;
299 DWORD64 length;
301 if (!types_get_real_type(&type, &tag)) return FALSE;
302 switch (tag)
304 case SymTagArrayType:
305 types_get_info(&type, TI_GET_COUNT, &count);
306 if (index < 0 || index >= count) return FALSE;
307 /* fall through */
308 case SymTagPointerType:
309 /* Contents of array share same data (addr mode, module...) */
310 *result = *lvalue;
312 * Get the base type, so we know how much to index by.
314 types_get_info(&type, TI_GET_TYPE, &result->type.id);
315 types_get_info(&result->type, TI_GET_LENGTH, &length);
316 memory_read_value(lvalue, sizeof(result->addr.Offset), &result->addr.Offset);
317 result->addr.Offset += index * (DWORD)length;
318 break;
319 default:
320 assert(FALSE);
322 return TRUE;
325 struct type_find_t
327 unsigned long result; /* out: the found type */
328 enum SymTagEnum tag; /* in: the tag to look for */
329 union
331 unsigned long typeid; /* when tag is SymTagUDT */
332 const char* name; /* when tag is SymTagPointerType */
333 } u;
336 static BOOL CALLBACK types_cb(PSYMBOL_INFO sym, ULONG size, void* _user)
338 struct type_find_t* user = (struct type_find_t*)_user;
339 BOOL ret = TRUE;
340 struct dbg_type type;
341 DWORD type_id;
343 if (sym->Tag == user->tag)
345 switch (user->tag)
347 case SymTagUDT:
348 if (!strcmp(user->u.name, sym->Name))
350 user->result = sym->TypeIndex;
351 ret = FALSE;
353 break;
354 case SymTagPointerType:
355 type.module = sym->ModBase;
356 type.id = sym->TypeIndex;
357 if (types_get_info(&type, TI_GET_TYPE, &type_id) && type_id == user->u.typeid)
359 user->result = sym->TypeIndex;
360 ret = FALSE;
362 break;
363 default: break;
366 return ret;
369 /******************************************************************
370 * types_find_pointer
372 * Should look up in module based at linear whether (typeid*) exists
373 * Otherwise, we could create it locally
375 struct dbg_type types_find_pointer(const struct dbg_type* type)
377 struct type_find_t f;
378 struct dbg_type ret;
380 f.result = dbg_itype_none;
381 f.tag = SymTagPointerType;
382 f.u.typeid = type->id;
383 SymEnumTypes(dbg_curr_process->handle, type->module, types_cb, &f);
384 ret.module = type->module;
385 ret.id = f.result;
386 return ret;
389 /******************************************************************
390 * types_find_type
392 * Should look up in the module based at linear address whether a type
393 * named 'name' and with the correct tag exists
395 struct dbg_type types_find_type(unsigned long linear, const char* name, enum SymTagEnum tag)
398 struct type_find_t f;
399 struct dbg_type ret;
401 f.result = dbg_itype_none;
402 f.tag = tag;
403 f.u.name = name;
404 SymEnumTypes(dbg_curr_process->handle, linear, types_cb, &f);
405 ret.module = linear;
406 ret.id = f.result;
407 return ret;
410 /***********************************************************************
411 * print_value
413 * Implementation of the 'print' command.
415 void print_value(const struct dbg_lvalue* lvalue, char format, int level)
417 struct dbg_type type = lvalue->type;
418 struct dbg_lvalue lvalue_field;
419 int i;
420 DWORD tag;
421 DWORD count;
422 DWORD64 size;
424 if (!types_get_real_type(&type, &tag))
426 WINE_FIXME("---error\n");
427 return;
430 if (type.id == dbg_itype_none)
432 /* No type, just print the addr value */
433 print_bare_address(&lvalue->addr);
434 goto leave;
437 if (format == 'i' || format == 's' || format == 'w' || format == 'b' || format == 'g')
439 dbg_printf("Format specifier '%c' is meaningless in 'print' command\n", format);
440 format = '\0';
443 switch (tag)
445 case SymTagBaseType:
446 case SymTagEnum:
447 case SymTagPointerType:
448 /* FIXME: this in not 100% optimal (as we're going through the typedef handling
449 * stuff again
451 print_basic(lvalue, 1, format);
452 break;
453 case SymTagUDT:
454 if (types_get_info(&type, TI_GET_CHILDRENCOUNT, &count))
456 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
457 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
458 WCHAR* ptr;
459 char tmp[256];
460 long int tmpbuf;
461 struct dbg_type sub_type;
463 dbg_printf("{");
464 fcp->Start = 0;
465 while (count)
467 fcp->Count = min(count, 256);
468 if (types_get_info(&type, TI_FINDCHILDREN, fcp))
470 for (i = 0; i < min(fcp->Count, count); i++)
472 ptr = NULL;
473 sub_type.module = type.module;
474 sub_type.id = fcp->ChildId[i];
475 types_get_info(&sub_type, TI_GET_SYMNAME, &ptr);
476 if (!ptr) continue;
477 WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
478 dbg_printf("%s=", tmp);
479 HeapFree(GetProcessHeap(), 0, ptr);
480 lvalue_field = *lvalue;
481 if (types_get_udt_element_lvalue(&lvalue_field, &sub_type, &tmpbuf))
483 print_value(&lvalue_field, format, level + 1);
485 if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", ");
488 count -= min(count, 256);
489 fcp->Start += 256;
491 dbg_printf("}");
493 break;
494 case SymTagArrayType:
496 * Loop over all of the entries, printing stuff as we go.
498 count = 1; size = 1;
499 types_get_info(&type, TI_GET_COUNT, &count);
500 types_get_info(&type, TI_GET_LENGTH, &size);
502 if (size == count)
504 unsigned len;
505 char buffer[256];
507 * Special handling for character arrays.
509 /* FIXME should check basic type here (should be a char!!!!)... */
510 len = min(count, sizeof(buffer));
511 memory_get_string(dbg_curr_process,
512 memory_to_linear_addr(&lvalue->addr),
513 lvalue->cookie == DLV_TARGET, TRUE, buffer, len);
514 dbg_printf("\"%s%s\"", buffer, (len < count) ? "..." : "");
515 break;
517 lvalue_field = *lvalue;
518 types_get_info(&type, TI_GET_TYPE, &lvalue_field.type.id);
519 dbg_printf("{");
520 for (i = 0; i < count; i++)
522 print_value(&lvalue_field, format, level + 1);
523 lvalue_field.addr.Offset += size / count;
524 dbg_printf((i == count - 1) ? "}" : ", ");
526 break;
527 case SymTagFunctionType:
528 dbg_printf("Function ");
529 print_bare_address(&lvalue->addr);
530 dbg_printf(": ");
531 types_print_type(&type, FALSE);
532 break;
533 case SymTagTypedef:
534 lvalue_field = *lvalue;
535 types_get_info(&lvalue->type, TI_GET_TYPE, &lvalue_field.type.id);
536 print_value(&lvalue_field, format, level);
537 break;
538 default:
539 WINE_FIXME("Unknown tag (%lu)\n", tag);
540 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
541 break;
544 leave:
546 if (level == 0) dbg_printf("\n");
549 static BOOL CALLBACK print_types_cb(PSYMBOL_INFO sym, ULONG size, void* ctx)
551 struct dbg_type type;
552 type.module = sym->ModBase;
553 type.id = sym->TypeIndex;
554 dbg_printf("Mod: %08lx ID: %08lx \n", type.module, type.id);
555 types_print_type(&type, TRUE);
556 dbg_printf("\n");
557 return TRUE;
560 static BOOL CALLBACK print_types_mod_cb(PSTR mod_name, DWORD base, void* ctx)
562 return SymEnumTypes(dbg_curr_process->handle, base, print_types_cb, ctx);
565 int print_types(void)
567 SymEnumerateModules(dbg_curr_process->handle, print_types_mod_cb, NULL);
568 return 0;
571 int types_print_type(const struct dbg_type* type, BOOL details)
573 WCHAR* ptr;
574 char tmp[256];
575 const char* name;
576 DWORD tag, udt, count;
577 struct dbg_type subtype;
579 if (type->id == dbg_itype_none || !types_get_info(type, TI_GET_SYMTAG, &tag))
581 dbg_printf("--invalid--<%lxh>--", type->id);
582 return FALSE;
585 if (types_get_info(type, TI_GET_SYMNAME, &ptr) && ptr)
587 WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
588 name = tmp;
589 HeapFree(GetProcessHeap(), 0, ptr);
591 else name = "--none--";
593 switch (tag)
595 case SymTagBaseType:
596 if (details) dbg_printf("Basic<%s>", name); else dbg_printf("%s", name);
597 break;
598 case SymTagPointerType:
599 types_get_info(type, TI_GET_TYPE, &subtype.id);
600 subtype.module = type->module;
601 types_print_type(&subtype, FALSE);
602 dbg_printf("*");
603 break;
604 case SymTagUDT:
605 types_get_info(type, TI_GET_UDTKIND, &udt);
606 switch (udt)
608 case UdtStruct: dbg_printf("struct %s", name); break;
609 case UdtUnion: dbg_printf("union %s", name); break;
610 case UdtClass: dbg_printf("class %s", name); break;
611 default: WINE_ERR("Unsupported UDT type (%ld) for %s\n", udt, name); break;
613 if (details &&
614 types_get_info(type, TI_GET_CHILDRENCOUNT, &count))
616 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
617 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
618 WCHAR* ptr;
619 char tmp[256];
620 int i;
621 struct dbg_type type_elt;
622 dbg_printf(" {");
624 fcp->Start = 0;
625 while (count)
627 fcp->Count = min(count, 256);
628 if (types_get_info(type, TI_FINDCHILDREN, fcp))
630 for (i = 0; i < min(fcp->Count, count); i++)
632 ptr = NULL;
633 type_elt.module = type->module;
634 type_elt.id = fcp->ChildId[i];
635 types_get_info(&type_elt, TI_GET_SYMNAME, &ptr);
636 if (!ptr) continue;
637 WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
638 HeapFree(GetProcessHeap(), 0, ptr);
639 dbg_printf("%s", tmp);
640 if (types_get_info(&type_elt, TI_GET_TYPE, &type_elt.id))
642 dbg_printf(":");
643 types_print_type(&type_elt, details);
645 if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", ");
648 count -= min(count, 256);
649 fcp->Start += 256;
651 dbg_printf("}");
653 break;
654 case SymTagArrayType:
655 types_get_info(type, TI_GET_TYPE, &subtype.id);
656 subtype.module = type->module;
657 types_print_type(&subtype, details);
658 dbg_printf(" %s[]", name);
659 break;
660 case SymTagEnum:
661 dbg_printf("enum %s", name);
662 break;
663 case SymTagFunctionType:
664 types_get_info(type, TI_GET_TYPE, &subtype.id);
665 subtype.module = type->module;
666 types_print_type(&subtype, FALSE);
667 dbg_printf(" (*%s)(", name);
668 if (types_get_info(type, TI_GET_CHILDRENCOUNT, &count))
670 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
671 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
672 int i;
674 fcp->Start = 0;
675 while (count)
677 fcp->Count = min(count, 256);
678 if (types_get_info(type, TI_FINDCHILDREN, fcp))
680 for (i = 0; i < min(fcp->Count, count); i++)
682 subtype.id = fcp->ChildId[i];
683 types_get_info(&subtype, TI_GET_TYPE, &subtype.id);
684 types_print_type(&subtype, FALSE);
685 if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", ");
688 count -= min(count, 256);
689 fcp->Start += 256;
692 dbg_printf(")");
693 break;
694 case SymTagTypedef:
695 dbg_printf(name);
696 break;
697 default:
698 WINE_ERR("Unknown type %lu for %s\n", tag, name);
699 break;
702 return TRUE;
705 /* helper to typecast pInfo to its expected type (_t) */
706 #define X(_t) (*((_t*)pInfo))
708 BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, void* pInfo)
710 if (type->id == dbg_itype_none) return FALSE;
711 if (type->module != 0)
713 DWORD ret, tag, bt;
714 ret = SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, ti, pInfo);
715 if (!ret &&
716 SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_SYMTAG, &tag) &&
717 tag == SymTagBaseType &&
718 SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_BASETYPE, &bt))
720 static const WCHAR voidW[] = {'v','o','i','d','\0'};
721 static const WCHAR charW[] = {'c','h','a','r','\0'};
722 static const WCHAR wcharW[] = {'W','C','H','A','R','\0'};
723 static const WCHAR intW[] = {'i','n','t','\0'};
724 static const WCHAR uintW[] = {'u','n','s','i','g','n','e','d',' ','i','n','t','\0'};
725 static const WCHAR floatW[] = {'f','l','o','a','t','\0'};
726 static const WCHAR boolW[] = {'b','o','o','l','\0'};
727 static const WCHAR longW[] = {'l','o','n','g',' ','i','n','t','\0'};
728 static const WCHAR ulongW[] = {'u','n','s','i','g','n','e','d',' ','l','o','n','g',' ','i','n','t','\0'};
729 static const WCHAR complexW[] = {'c','o','m','p','l','e','x','\0'};
730 const WCHAR* name = NULL;
732 switch (bt)
734 case btVoid: name = voidW; break;
735 case btChar: name = charW; break;
736 case btWChar: name = wcharW; break;
737 case btInt: name = intW; break;
738 case btUInt: name = uintW; break;
739 case btFloat: name = floatW; break;
740 case btBool: name = boolW; break;
741 case btLong: name = longW; break;
742 case btULong: name = ulongW; break;
743 case btComplex: name = complexW; break;
744 default: WINE_FIXME("Unsupported basic type %ld\n", bt); return FALSE;
746 X(WCHAR*) = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name) + 1) * sizeof(WCHAR));
747 if (X(WCHAR*))
749 lstrcpyW(X(WCHAR*), name);
750 ret = TRUE;
753 return ret;
756 assert(type->id >= dbg_itype_first);
758 switch (type->id)
760 case dbg_itype_unsigned_int:
761 switch (ti)
763 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
764 case TI_GET_LENGTH: X(DWORD64) = 4; break;
765 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
766 default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE;
768 break;
769 case dbg_itype_signed_int:
770 switch (ti)
772 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
773 case TI_GET_LENGTH: X(DWORD64) = 4; break;
774 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
775 default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE;
777 break;
778 case dbg_itype_unsigned_short_int:
779 switch (ti)
781 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
782 case TI_GET_LENGTH: X(DWORD64) = 2; break;
783 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
784 default: WINE_FIXME("unsupported %u for u-short int\n", ti); return FALSE;
786 break;
787 case dbg_itype_signed_short_int:
788 switch (ti)
790 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
791 case TI_GET_LENGTH: X(DWORD64) = 2; break;
792 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
793 default: WINE_FIXME("unsupported %u for s-short int\n", ti); return FALSE;
795 break;
796 case dbg_itype_unsigned_char_int:
797 switch (ti)
799 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
800 case TI_GET_LENGTH: X(DWORD64) = 1; break;
801 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
802 default: WINE_FIXME("unsupported %u for u-char int\n", ti); return FALSE;
804 break;
805 case dbg_itype_signed_char_int:
806 switch (ti)
808 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
809 case TI_GET_LENGTH: X(DWORD64) = 1; break;
810 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
811 default: WINE_FIXME("unsupported %u for s-char int\n", ti); return FALSE;
813 break;
814 case dbg_itype_char:
815 switch (ti)
817 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
818 case TI_GET_LENGTH: X(DWORD64) = 1; break;
819 case TI_GET_BASETYPE: X(DWORD) = btChar; break;
820 default: WINE_FIXME("unsupported %u for char int\n", ti); return FALSE;
822 break;
823 case dbg_itype_astring:
824 switch (ti)
826 case TI_GET_SYMTAG: X(DWORD) = SymTagPointerType; break;
827 case TI_GET_LENGTH: X(DWORD64) = 4; break;
828 case TI_GET_TYPE: X(DWORD) = dbg_itype_char; break;
829 default: WINE_FIXME("unsupported %u for a string\n", ti); return FALSE;
831 break;
832 case dbg_itype_segptr:
833 switch (ti)
835 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
836 case TI_GET_LENGTH: X(DWORD64) = 4; break;
837 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
838 default: WINE_FIXME("unsupported %u for seg-ptr\n", ti); return FALSE;
840 break;
841 default: WINE_FIXME("unsupported type id 0x%lx\n", type->id);
844 #undef X
845 return TRUE;