msi: Select the first item in the SelectionTree control.
[wine.git] / programs / winedbg / types.c
blobf248f210a5878632b206181f3dbe434df1e0a014
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 assert(lvalue->cookie == DLV_TARGET);
110 if (!memory_read_value(lvalue, sizeof(rtn), &rtn))
111 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
112 break;
113 case SymTagEnum:
114 assert(lvalue->cookie == DLV_TARGET);
115 if (!memory_read_value(lvalue, sizeof(rtn), &rtn))
116 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
117 break;
118 case SymTagFunctionType:
119 rtn = (unsigned)memory_to_linear_addr(&lvalue->addr);
120 break;
121 default:
122 WINE_FIXME("Unsupported tag %lu\n", tag);
123 RaiseException(DEBUG_STATUS_NOT_AN_INTEGER, 0, 0, NULL);
124 break;
127 return rtn;
130 /******************************************************************
131 * types_extract_as_address
135 void types_extract_as_address(const struct dbg_lvalue* lvalue, ADDRESS64* addr)
137 if (lvalue->type.id == dbg_itype_segptr && lvalue->type.module == 0)
139 *addr = lvalue->addr;
141 else
143 addr->Mode = AddrModeFlat;
144 addr->Offset = types_extract_as_integer( lvalue );
148 /******************************************************************
149 * types_deref
152 BOOL types_deref(const struct dbg_lvalue* lvalue, struct dbg_lvalue* result)
154 struct dbg_type type = lvalue->type;
155 DWORD tag;
157 memset(result, 0, sizeof(*result));
158 result->type.id = dbg_itype_none;
159 result->type.module = 0;
162 * Make sure that this really makes sense.
164 if (!types_get_real_type(&type, &tag) || tag != SymTagPointerType ||
165 !memory_read_value(lvalue, sizeof(result->addr.Offset), &result->addr.Offset) ||
166 !types_get_info(&type, TI_GET_TYPE, &result->type.id))
167 return FALSE;
168 result->type.module = type.module;
169 result->cookie = DLV_TARGET;
170 /* FIXME: this is currently buggy.
171 * there is no way to tell were the deref:ed value is...
172 * for example:
173 * x is a pointer to struct s, x being on the stack
174 * => lvalue is in debuggee, result is in debugger
175 * x is a pointer to struct s, x being optimized into a reg
176 * => lvalue is debugger, result is debuggee
177 * x is a pointer to internal variable x
178 * => lvalue is debugger, result is debuggee
179 * so we force debuggee address space, because dereferencing pointers to
180 * internal variables is very unlikely. A correct fix would be
181 * rather large.
183 result->addr.Mode = AddrModeFlat;
184 return TRUE;
187 /******************************************************************
188 * types_get_udt_element_lvalue
190 * Implement a structure derefencement
192 static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue,
193 const struct dbg_type* type, long int* tmpbuf)
195 DWORD offset, bitoffset;
196 DWORD bt;
197 DWORD64 length;
199 unsigned mask;
201 types_get_info(type, TI_GET_TYPE, &lvalue->type.id);
202 lvalue->type.module = type->module;
203 if (!types_get_info(type, TI_GET_OFFSET, &offset)) return FALSE;
204 lvalue->addr.Offset += offset;
206 if (types_get_info(type, TI_GET_BITPOSITION, &bitoffset))
208 types_get_info(type, TI_GET_LENGTH, &length);
209 /* FIXME: this test isn't sufficient, depending on start of bitfield
210 * (ie a 32 bit field can spread across 5 bytes)
212 if (length > 8 * sizeof(*tmpbuf)) return FALSE;
213 lvalue->addr.Offset += bitoffset >> 3;
215 * Bitfield operation. We have to extract the field and store
216 * it in a temporary buffer so that we get it all right.
218 if (!memory_read_value(lvalue, sizeof(*tmpbuf), tmpbuf)) return FALSE;
219 mask = 0xffffffff << (DWORD)length;
220 *tmpbuf >>= bitoffset & 7;
221 *tmpbuf &= ~mask;
223 lvalue->cookie = DLV_HOST;
224 lvalue->addr.Offset = (DWORD)tmpbuf;
227 * OK, now we have the correct part of the number.
228 * Check to see whether the basic type is signed or not, and if so,
229 * we need to sign extend the number.
231 if (types_get_info(&lvalue->type, TI_GET_BASETYPE, &bt) &&
232 bt == btInt && (*tmpbuf & (1 << ((DWORD)length - 1))))
234 *tmpbuf |= mask;
237 else
239 if (!memory_read_value(lvalue, sizeof(*tmpbuf), tmpbuf)) return FALSE;
241 return TRUE;
244 /******************************************************************
245 * types_udt_find_element
248 BOOL types_udt_find_element(struct dbg_lvalue* lvalue, const char* name, long int* tmpbuf)
250 DWORD tag, count;
251 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
252 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
253 WCHAR* ptr;
254 char tmp[256];
255 int i;
256 struct dbg_type type;
258 if (!types_get_info(&lvalue->type, TI_GET_SYMTAG, &tag) ||
259 tag != SymTagUDT)
260 return FALSE;
262 if (types_get_info(&lvalue->type, TI_GET_CHILDRENCOUNT, &count))
264 fcp->Start = 0;
265 while (count)
267 fcp->Count = min(count, 256);
268 if (types_get_info(&lvalue->type, TI_FINDCHILDREN, fcp))
270 type.module = lvalue->type.module;
271 for (i = 0; i < min(fcp->Count, count); i++)
273 ptr = NULL;
274 type.id = fcp->ChildId[i];
275 types_get_info(&type, TI_GET_SYMNAME, &ptr);
276 if (!ptr) continue;
277 WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
278 HeapFree(GetProcessHeap(), 0, ptr);
279 if (strcmp(tmp, name)) continue;
281 return types_get_udt_element_lvalue(lvalue, &type, tmpbuf);
284 count -= min(count, 256);
285 fcp->Start += 256;
288 return FALSE;
291 /******************************************************************
292 * types_array_index
294 * Grab an element from an array
296 BOOL types_array_index(const struct dbg_lvalue* lvalue, int index,
297 struct dbg_lvalue* result)
299 struct dbg_type type = lvalue->type;
300 DWORD tag, count;
301 DWORD64 length;
303 if (!types_get_real_type(&type, &tag)) return FALSE;
304 switch (tag)
306 case SymTagArrayType:
307 types_get_info(&type, TI_GET_COUNT, &count);
308 if (index < 0 || index >= count) return FALSE;
309 /* fall through */
310 case SymTagPointerType:
311 /* Contents of array share same data (addr mode, module...) */
312 *result = *lvalue;
314 * Get the base type, so we know how much to index by.
316 types_get_info(&type, TI_GET_TYPE, &result->type.id);
317 types_get_info(&result->type, TI_GET_LENGTH, &length);
318 memory_read_value(lvalue, sizeof(result->addr.Offset), &result->addr.Offset);
319 result->addr.Offset += index * (DWORD)length;
320 break;
321 default:
322 assert(FALSE);
324 return TRUE;
327 struct type_find_t
329 unsigned long result; /* out: the found type */
330 enum SymTagEnum tag; /* in: the tag to look for */
331 union
333 unsigned long typeid; /* when tag is SymTagUDT */
334 const char* name; /* when tag is SymTagPointerType */
335 } u;
338 static BOOL CALLBACK types_cb(PSYMBOL_INFO sym, ULONG size, void* _user)
340 struct type_find_t* user = (struct type_find_t*)_user;
341 BOOL ret = TRUE;
342 struct dbg_type type;
343 DWORD type_id;
345 if (sym->Tag == user->tag)
347 switch (user->tag)
349 case SymTagUDT:
350 if (!strcmp(user->u.name, sym->Name))
352 user->result = sym->TypeIndex;
353 ret = FALSE;
355 break;
356 case SymTagPointerType:
357 type.module = sym->ModBase;
358 type.id = sym->TypeIndex;
359 if (types_get_info(&type, TI_GET_TYPE, &type_id) && type_id == user->u.typeid)
361 user->result = sym->TypeIndex;
362 ret = FALSE;
364 break;
365 default: break;
368 return ret;
371 /******************************************************************
372 * types_find_pointer
374 * Should look up in module based at linear whether (typeid*) exists
375 * Otherwise, we could create it locally
377 struct dbg_type types_find_pointer(const struct dbg_type* type)
379 struct type_find_t f;
380 struct dbg_type ret;
382 f.result = dbg_itype_none;
383 f.tag = SymTagPointerType;
384 f.u.typeid = type->id;
385 SymEnumTypes(dbg_curr_process->handle, type->module, types_cb, &f);
386 ret.module = type->module;
387 ret.id = f.result;
388 return ret;
391 /******************************************************************
392 * types_find_type
394 * Should look up in the module based at linear address whether a type
395 * named 'name' and with the correct tag exists
397 struct dbg_type types_find_type(unsigned long linear, const char* name, enum SymTagEnum tag)
400 struct type_find_t f;
401 struct dbg_type ret;
403 f.result = dbg_itype_none;
404 f.tag = tag;
405 f.u.name = name;
406 SymEnumTypes(dbg_curr_process->handle, linear, types_cb, &f);
407 ret.module = linear;
408 ret.id = f.result;
409 return ret;
412 /***********************************************************************
413 * print_value
415 * Implementation of the 'print' command.
417 void print_value(const struct dbg_lvalue* lvalue, char format, int level)
419 struct dbg_type type = lvalue->type;
420 struct dbg_lvalue lvalue_field;
421 int i;
422 DWORD tag;
423 DWORD count;
424 DWORD64 size;
426 if (!types_get_real_type(&type, &tag))
428 WINE_FIXME("---error\n");
429 return;
432 if (type.id == dbg_itype_none)
434 /* No type, just print the addr value */
435 print_bare_address(&lvalue->addr);
436 goto leave;
439 if (format == 'i' || format == 's' || format == 'w' || format == 'b' || format == 'g')
441 dbg_printf("Format specifier '%c' is meaningless in 'print' command\n", format);
442 format = '\0';
445 switch (tag)
447 case SymTagBaseType:
448 case SymTagEnum:
449 case SymTagPointerType:
450 /* FIXME: this in not 100% optimal (as we're going through the typedef handling
451 * stuff again
453 print_basic(lvalue, 1, format);
454 break;
455 case SymTagUDT:
456 if (types_get_info(&type, TI_GET_CHILDRENCOUNT, &count))
458 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
459 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
460 WCHAR* ptr;
461 char tmp[256];
462 long int tmpbuf;
463 struct dbg_type sub_type;
465 dbg_printf("{");
466 fcp->Start = 0;
467 while (count)
469 fcp->Count = min(count, 256);
470 if (types_get_info(&type, TI_FINDCHILDREN, fcp))
472 for (i = 0; i < min(fcp->Count, count); i++)
474 ptr = NULL;
475 sub_type.module = type.module;
476 sub_type.id = fcp->ChildId[i];
477 types_get_info(&sub_type, TI_GET_SYMNAME, &ptr);
478 if (!ptr) continue;
479 WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
480 dbg_printf("%s=", tmp);
481 HeapFree(GetProcessHeap(), 0, ptr);
482 lvalue_field = *lvalue;
483 if (types_get_udt_element_lvalue(&lvalue_field, &sub_type, &tmpbuf))
485 print_value(&lvalue_field, format, level + 1);
487 if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", ");
490 count -= min(count, 256);
491 fcp->Start += 256;
493 dbg_printf("}");
495 break;
496 case SymTagArrayType:
498 * Loop over all of the entries, printing stuff as we go.
500 count = 1; size = 1;
501 types_get_info(&type, TI_GET_COUNT, &count);
502 types_get_info(&type, TI_GET_LENGTH, &size);
504 if (size == count)
506 unsigned len;
507 char buffer[256];
509 * Special handling for character arrays.
511 /* FIXME should check basic type here (should be a char!!!!)... */
512 len = min(count, sizeof(buffer));
513 memory_get_string(dbg_curr_process,
514 memory_to_linear_addr(&lvalue->addr),
515 lvalue->cookie == DLV_TARGET, TRUE, buffer, len);
516 dbg_printf("\"%s%s\"", buffer, (len < count) ? "..." : "");
517 break;
519 lvalue_field = *lvalue;
520 types_get_info(&type, TI_GET_TYPE, &lvalue_field.type.id);
521 dbg_printf("{");
522 for (i = 0; i < count; i++)
524 print_value(&lvalue_field, format, level + 1);
525 lvalue_field.addr.Offset += size / count;
526 dbg_printf((i == count - 1) ? "}" : ", ");
528 break;
529 case SymTagFunctionType:
530 dbg_printf("Function ");
531 print_bare_address(&lvalue->addr);
532 dbg_printf(": ");
533 types_print_type(&type, FALSE);
534 break;
535 case SymTagTypedef:
536 lvalue_field = *lvalue;
537 types_get_info(&lvalue->type, TI_GET_TYPE, &lvalue_field.type.id);
538 print_value(&lvalue_field, format, level);
539 break;
540 default:
541 WINE_FIXME("Unknown tag (%lu)\n", tag);
542 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
543 break;
546 leave:
548 if (level == 0) dbg_printf("\n");
551 static BOOL CALLBACK print_types_cb(PSYMBOL_INFO sym, ULONG size, void* ctx)
553 struct dbg_type type;
554 type.module = sym->ModBase;
555 type.id = sym->TypeIndex;
556 dbg_printf("Mod: %08lx ID: %08lx \n", type.module, type.id);
557 types_print_type(&type, TRUE);
558 dbg_printf("\n");
559 return TRUE;
562 static BOOL CALLBACK print_types_mod_cb(PSTR mod_name, DWORD base, void* ctx)
564 return SymEnumTypes(dbg_curr_process->handle, base, print_types_cb, ctx);
567 int print_types(void)
569 SymEnumerateModules(dbg_curr_process->handle, print_types_mod_cb, NULL);
570 return 0;
573 int types_print_type(const struct dbg_type* type, BOOL details)
575 WCHAR* ptr;
576 char tmp[256];
577 const char* name;
578 DWORD tag, udt, count;
579 struct dbg_type subtype;
581 if (type->id == dbg_itype_none || !types_get_info(type, TI_GET_SYMTAG, &tag))
583 dbg_printf("--invalid--<%lxh>--", type->id);
584 return FALSE;
587 if (types_get_info(type, TI_GET_SYMNAME, &ptr) && ptr)
589 WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
590 name = tmp;
591 HeapFree(GetProcessHeap(), 0, ptr);
593 else name = "--none--";
595 switch (tag)
597 case SymTagBaseType:
598 if (details) dbg_printf("Basic<%s>", name); else dbg_printf("%s", name);
599 break;
600 case SymTagPointerType:
601 types_get_info(type, TI_GET_TYPE, &subtype.id);
602 subtype.module = type->module;
603 types_print_type(&subtype, FALSE);
604 dbg_printf("*");
605 break;
606 case SymTagUDT:
607 types_get_info(type, TI_GET_UDTKIND, &udt);
608 switch (udt)
610 case UdtStruct: dbg_printf("struct %s", name); break;
611 case UdtUnion: dbg_printf("union %s", name); break;
612 case UdtClass: dbg_printf("class %s", name); break;
613 default: WINE_ERR("Unsupported UDT type (%ld) for %s", udt, name); break;
615 if (details &&
616 types_get_info(type, TI_GET_CHILDRENCOUNT, &count))
618 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
619 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
620 WCHAR* ptr;
621 char tmp[256];
622 int i;
623 struct dbg_type type_elt;
624 dbg_printf(" {");
626 fcp->Start = 0;
627 while (count)
629 fcp->Count = min(count, 256);
630 if (types_get_info(type, TI_FINDCHILDREN, fcp))
632 for (i = 0; i < min(fcp->Count, count); i++)
634 ptr = NULL;
635 type_elt.module = type->module;
636 type_elt.id = fcp->ChildId[i];
637 types_get_info(&type_elt, TI_GET_SYMNAME, &ptr);
638 if (!ptr) continue;
639 WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
640 HeapFree(GetProcessHeap(), 0, ptr);
641 dbg_printf("%s", tmp);
642 if (types_get_info(&type_elt, TI_GET_TYPE, &type_elt.id))
644 dbg_printf(":");
645 types_print_type(&type_elt, details);
647 if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", ");
650 count -= min(count, 256);
651 fcp->Start += 256;
653 dbg_printf("}");
655 break;
656 case SymTagArrayType:
657 types_get_info(type, TI_GET_TYPE, &subtype.id);
658 subtype.module = type->module;
659 types_print_type(&subtype, details);
660 dbg_printf(" %s[]", name);
661 break;
662 case SymTagEnum:
663 dbg_printf("enum %s", name);
664 break;
665 case SymTagFunctionType:
666 types_get_info(type, TI_GET_TYPE, &subtype.id);
667 subtype.module = type->module;
668 types_print_type(&subtype, FALSE);
669 dbg_printf(" (*%s)(", name);
670 if (types_get_info(type, TI_GET_CHILDRENCOUNT, &count))
672 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
673 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
674 int i;
676 fcp->Start = 0;
677 while (count)
679 fcp->Count = min(count, 256);
680 if (types_get_info(type, TI_FINDCHILDREN, fcp))
682 for (i = 0; i < min(fcp->Count, count); i++)
684 subtype.id = fcp->ChildId[i];
685 types_get_info(&subtype, TI_GET_TYPE, &subtype.id);
686 types_print_type(&subtype, FALSE);
687 if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", ");
690 count -= min(count, 256);
691 fcp->Start += 256;
694 dbg_printf(")");
695 break;
696 case SymTagTypedef:
697 dbg_printf(name);
698 break;
699 default:
700 WINE_ERR("Unknown type %lu for %s\n", tag, name);
701 break;
704 return TRUE;
707 /* helper to typecast pInfo to its expected type (_t) */
708 #define X(_t) (*((_t*)pInfo))
710 BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, void* pInfo)
712 if (type->id == dbg_itype_none) return FALSE;
713 if (type->module != 0)
715 DWORD ret, tag, bt;
716 ret = SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, ti, pInfo);
717 if (!ret &&
718 SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_SYMTAG, &tag) &&
719 tag == SymTagBaseType &&
720 SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_BASETYPE, &bt))
722 static const WCHAR voidW[] = {'v','o','i','d','\0'};
723 static const WCHAR charW[] = {'c','h','a','r','\0'};
724 static const WCHAR wcharW[] = {'W','C','H','A','R','\0'};
725 static const WCHAR intW[] = {'i','n','t','\0'};
726 static const WCHAR uintW[] = {'u','n','s','i','g','n','e','d',' ','i','n','t','\0'};
727 static const WCHAR floatW[] = {'f','l','o','a','t','\0'};
728 static const WCHAR boolW[] = {'b','o','o','l','\0'};
729 static const WCHAR longW[] = {'l','o','n','g',' ','i','n','t','\0'};
730 static const WCHAR ulongW[] = {'u','n','s','i','g','n','e','d',' ','l','o','n','g',' ','i','n','t','\0'};
731 static const WCHAR complexW[] = {'c','o','m','p','l','e','x','\0'};
732 const WCHAR* name = NULL;
734 switch (bt)
736 case btVoid: name = voidW; break;
737 case btChar: name = charW; break;
738 case btWChar: name = wcharW; break;
739 case btInt: name = intW; break;
740 case btUInt: name = uintW; break;
741 case btFloat: name = floatW; break;
742 case btBool: name = boolW; break;
743 case btLong: name = longW; break;
744 case btULong: name = ulongW; break;
745 case btComplex: name = complexW; break;
746 default: WINE_FIXME("Unsupported basic type %ld\n", bt); return FALSE;
748 X(WCHAR*) = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name) + 1) * sizeof(WCHAR));
749 if (X(WCHAR*))
751 lstrcpyW(X(WCHAR*), name);
752 ret = TRUE;
755 return ret;
758 assert(type->id >= dbg_itype_first);
760 switch (type->id)
762 case dbg_itype_unsigned_int:
763 switch (ti)
765 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
766 case TI_GET_LENGTH: X(DWORD64) = 4; break;
767 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
768 default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE;
770 break;
771 case dbg_itype_signed_int:
772 switch (ti)
774 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
775 case TI_GET_LENGTH: X(DWORD64) = 4; break;
776 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
777 default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE;
779 break;
780 case dbg_itype_unsigned_short_int:
781 switch (ti)
783 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
784 case TI_GET_LENGTH: X(DWORD64) = 2; break;
785 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
786 default: WINE_FIXME("unsupported %u for u-short int\n", ti); return FALSE;
788 break;
789 case dbg_itype_signed_short_int:
790 switch (ti)
792 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
793 case TI_GET_LENGTH: X(DWORD64) = 2; break;
794 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
795 default: WINE_FIXME("unsupported %u for s-short int\n", ti); return FALSE;
797 break;
798 case dbg_itype_unsigned_char_int:
799 switch (ti)
801 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
802 case TI_GET_LENGTH: X(DWORD64) = 1; break;
803 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
804 default: WINE_FIXME("unsupported %u for u-char int\n", ti); return FALSE;
806 break;
807 case dbg_itype_signed_char_int:
808 switch (ti)
810 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
811 case TI_GET_LENGTH: X(DWORD64) = 1; break;
812 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
813 default: WINE_FIXME("unsupported %u for s-char int\n", ti); return FALSE;
815 break;
816 case dbg_itype_char:
817 switch (ti)
819 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
820 case TI_GET_LENGTH: X(DWORD64) = 1; break;
821 case TI_GET_BASETYPE: X(DWORD) = btChar; break;
822 default: WINE_FIXME("unsupported %u for char int\n", ti); return FALSE;
824 break;
825 case dbg_itype_astring:
826 switch (ti)
828 case TI_GET_SYMTAG: X(DWORD) = SymTagPointerType; break;
829 case TI_GET_LENGTH: X(DWORD64) = 4; break;
830 case TI_GET_TYPE: X(DWORD) = dbg_itype_char; break;
831 default: WINE_FIXME("unsupported %u for a string\n", ti); return FALSE;
833 break;
834 case dbg_itype_segptr:
835 switch (ti)
837 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
838 case TI_GET_LENGTH: X(DWORD64) = 4; break;
839 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
840 default: WINE_FIXME("unsupported %u for seg-ptr\n", ti); return FALSE;
842 break;
843 default: WINE_FIXME("unsupported type id 0x%lx\n", type->id);
846 #undef X
847 return TRUE;