wined3d: Pass a wined3d_device_gl pointer to wined3d_device_create_primary_opengl_con...
[wine.git] / programs / winedbg / types.c
blob8f16a535606ec5fbc01adfab5a8e49965d89df78
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 <stdlib.h>
26 #include "debugger.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
31 /******************************************************************
32 * types_get_real_type
34 * Get rid of any potential typedef in the lvalue's type to get
35 * to the 'real' type (the one we can work upon).
37 BOOL types_get_real_type(struct dbg_type* type, DWORD* tag)
39 if (type->id == dbg_itype_none) return FALSE;
42 if (!types_get_info(type, TI_GET_SYMTAG, tag))
43 return FALSE;
44 if (*tag != SymTagTypedef) return TRUE;
45 } while (types_get_info(type, TI_GET_TYPE, &type->id));
46 return FALSE;
49 /******************************************************************
50 * types_extract_as_lgint
52 * Given a lvalue, try to get an integral (or pointer/address) value
53 * out of it
55 dbg_lgint_t types_extract_as_lgint(const struct dbg_lvalue* lvalue,
56 unsigned* psize, BOOL *issigned)
58 dbg_lgint_t rtn = 0;
59 DWORD tag, bt;
60 DWORD64 size;
61 struct dbg_type type = lvalue->type;
62 BOOL s = FALSE;
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_PTR)memory_to_linear_addr(&lvalue->addr);
71 if (tag != SymTagBaseType && lvalue->bitlen) dbg_printf("Unexpected bitfield on tag %d\n", tag);
73 if (psize) *psize = 0;
74 if (issigned) *issigned = FALSE;
75 switch (tag)
77 case SymTagBaseType:
78 if (!types_get_info(&type, TI_GET_LENGTH, &size) ||
79 !types_get_info(&type, TI_GET_BASETYPE, &bt))
81 WINE_ERR("Couldn't get information\n");
82 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
83 return rtn;
85 if (size > sizeof(rtn))
87 WINE_ERR("Size too large (%I64x)\n", size);
88 RaiseException(DEBUG_STATUS_NOT_AN_INTEGER, 0, 0, NULL);
89 return rtn;
91 switch (bt)
93 case btChar:
94 case btInt:
95 if (!memory_fetch_integer(lvalue, (unsigned)size, s = TRUE, &rtn))
96 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
97 break;
98 case btUInt:
99 if (!memory_fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn))
100 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
101 break;
102 case btFloat:
103 RaiseException(DEBUG_STATUS_NOT_AN_INTEGER, 0, 0, NULL);
105 if (psize) *psize = (unsigned)size;
106 if (issigned) *issigned = s;
107 break;
108 case SymTagPointerType:
109 if (!types_get_info(&type, TI_GET_LENGTH, &size) ||
110 !memory_fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn))
111 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
112 break;
113 case SymTagArrayType:
114 case SymTagUDT:
115 if (!memory_fetch_integer(lvalue, sizeof(unsigned), s = FALSE, &rtn))
116 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
117 break;
118 case SymTagEnum:
119 if (!types_get_info(&type, TI_GET_LENGTH, &size) ||
120 !memory_fetch_integer(lvalue, (unsigned)size, s = FALSE, &rtn))
121 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
122 break;
123 case SymTagFunctionType:
124 rtn = (ULONG_PTR)memory_to_linear_addr(&lvalue->addr);
125 break;
126 default:
127 WINE_FIXME("Unsupported tag %u\n", tag);
128 RaiseException(DEBUG_STATUS_NOT_AN_INTEGER, 0, 0, NULL);
131 return rtn;
134 /******************************************************************
135 * types_extract_as_integer
137 * Given a lvalue, try to get an integral (or pointer/address) value
138 * out of it
140 dbg_lgint_t types_extract_as_integer(const struct dbg_lvalue* lvalue)
142 return types_extract_as_lgint(lvalue, NULL, NULL);
145 /******************************************************************
146 * types_extract_as_address
150 void types_extract_as_address(const struct dbg_lvalue* lvalue, ADDRESS64* addr)
152 if (lvalue->type.id == dbg_itype_segptr && lvalue->type.module == 0)
154 *addr = lvalue->addr;
156 else
158 addr->Mode = AddrModeFlat;
159 addr->Offset = types_extract_as_lgint(lvalue, NULL, NULL);
163 BOOL types_store_value(struct dbg_lvalue* lvalue_to, const struct dbg_lvalue* lvalue_from)
165 dbg_lgint_t val;
166 DWORD64 size;
168 if (!types_get_info(&lvalue_to->type, TI_GET_LENGTH, &size)) return FALSE;
169 if (sizeof(val) < size)
171 dbg_printf("Insufficient size\n");
172 return FALSE;
174 /* FIXME: should support floats as well */
175 val = types_extract_as_integer(lvalue_from);
176 return memory_store_integer(lvalue_to, val);
179 /******************************************************************
180 * types_get_udt_element_lvalue
182 * Implement a structure derefencement
184 static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue, const struct dbg_type* type)
186 DWORD offset, bitoffset;
187 DWORD64 length;
189 types_get_info(type, TI_GET_TYPE, &lvalue->type.id);
190 lvalue->type.module = type->module;
191 if (!types_get_info(type, TI_GET_OFFSET, &offset)) return FALSE;
192 lvalue->addr.Offset += offset;
194 if (types_get_info(type, TI_GET_BITPOSITION, &bitoffset))
196 types_get_info(type, TI_GET_LENGTH, &length);
197 lvalue->bitlen = length;
198 lvalue->bitstart = bitoffset;
199 if (lvalue->bitlen != length || lvalue->bitstart != bitoffset)
201 dbg_printf("too wide bitfields\n"); /* shouldn't happen */
202 return FALSE;
205 else
206 lvalue->bitlen = lvalue->bitstart = 0;
208 return TRUE;
211 /******************************************************************
212 * types_udt_find_element
215 BOOL types_udt_find_element(struct dbg_lvalue* lvalue, const char* name)
217 DWORD tag, count;
218 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
219 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
220 WCHAR* ptr;
221 char tmp[256];
222 struct dbg_type type;
224 if (!types_get_real_type(&lvalue->type, &tag) || tag != SymTagUDT)
225 return FALSE;
227 if (types_get_info(&lvalue->type, TI_GET_CHILDRENCOUNT, &count))
229 fcp->Start = 0;
230 while (count)
232 fcp->Count = min(count, 256);
233 if (types_get_info(&lvalue->type, TI_FINDCHILDREN, fcp))
235 unsigned i;
236 type.module = lvalue->type.module;
237 for (i = 0; i < min(fcp->Count, count); i++)
239 type.id = fcp->ChildId[i];
240 if (types_get_info(&type, TI_GET_SYMNAME, &ptr) && ptr)
242 WideCharToMultiByte(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp), NULL, NULL);
243 HeapFree(GetProcessHeap(), 0, ptr);
244 if (!strcmp(tmp, name))
245 return types_get_udt_element_lvalue(lvalue, &type);
249 count -= min(count, 256);
250 fcp->Start += 256;
253 return FALSE;
256 /******************************************************************
257 * types_array_index
259 * Grab an element from an array
261 BOOL types_array_index(const struct dbg_lvalue* lvalue, int index, struct dbg_lvalue* result)
263 struct dbg_type type = lvalue->type;
264 DWORD tag, count;
266 memset(result, 0, sizeof(*result));
267 result->type.id = dbg_itype_none;
268 result->type.module = 0;
270 if (!types_get_real_type(&type, &tag)) return FALSE;
271 switch (tag)
273 case SymTagArrayType:
274 if (!types_get_info(&type, TI_GET_COUNT, &count)) return FALSE;
275 if (index < 0 || index >= count) return FALSE;
276 result->addr = lvalue->addr;
277 break;
278 case SymTagPointerType:
279 if (!memory_read_value(lvalue, dbg_curr_process->be_cpu->pointer_size, &result->addr.Offset))
280 return FALSE;
281 result->addr.Mode = AddrModeFlat;
282 switch (dbg_curr_process->be_cpu->pointer_size)
284 case 4: result->addr.Offset = (DWORD)result->addr.Offset; break;
285 case 8: break;
286 default: assert(0);
288 break;
289 default:
290 assert(FALSE);
293 * Get the base type, so we know how much to index by.
295 if (!types_get_info(&type, TI_GET_TYPE, &result->type.id)) return FALSE;
296 result->type.module = type.module;
297 if (index)
299 DWORD64 length;
300 if (!types_get_info(&result->type, TI_GET_LENGTH, &length)) return FALSE;
301 result->addr.Offset += index * (DWORD)length;
303 /* FIXME: the following statement is not always true (and can lead to buggy behavior).
304 * There is no way to tell where the deref:ed value is...
305 * For example:
306 * x is a pointer to struct s, x being on the stack
307 * => lvalue is in debuggee, result is in debugger
308 * x is a pointer to struct s, x being optimized into a reg
309 * => lvalue is debugger, result is debuggee
310 * x is a pointer to internal variable x
311 * => lvalue is debugger, result is debuggee
312 * So we always force debuggee address space, because dereferencing pointers to
313 * internal variables is very unlikely. A correct fix would be
314 * rather large.
316 result->in_debuggee = 1;
317 return TRUE;
320 struct type_find_t
322 ULONG result; /* out: the found type */
323 enum SymTagEnum tag; /* in: the tag to look for */
324 union
326 ULONG typeid; /* when tag is SymTagUDT */
327 const char* name; /* when tag is SymTagPointerType */
328 } u;
331 static BOOL CALLBACK types_cb(PSYMBOL_INFO sym, ULONG size, void* _user)
333 struct type_find_t* user = _user;
334 BOOL ret = TRUE;
335 struct dbg_type type;
336 DWORD type_id;
338 if (sym->Tag == user->tag)
340 switch (user->tag)
342 case SymTagUDT:
343 if (!strcmp(user->u.name, sym->Name))
345 user->result = sym->TypeIndex;
346 ret = FALSE;
348 break;
349 case SymTagPointerType:
350 type.module = sym->ModBase;
351 type.id = sym->TypeIndex;
352 if (types_get_info(&type, TI_GET_TYPE, &type_id) && type_id == user->u.typeid)
354 user->result = sym->TypeIndex;
355 ret = FALSE;
357 break;
358 default: break;
361 return ret;
364 /******************************************************************
365 * types_find_pointer
367 * Should look up in module based at linear whether (typeid*) exists
368 * Otherwise, we could create it locally
370 struct dbg_type types_find_pointer(const struct dbg_type* type)
372 struct type_find_t f;
373 struct dbg_type ret;
375 f.result = dbg_itype_none;
376 f.tag = SymTagPointerType;
377 f.u.typeid = type->id;
378 SymEnumTypes(dbg_curr_process->handle, type->module, types_cb, &f);
379 ret.module = type->module;
380 ret.id = f.result;
381 return ret;
384 /******************************************************************
385 * types_find_type
387 * Should look up in the module based at linear address whether a type
388 * named 'name' and with the correct tag exists
390 struct dbg_type types_find_type(DWORD64 linear, const char* name, enum SymTagEnum tag)
393 struct type_find_t f;
394 struct dbg_type ret;
396 f.result = dbg_itype_none;
397 f.tag = tag;
398 f.u.name = name;
399 SymEnumTypes(dbg_curr_process->handle, linear, types_cb, &f);
400 ret.module = linear;
401 ret.id = f.result;
402 return ret;
405 /***********************************************************************
406 * print_value
408 * Implementation of the 'print' command.
410 void print_value(const struct dbg_lvalue* lvalue, char format, int level)
412 struct dbg_type type = lvalue->type;
413 struct dbg_lvalue lvalue_field;
414 int i;
415 DWORD tag;
416 DWORD count;
417 DWORD64 size;
419 if (!types_get_real_type(&type, &tag))
421 WINE_FIXME("---error\n");
422 return;
425 if (type.id == dbg_itype_none)
427 /* No type, just print the addr value */
428 print_bare_address(&lvalue->addr);
429 goto leave;
432 if (format == 'i' || format == 's' || format == 'w' || format == 'b' || format == 'g')
434 dbg_printf("Format specifier '%c' is meaningless in 'print' command\n", format);
435 format = '\0';
438 switch (tag)
440 case SymTagBaseType:
441 case SymTagEnum:
442 case SymTagPointerType:
443 /* FIXME: this in not 100% optimal (as we're going through the typedef handling
444 * stuff again
446 print_basic(lvalue, format);
447 break;
448 case SymTagUDT:
449 if (types_get_info(&type, TI_GET_CHILDRENCOUNT, &count))
451 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
452 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
453 WCHAR* ptr;
454 struct dbg_type sub_type;
456 dbg_printf("{");
457 fcp->Start = 0;
458 while (count)
460 fcp->Count = min(count, 256);
461 if (types_get_info(&type, TI_FINDCHILDREN, fcp))
463 for (i = 0; i < min(fcp->Count, count); i++)
465 sub_type.module = type.module;
466 sub_type.id = fcp->ChildId[i];
467 if (!types_get_info(&sub_type, TI_GET_SYMNAME, &ptr) || !ptr) continue;
468 dbg_printf("%ls=", ptr);
469 HeapFree(GetProcessHeap(), 0, ptr);
470 lvalue_field = *lvalue;
471 if (types_get_udt_element_lvalue(&lvalue_field, &sub_type))
473 print_value(&lvalue_field, format, level + 1);
475 if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", ");
478 count -= min(count, 256);
479 fcp->Start += 256;
481 dbg_printf("}");
483 break;
484 case SymTagArrayType:
486 * Loop over all of the entries, printing stuff as we go.
488 count = 1; size = 1;
489 types_get_info(&type, TI_GET_COUNT, &count);
490 types_get_info(&type, TI_GET_LENGTH, &size);
491 lvalue_field = *lvalue;
492 types_get_info(&lvalue_field.type, TI_GET_TYPE, &lvalue_field.type.id);
493 types_get_real_type(&lvalue_field.type, &tag);
495 if (size == count && tag == SymTagBaseType)
497 DWORD basetype;
499 types_get_info(&lvalue_field.type, TI_GET_BASETYPE, &basetype);
500 if (basetype == btChar)
502 char buffer[256];
504 * Special handling for character arrays.
506 unsigned len = min(count, sizeof(buffer));
507 memory_get_string(dbg_curr_process,
508 memory_to_linear_addr(&lvalue->addr),
509 lvalue->in_debuggee, TRUE, buffer, len);
510 dbg_printf("\"%s%s\"", buffer, (len < count) ? "..." : "");
511 break;
514 dbg_printf("{");
515 for (i = 0; i < count; i++)
517 print_value(&lvalue_field, format, level + 1);
518 lvalue_field.addr.Offset += size / count;
519 dbg_printf((i == count - 1) ? "}" : ", ");
521 break;
522 case SymTagFunctionType:
523 dbg_printf("Function ");
524 print_bare_address(&lvalue->addr);
525 dbg_printf(": ");
526 types_print_type(&type, FALSE);
527 break;
528 case SymTagTypedef:
529 lvalue_field = *lvalue;
530 types_get_info(&lvalue->type, TI_GET_TYPE, &lvalue_field.type.id);
531 print_value(&lvalue_field, format, level);
532 break;
533 default:
534 WINE_FIXME("Unknown tag (%u)\n", tag);
535 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
536 break;
539 leave:
541 if (level == 0) dbg_printf("\n");
544 static BOOL CALLBACK print_types_cb(PSYMBOL_INFO sym, ULONG size, void* ctx)
546 struct dbg_type type;
547 type.module = sym->ModBase;
548 type.id = sym->TypeIndex;
549 dbg_printf("Mod: %0*Ix ID: %08x\n", ADDRWIDTH, type.module, type.id);
550 types_print_type(&type, TRUE);
551 dbg_printf("\n");
552 return TRUE;
555 static BOOL CALLBACK print_types_mod_cb(PCSTR mod_name, DWORD64 base, PVOID ctx)
557 return SymEnumTypes(dbg_curr_process->handle, base, print_types_cb, ctx);
560 BOOL print_types(void)
562 if (!dbg_curr_process)
564 dbg_printf("No known process, cannot print types\n");
565 return FALSE;
567 SymEnumerateModules64(dbg_curr_process->handle, print_types_mod_cb, NULL);
568 return FALSE;
571 BOOL types_print_type(const struct dbg_type* type, BOOL details)
573 WCHAR* ptr;
574 const WCHAR* name;
575 DWORD tag, udt, count;
576 struct dbg_type subtype;
578 if (type->id == dbg_itype_none || !types_get_info(type, TI_GET_SYMTAG, &tag))
580 dbg_printf("--invalid--<%xh>--", type->id);
581 return FALSE;
584 name = (types_get_info(type, TI_GET_SYMNAME, &ptr) && ptr) ? ptr : L"--none--";
586 switch (tag)
588 case SymTagBaseType:
589 if (details) dbg_printf("Basic<%ls>", name); else dbg_printf("%ls", name);
590 break;
591 case SymTagPointerType:
592 types_get_info(type, TI_GET_TYPE, &subtype.id);
593 subtype.module = type->module;
594 types_print_type(&subtype, FALSE);
595 dbg_printf("*");
596 break;
597 case SymTagUDT:
598 types_get_info(type, TI_GET_UDTKIND, &udt);
599 switch (udt)
601 case UdtStruct: dbg_printf("struct %ls", name); break;
602 case UdtUnion: dbg_printf("union %ls", name); break;
603 case UdtClass: dbg_printf("class %ls", name); break;
604 default: WINE_ERR("Unsupported UDT type (%d) for %ls\n", udt, name); break;
606 if (details &&
607 types_get_info(type, TI_GET_CHILDRENCOUNT, &count))
609 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
610 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
611 WCHAR* ptr;
612 int i;
613 struct dbg_type type_elt;
614 dbg_printf(" {");
616 fcp->Start = 0;
617 while (count)
619 fcp->Count = min(count, 256);
620 if (types_get_info(type, TI_FINDCHILDREN, fcp))
622 for (i = 0; i < min(fcp->Count, count); i++)
624 type_elt.module = type->module;
625 type_elt.id = fcp->ChildId[i];
626 if (!types_get_info(&type_elt, TI_GET_SYMNAME, &ptr) || !ptr) continue;
627 dbg_printf("%ls", ptr);
628 HeapFree(GetProcessHeap(), 0, ptr);
629 if (types_get_info(&type_elt, TI_GET_TYPE, &type_elt.id))
631 dbg_printf(":");
632 types_print_type(&type_elt, details);
634 if (i < min(fcp->Count, count) - 1 || count > 256) dbg_printf(", ");
637 count -= min(count, 256);
638 fcp->Start += 256;
640 dbg_printf("}");
642 break;
643 case SymTagArrayType:
644 types_get_info(type, TI_GET_TYPE, &subtype.id);
645 subtype.module = type->module;
646 types_print_type(&subtype, details);
647 if (types_get_info(type, TI_GET_COUNT, &count))
648 dbg_printf(" %ls[%d]", name, count);
649 else
650 dbg_printf(" %ls[]", name);
651 break;
652 case SymTagEnum:
653 dbg_printf("enum %ls", name);
654 break;
655 case SymTagFunctionType:
656 types_get_info(type, TI_GET_TYPE, &subtype.id);
657 /* is the returned type the same object as function sig itself ? */
658 if (subtype.id != type->id)
660 subtype.module = type->module;
661 types_print_type(&subtype, FALSE);
663 else
665 subtype.module = 0;
666 dbg_printf("<ret_type=self>");
668 dbg_printf(" (*%ls)(", name);
669 if (types_get_info(type, TI_GET_CHILDRENCOUNT, &count))
671 char buffer[sizeof(TI_FINDCHILDREN_PARAMS) + 256 * sizeof(DWORD)];
672 TI_FINDCHILDREN_PARAMS* fcp = (TI_FINDCHILDREN_PARAMS*)buffer;
673 int i;
675 fcp->Start = 0;
676 if (!count) dbg_printf("void");
677 else 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("%ls", name);
698 break;
699 default:
700 WINE_ERR("Unknown type %u for %ls\n", tag, name);
701 break;
704 HeapFree(GetProcessHeap(), 0, ptr);
705 return TRUE;
708 /* helper to typecast pInfo to its expected type (_t) */
709 #define X(_t) (*((_t*)pInfo))
711 BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, void* pInfo)
713 if (type->id == dbg_itype_none) return FALSE;
714 if (type->module != 0)
716 DWORD ret, tag, bt;
717 ret = SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, ti, pInfo);
718 if (!ret &&
719 ti == TI_GET_SYMNAME &&
720 SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_SYMTAG, &tag) &&
721 tag == SymTagBaseType &&
722 SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_BASETYPE, &bt))
724 const WCHAR* name = NULL;
726 switch (bt)
728 case btVoid: name = L"void"; break;
729 case btChar: name = L"char"; break;
730 case btWChar: name = L"WCHAR"; break;
731 case btInt: name = L"int"; break;
732 case btUInt: name = L"unsigned int"; break;
733 case btFloat: name = L"float"; break;
734 case btBool: name = L"bool"; break;
735 case btLong: name = L"long int"; break;
736 case btULong: name = L"unsigned long int"; break;
737 case btComplex: name = L"complex"; break;
738 default: WINE_FIXME("Unsupported basic type %u\n", bt); return FALSE;
740 X(WCHAR*) = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name) + 1) * sizeof(WCHAR));
741 if (X(WCHAR*))
743 lstrcpyW(X(WCHAR*), name);
744 ret = TRUE;
747 return ret;
750 assert(type->id >= dbg_itype_first);
752 switch (type->id)
754 case dbg_itype_lguint:
755 switch (ti)
757 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
758 case TI_GET_LENGTH: X(DWORD64) = sizeof(dbg_lguint_t); break;
759 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
760 default: WINE_FIXME("unsupported %u for lguint_t\n", ti); return FALSE;
762 break;
763 case dbg_itype_lgint:
764 switch (ti)
766 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
767 case TI_GET_LENGTH: X(DWORD64) = sizeof(dbg_lgint_t); break;
768 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
769 default: WINE_FIXME("unsupported %u for lgint_t\n", ti); return FALSE;
771 break;
772 case dbg_itype_unsigned_long_int:
773 switch (ti)
775 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
776 case TI_GET_LENGTH: X(DWORD64) = ADDRSIZE; break;
777 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
778 default: WINE_FIXME("unsupported %u for u-long int\n", ti); return FALSE;
780 break;
781 case dbg_itype_signed_long_int:
782 switch (ti)
784 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
785 case TI_GET_LENGTH: X(DWORD64) = ADDRSIZE; break;
786 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
787 default: WINE_FIXME("unsupported %u for s-long int\n", ti); return FALSE;
789 break;
790 case dbg_itype_unsigned_int:
791 switch (ti)
793 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
794 case TI_GET_LENGTH: X(DWORD64) = 4; break;
795 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
796 default: WINE_FIXME("unsupported %u for u-int\n", ti); return FALSE;
798 break;
799 case dbg_itype_signed_int:
800 switch (ti)
802 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
803 case TI_GET_LENGTH: X(DWORD64) = 4; break;
804 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
805 default: WINE_FIXME("unsupported %u for s-int\n", ti); return FALSE;
807 break;
808 case dbg_itype_unsigned_short_int:
809 switch (ti)
811 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
812 case TI_GET_LENGTH: X(DWORD64) = 2; break;
813 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
814 default: WINE_FIXME("unsupported %u for u-short int\n", ti); return FALSE;
816 break;
817 case dbg_itype_signed_short_int:
818 switch (ti)
820 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
821 case TI_GET_LENGTH: X(DWORD64) = 2; break;
822 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
823 default: WINE_FIXME("unsupported %u for s-short int\n", ti); return FALSE;
825 break;
826 case dbg_itype_unsigned_char_int:
827 switch (ti)
829 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
830 case TI_GET_LENGTH: X(DWORD64) = 1; break;
831 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
832 default: WINE_FIXME("unsupported %u for u-char int\n", ti); return FALSE;
834 break;
835 case dbg_itype_signed_char_int:
836 switch (ti)
838 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
839 case TI_GET_LENGTH: X(DWORD64) = 1; break;
840 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
841 default: WINE_FIXME("unsupported %u for s-char int\n", ti); return FALSE;
843 break;
844 case dbg_itype_char:
845 switch (ti)
847 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
848 case TI_GET_LENGTH: X(DWORD64) = 1; break;
849 case TI_GET_BASETYPE: X(DWORD) = btChar; break;
850 default: WINE_FIXME("unsupported %u for char int\n", ti); return FALSE;
852 break;
853 case dbg_itype_astring:
854 switch (ti)
856 case TI_GET_SYMTAG: X(DWORD) = SymTagPointerType; break;
857 case TI_GET_LENGTH: X(DWORD64) = ADDRSIZE; break;
858 case TI_GET_TYPE: X(DWORD) = dbg_itype_char; break;
859 default: WINE_FIXME("unsupported %u for a string\n", ti); return FALSE;
861 break;
862 case dbg_itype_segptr:
863 switch (ti)
865 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
866 case TI_GET_LENGTH: X(DWORD64) = 4; break;
867 case TI_GET_BASETYPE: X(DWORD) = btInt; break;
868 default: WINE_FIXME("unsupported %u for seg-ptr\n", ti); return FALSE;
870 break;
871 case dbg_itype_short_real:
872 switch (ti)
874 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
875 case TI_GET_LENGTH: X(DWORD64) = 4; break;
876 case TI_GET_BASETYPE: X(DWORD) = btFloat; break;
877 default: WINE_FIXME("unsupported %u for short real\n", ti); return FALSE;
879 break;
880 case dbg_itype_real:
881 switch (ti)
883 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
884 case TI_GET_LENGTH: X(DWORD64) = 8; break;
885 case TI_GET_BASETYPE: X(DWORD) = btFloat; break;
886 default: WINE_FIXME("unsupported %u for real\n", ti); return FALSE;
888 break;
889 case dbg_itype_long_real:
890 switch (ti)
892 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
893 case TI_GET_LENGTH: X(DWORD64) = 10; break;
894 case TI_GET_BASETYPE: X(DWORD) = btFloat; break;
895 default: WINE_FIXME("unsupported %u for long real\n", ti); return FALSE;
897 break;
898 case dbg_itype_m128a:
899 switch (ti)
901 case TI_GET_SYMTAG: X(DWORD) = SymTagBaseType; break;
902 case TI_GET_LENGTH: X(DWORD64) = 16; break;
903 case TI_GET_BASETYPE: X(DWORD) = btUInt; break;
904 default: WINE_FIXME("unsupported %u for XMM register\n", ti); return FALSE;
906 break;
907 default: WINE_FIXME("unsupported type id 0x%x\n", type->id);
910 #undef X
911 return TRUE;