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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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.
28 #include <sys/types.h>
36 #define NR_TYPE_HASH 521
39 static const int DEBUG_maxchar
= 1024;
43 struct en_values
* next
;
52 struct datatype
* type
;
60 struct datatype
* next
;
73 unsigned short bitoff
;
75 struct datatype
* basetype
;
80 struct datatype
* pointsto
;
84 struct datatype
* rettype
;
90 struct datatype
* basictype
;
95 struct member
* members
;
99 struct en_values
* members
;
105 * All of the types that have been defined so far.
107 static struct datatype
* type_hash_table
[NR_TYPE_HASH
+ 1];
108 static struct datatype
* pointer_types
= NULL
;
109 static struct datatype
* basic_types
[DT_BASIC_LAST
];
111 static unsigned int type_hash( const char * name
)
113 unsigned int hash
= 0;
121 hash
= (hash
<< 4) + *p
++;
123 if( (tmp
= (hash
& 0xf0000000)) )
129 return hash
% NR_TYPE_HASH
;
133 static struct datatype
*
134 DEBUG_InitBasic(int type
, char * name
, int size
, int b_signed
,
135 char * output_format
)
139 struct datatype
* dt
;
140 dt
= (struct datatype
*) DBG_alloc(sizeof(struct datatype
));
146 hash
= type_hash(name
);
155 dt
->next
= type_hash_table
[hash
];
156 type_hash_table
[hash
] = dt
;
157 dt
->un
.basic
.basic_type
= type
;
158 dt
->un
.basic
.basic_size
= size
;
159 dt
->un
.basic
.b_signed
= b_signed
;
160 dt
->un
.basic
.output_format
= output_format
;
161 basic_types
[type
] = dt
;
169 DEBUG_LookupDataType(enum debug_type xtype
, int hash
, const char * typename
)
171 struct datatype
* dt
= NULL
;
173 if( typename
!= NULL
)
175 for( dt
= type_hash_table
[hash
]; dt
; dt
= dt
->next
)
177 if( xtype
!= dt
->type
|| dt
->name
== NULL
178 || dt
->name
[0] != typename
[0])
183 if( strcmp(dt
->name
, typename
) == 0 )
194 DEBUG_GetBasicType(enum debug_type_basic basic
)
196 if (basic
== 0 || basic
>= DT_BASIC_LAST
)
200 return basic_types
[basic
];
204 DEBUG_NewDataType(enum debug_type xtype
, const char * typename
)
206 struct datatype
* dt
= NULL
;
210 * The last bucket is special, and is used to hold typeless names.
212 if( typename
== NULL
)
218 hash
= type_hash(typename
);
221 dt
= DEBUG_LookupDataType(xtype
, hash
, typename
);
225 dt
= (struct datatype
*) DBG_alloc(sizeof(struct datatype
));
229 memset(dt
, 0, sizeof(*dt
));
232 if( typename
!= NULL
)
234 dt
->name
= DBG_strdup(typename
);
240 if( xtype
== DT_POINTER
)
242 dt
->next
= pointer_types
;
247 dt
->next
= type_hash_table
[hash
];
248 type_hash_table
[hash
] = dt
;
257 DEBUG_FindOrMakePointerType(struct datatype
* reftype
)
259 struct datatype
* dt
= NULL
;
261 if( reftype
!= NULL
)
263 for( dt
= pointer_types
; dt
; dt
= dt
->next
)
265 if( dt
->type
!= DT_POINTER
)
270 if( dt
->un
.pointer
.pointsto
== reftype
)
279 dt
= (struct datatype
*) DBG_alloc(sizeof(struct datatype
));
283 dt
->type
= DT_POINTER
;
284 dt
->un
.pointer
.pointsto
= reftype
;
285 dt
->next
= pointer_types
;
294 DEBUG_InitTypes(void)
296 static int beenhere
= 0;
298 if( beenhere
++ != 0 )
304 * Initialize a few builtin types.
307 DEBUG_InitBasic(DT_BASIC_INT
,"int",4,1,"%d");
308 DEBUG_InitBasic(DT_BASIC_CHAR
,"char",1,1,"'%c'");
309 DEBUG_InitBasic(DT_BASIC_LONGINT
,"long int",4,1,"%d");
310 DEBUG_InitBasic(DT_BASIC_UINT
,"unsigned int",4,0,"%d");
311 DEBUG_InitBasic(DT_BASIC_ULONGINT
,"long unsigned int",4,0,"%d");
312 DEBUG_InitBasic(DT_BASIC_LONGLONGINT
,"long long int",8,1,"%ld");
313 DEBUG_InitBasic(DT_BASIC_ULONGLONGINT
,"long long unsigned int",8,0,"%ld");
314 DEBUG_InitBasic(DT_BASIC_SHORTINT
,"short int",2,1,"%d");
315 DEBUG_InitBasic(DT_BASIC_USHORTINT
,"short unsigned int",2,0,"%d");
316 DEBUG_InitBasic(DT_BASIC_SCHAR
,"signed char",1,1,"'%c'");
317 DEBUG_InitBasic(DT_BASIC_UCHAR
,"unsigned char",1,0,"'%c'");
318 DEBUG_InitBasic(DT_BASIC_FLOAT
,"float",4,0,"%f");
319 DEBUG_InitBasic(DT_BASIC_DOUBLE
,"long double",12,0,NULL
);
320 DEBUG_InitBasic(DT_BASIC_LONGDOUBLE
,"double",8,0,"%lf");
321 DEBUG_InitBasic(DT_BASIC_CMPLX_INT
,"complex int",8,1,NULL
);
322 DEBUG_InitBasic(DT_BASIC_CMPLX_FLOAT
,"complex float",8,0,NULL
);
323 DEBUG_InitBasic(DT_BASIC_CMPLX_DOUBLE
,"complex double",16,0,NULL
);
324 DEBUG_InitBasic(DT_BASIC_CMPLX_LONGDOUBLE
,"complex long double",24,0,NULL
);
325 DEBUG_InitBasic(DT_BASIC_VOID
,"void",0,0,NULL
);
326 DEBUG_InitBasic(DT_BASIC_BOOL1
,NULL
,1,0,"%B");
327 DEBUG_InitBasic(DT_BASIC_BOOL2
,NULL
,2,0,"%B");
328 DEBUG_InitBasic(DT_BASIC_BOOL4
,NULL
,4,0,"%B");
330 basic_types
[DT_BASIC_STRING
] = DEBUG_NewDataType(DT_POINTER
, NULL
);
331 DEBUG_SetPointerType(basic_types
[DT_BASIC_STRING
], basic_types
[DT_BASIC_CHAR
]);
334 * Special version of int used with constants of various kinds.
336 DEBUG_InitBasic(DT_BASIC_CONST_INT
,NULL
,4,1,"%d");
339 * Now initialize the builtins for codeview.
341 DEBUG_InitCVDataTypes();
343 DEBUG_InitBasic(DT_BASIC_CONTEXT
,NULL
,4,0,"%R");
347 DEBUG_GetExprValue(const DBG_VALUE
* _value
, char** format
)
351 struct datatype
* type2
= NULL
;
352 struct en_values
* e
;
353 char * def_format
= "0x%x";
354 DBG_VALUE value
= *_value
;
356 assert(_value
->cookie
== DV_TARGET
|| _value
->cookie
== DV_HOST
);
359 /* FIXME? I don't quite get this...
360 * if this is wrong, value.addr shall be linearized
363 assert(value
.type
!= NULL
);
365 switch (value
.type
->type
) {
368 if (value
.type
->un
.basic
.basic_size
> sizeof(rtn
)) {
369 DEBUG_Printf(DBG_CHN_ERR
, "Size too large (%d)\n",
370 value
.type
->un
.basic
.basic_size
);
373 /* FIXME: following code implies i386 byte ordering */
374 if (_value
->cookie
== DV_TARGET
) {
375 if (!DEBUG_READ_MEM_VERBOSE((void*)value
.addr
.off
, &rtn
,
376 value
.type
->un
.basic
.basic_size
))
379 memcpy(&rtn
, (void*)value
.addr
.off
, value
.type
->un
.basic
.basic_size
);
382 if ( (value
.type
->un
.basic
.b_signed
)
383 && ((value
.type
->un
.basic
.basic_size
& 3) != 0)
384 && ((rtn
>> (value
.type
->un
.basic
.basic_size
* 8 - 1)) != 0)) {
385 rtn
= rtn
| ((-1) << (value
.type
->un
.basic
.basic_size
* 8));
387 /* float type has to be promoted as a double */
388 if (value
.type
->un
.basic
.basic_type
== DT_BASIC_FLOAT
) {
391 memcpy(&f
, &rtn
, sizeof(f
));
393 memcpy(&rtn
, &d
, sizeof(rtn
));
395 if (value
.type
->un
.basic
.output_format
!= NULL
) {
396 def_format
= value
.type
->un
.basic
.output_format
;
400 * Check for single character prints that are out of range.
402 if ( value
.type
->un
.basic
.basic_size
== 1
403 && strcmp(def_format
, "'%c'") == 0
404 && ((rtn
< 0x20) || (rtn
> 0x80))) {
409 if (_value
->cookie
== DV_TARGET
) {
410 if (!DEBUG_READ_MEM_VERBOSE((void*)value
.addr
.off
, &rtn2
, sizeof(void*)))
413 rtn2
= *(unsigned int*)(value
.addr
.off
);
416 type2
= value
.type
->un
.pointer
.pointsto
;
419 def_format
= "Internal symbol error: unable to access memory location 0x%08x";
424 if (type2
->type
== DT_BASIC
&& type2
->un
.basic
.basic_size
== 1) {
425 if (_value
->cookie
== DV_TARGET
) {
427 def_format
= "\"%S\"";
428 /* FIXME: assuming little endian */
429 if (!DEBUG_READ_MEM_VERBOSE((void*)rtn2
, &ch
, 1))
432 def_format
= "\"%s\"";
435 def_format
= "0x%8.8x";
441 assert(_value
->cookie
== DV_TARGET
);
442 if (!DEBUG_READ_MEM_VERBOSE((void*)value
.addr
.off
, &rtn2
, sizeof(rtn2
)))
445 def_format
= "0x%8.8x";
448 assert(_value
->cookie
== DV_TARGET
);
449 if (!DEBUG_READ_MEM_VERBOSE((void*)value
.addr
.off
, &rtn2
, sizeof(rtn2
)))
453 for (e
= value
.type
->un
.enumeration
.members
; e
; e
= e
->next
) {
454 if (e
->value
== rtn
) {
467 if (format
!= NULL
) {
468 *format
= def_format
;
474 DEBUG_TypeDerefPointer(const DBG_VALUE
*value
, struct datatype
** newtype
)
476 DBG_ADDR addr
= value
->addr
;
479 assert(value
->cookie
== DV_TARGET
|| value
->cookie
== DV_HOST
);
484 * Make sure that this really makes sense.
486 if( value
->type
->type
!= DT_POINTER
)
489 if (value
->cookie
== DV_TARGET
) {
490 if (!DEBUG_READ_MEM((void*)value
->addr
.off
, &val
, sizeof(val
)))
493 val
= *(unsigned int*)value
->addr
.off
;
496 *newtype
= value
->type
->un
.pointer
.pointsto
;
498 return DEBUG_ToLinear(&addr
); /* FIXME: is this right (or "better") ? */
502 DEBUG_FindStructElement(DBG_VALUE
* value
, const char * ele_name
, int * tmpbuf
)
507 assert(value
->cookie
== DV_TARGET
|| value
->cookie
== DV_HOST
);
510 * Make sure that this really makes sense.
512 if( value
->type
->type
!= DT_STRUCT
)
518 for(m
= value
->type
->un
.structure
.members
; m
; m
= m
->next
)
520 if( strcmp(m
->name
, ele_name
) == 0 )
522 value
->type
= m
->type
;
523 if( (m
->offset
& 7) != 0 || (m
->size
& 7) != 0)
526 * Bitfield operation. We have to extract the field and store
527 * it in a temporary buffer so that we get it all right.
529 *tmpbuf
= ((*(int* ) (value
->addr
.off
+ (m
->offset
>> 3))) >> (m
->offset
& 7));
530 value
->addr
.off
= (int) tmpbuf
;
532 mask
= 0xffffffff << (m
->size
);
535 * OK, now we have the correct part of the number.
536 * Check to see whether the basic type is signed or not, and if so,
537 * we need to sign extend the number.
539 if( m
->type
->type
== DT_BASIC
&& m
->type
->un
.basic
.b_signed
!= 0
540 && (*tmpbuf
& (1 << (m
->size
- 1))) != 0 )
547 value
->addr
.off
+= (m
->offset
>> 3);
558 DEBUG_SetStructSize(struct datatype
* dt
, int size
)
560 assert(dt
->type
== DT_STRUCT
);
562 if( dt
->un
.structure
.members
!= NULL
)
567 dt
->un
.structure
.size
= size
;
568 dt
->un
.structure
.members
= NULL
;
574 DEBUG_CopyFieldlist(struct datatype
* dt
, struct datatype
* dt2
)
576 if (!(dt
->type
== dt2
->type
&& ((dt
->type
== DT_STRUCT
) || (dt
->type
== DT_ENUM
)))) {
577 DEBUG_Printf(DBG_CHN_MESG
, "Error: Copyfield list mismatch (%d<>%d): ", dt
->type
, dt2
->type
);
578 DEBUG_PrintTypeCast(dt
);
579 DEBUG_Printf(DBG_CHN_MESG
, " ");
580 DEBUG_PrintTypeCast(dt2
);
581 DEBUG_Printf(DBG_CHN_MESG
, "\n");
585 if( dt
->type
== DT_STRUCT
)
587 dt
->un
.structure
.members
= dt2
->un
.structure
.members
;
591 dt
->un
.enumeration
.members
= dt2
->un
.enumeration
.members
;
598 DEBUG_AddStructElement(struct datatype
* dt
, char * name
, struct datatype
* type
,
599 int offset
, int size
)
602 struct member
* last
;
603 struct en_values
* e
;
605 if( dt
->type
== DT_STRUCT
)
607 for(last
= dt
->un
.structure
.members
; last
; last
= last
->next
)
609 if( (last
->name
[0] == name
[0])
610 && (strcmp(last
->name
, name
) == 0) )
614 if( last
->next
== NULL
)
619 m
= (struct member
*) DBG_alloc(sizeof(struct member
));
625 m
->name
= DBG_strdup(name
);
631 m
->next
= dt
->un
.structure
.members
;
632 dt
->un
.structure
.members
= m
;
640 * If the base type is bitfield, then adjust the offsets here so that we
641 * are able to look things up without lots of falter-all.
643 if( type
&& type
->type
== DT_BITFIELD
)
645 m
->offset
+= m
->type
->un
.bitfield
.bitoff
;
646 m
->size
= m
->type
->un
.bitfield
.nbits
;
647 m
->type
= m
->type
->un
.bitfield
.basetype
;
650 else if( dt
->type
== DT_ENUM
)
652 e
= (struct en_values
*) DBG_alloc(sizeof(struct en_values
));
658 e
->name
= DBG_strdup(name
);
660 e
->next
= dt
->un
.enumeration
.members
;
661 dt
->un
.enumeration
.members
= e
;
671 DEBUG_GetPointerType(struct datatype
* dt
)
673 if( dt
->type
== DT_POINTER
)
675 return dt
->un
.pointer
.pointsto
;
682 DEBUG_SetPointerType(struct datatype
* dt
, struct datatype
* dt2
)
687 dt
->un
.pointer
.pointsto
= dt2
;
690 dt
->un
.funct
.rettype
= dt2
;
700 DEBUG_SetArrayParams(struct datatype
* dt
, int min
, int max
, struct datatype
* dt2
)
702 assert(dt
->type
== DT_ARRAY
);
703 dt
->un
.array
.start
= min
;
704 dt
->un
.array
.end
= max
;
705 dt
->un
.array
.basictype
= dt2
;
711 DEBUG_SetBitfieldParams(struct datatype
* dt
, int offset
, int nbits
,
712 struct datatype
* dt2
)
714 assert(dt
->type
== DT_BITFIELD
);
715 dt
->un
.bitfield
.bitoff
= offset
;
716 dt
->un
.bitfield
.nbits
= nbits
;
717 dt
->un
.bitfield
.basetype
= dt2
;
722 int DEBUG_GetObjectSize(struct datatype
* dt
)
732 return dt
->un
.basic
.basic_size
;
734 return sizeof(int *);
736 return dt
->un
.structure
.size
;
740 return (dt
->un
.array
.end
- dt
->un
.array
.start
)
741 * DEBUG_GetObjectSize(dt
->un
.array
.basictype
);
744 * Bitfields have to be handled separately later on
745 * when we insert the element into the structure.
751 DEBUG_Printf(DBG_CHN_ERR
, "Unknown type???\n");
758 DEBUG_ArrayIndex(const DBG_VALUE
* value
, DBG_VALUE
* result
, int index
)
762 assert(value
->cookie
== DV_TARGET
|| value
->cookie
== DV_HOST
);
765 * Make sure that this really makes sense.
767 if( value
->type
->type
== DT_POINTER
)
770 * Get the base type, so we know how much to index by.
772 size
= DEBUG_GetObjectSize(value
->type
->un
.pointer
.pointsto
);
773 result
->type
= value
->type
->un
.pointer
.pointsto
;
774 result
->addr
.off
= (DWORD
)DEBUG_ReadMemory(value
) + size
*index
;
776 /* Contents of array must be on same target */
777 result
->cookie
= value
->cookie
;
779 else if (value
->type
->type
== DT_ARRAY
)
781 size
= DEBUG_GetObjectSize(value
->type
->un
.array
.basictype
);
782 result
->type
= value
->type
->un
.array
.basictype
;
783 result
->addr
.off
= value
->addr
.off
+ size
* (index
- value
->type
->un
.array
.start
);
785 /* Contents of array must be on same target */
786 result
->cookie
= value
->cookie
;
796 /***********************************************************************
799 * Implementation of the 'print' command.
802 DEBUG_Print( const DBG_VALUE
*value
, int count
, char format
, int level
)
811 assert(value
->cookie
== DV_TARGET
|| value
->cookie
== DV_HOST
);
815 DEBUG_Printf( DBG_CHN_MESG
, "Count other than 1 is meaningless in 'print' command\n" );
819 if( value
->type
== NULL
)
821 /* No type, just print the addr value */
822 if (value
->addr
.seg
&& (value
->addr
.seg
!= 0xffffffff))
823 DEBUG_nchar
+= DEBUG_Printf( DBG_CHN_MESG
, "0x%04lx: ", value
->addr
.seg
);
824 DEBUG_nchar
+= DEBUG_Printf( DBG_CHN_MESG
, "0x%08lx", value
->addr
.off
);
833 if( DEBUG_nchar
> DEBUG_maxchar
)
835 DEBUG_Printf(DBG_CHN_MESG
, "...");
839 if( format
== 'i' || format
== 's' || format
== 'w' || format
== 'b' || format
== 'g')
841 DEBUG_Printf( DBG_CHN_MESG
, "Format specifier '%c' is meaningless in 'print' command\n", format
);
845 switch(value
->type
->type
)
850 DEBUG_PrintBasic(value
, 1, format
);
853 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, "{");
854 for(m
= value
->type
->un
.structure
.members
; m
; m
= m
->next
)
857 DEBUG_FindStructElement(&val1
, m
->name
, &xval
);
858 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, "%s=", m
->name
);
859 DEBUG_Print(&val1
, 1, format
, level
+ 1);
860 if( m
->next
!= NULL
)
862 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, ", ");
864 if( DEBUG_nchar
> DEBUG_maxchar
)
866 DEBUG_Printf(DBG_CHN_MESG
, "...}");
870 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, "}");
874 * Loop over all of the entries, printing stuff as we go.
876 size
= DEBUG_GetObjectSize(value
->type
->un
.array
.basictype
);
882 * Special handling for character arrays.
884 pnt
= (char *) value
->addr
.off
;
885 len
= value
->type
->un
.array
.end
- value
->type
->un
.array
.start
+ 1;
886 clen
= (DEBUG_nchar
+ len
< DEBUG_maxchar
)
887 ? len
: (DEBUG_maxchar
- DEBUG_nchar
);
889 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, "\"");
890 switch (value
->cookie
)
893 DEBUG_nchar
+= DEBUG_PrintStringA(DBG_CHN_MESG
, &value
->addr
, clen
);
896 DEBUG_OutputA(DBG_CHN_MESG
, pnt
, clen
);
900 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, (len
> clen
) ? "...\"" : "\"");
904 val1
.type
= value
->type
->un
.array
.basictype
;
905 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, "{");
906 for( i
=value
->type
->un
.array
.start
; i
<= value
->type
->un
.array
.end
; i
++ )
908 DEBUG_Print(&val1
, 1, format
, level
+ 1);
909 val1
.addr
.off
+= size
;
910 if( i
== value
->type
->un
.array
.end
)
912 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, "}");
916 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, ", ");
918 if( DEBUG_nchar
> DEBUG_maxchar
)
920 DEBUG_Printf(DBG_CHN_MESG
, "...}");
926 DEBUG_Printf(DBG_CHN_MESG
, "Function at ???\n");
929 DEBUG_Printf(DBG_CHN_MESG
, "Unknown type (%d)\n", value
->type
->type
);
938 DEBUG_nchar
+= DEBUG_Printf(DBG_CHN_MESG
, "\n");
942 static void DEBUG_DumpAType(struct datatype
* dt
, BOOL deep
)
944 char* name
= (dt
->name
) ? dt
->name
: "--none--";
946 /* EPP DEBUG_Printf(DBG_CHN_MESG, "0x%08lx ", (unsigned long)dt); */
950 DEBUG_Printf(DBG_CHN_MESG
, "BASIC(%s)", name
);
953 DEBUG_Printf(DBG_CHN_MESG
, "POINTER(%s)<", name
);
954 DEBUG_DumpAType(dt
->un
.pointer
.pointsto
, FALSE
);
955 DEBUG_Printf(DBG_CHN_MESG
, ">");
958 DEBUG_Printf(DBG_CHN_MESG
, "STRUCT(%s) %d {",
959 name
, dt
->un
.structure
.size
);
960 if (dt
->un
.structure
.members
!= NULL
)
963 for (m
= dt
->un
.structure
.members
; m
; m
= m
->next
)
965 DEBUG_Printf(DBG_CHN_MESG
, " %s(%d",
966 m
->name
, m
->offset
/ 8);
967 if (m
->offset
% 8 != 0)
968 DEBUG_Printf(DBG_CHN_MESG
, ".%d", m
->offset
/ 8);
969 DEBUG_Printf(DBG_CHN_MESG
, "/%d", m
->size
/ 8);
970 if (m
->size
% 8 != 0)
971 DEBUG_Printf(DBG_CHN_MESG
, ".%d", m
->size
% 8);
972 DEBUG_Printf(DBG_CHN_MESG
, ")");
975 DEBUG_Printf(DBG_CHN_MESG
, " }");
978 DEBUG_Printf(DBG_CHN_MESG
, "ARRAY(%s)[", name
);
979 DEBUG_DumpAType(dt
->un
.array
.basictype
, FALSE
);
980 DEBUG_Printf(DBG_CHN_MESG
, "]");
983 DEBUG_Printf(DBG_CHN_MESG
, "ENUM(%s)", name
);
986 DEBUG_Printf(DBG_CHN_MESG
, "BITFIELD(%s)", name
);
989 DEBUG_Printf(DBG_CHN_MESG
, "FUNC(%s)(", name
);
990 DEBUG_DumpAType(dt
->un
.funct
.rettype
, FALSE
);
991 DEBUG_Printf(DBG_CHN_MESG
, ")");
994 DEBUG_Printf(DBG_CHN_ERR
, "Unknown type???");
997 if (deep
) DEBUG_Printf(DBG_CHN_MESG
, "\n");
1000 int DEBUG_DumpTypes(void)
1002 struct datatype
* dt
= NULL
;
1005 for (hash
= 0; hash
< NR_TYPE_HASH
+ 1; hash
++)
1007 for (dt
= type_hash_table
[hash
]; dt
; dt
= dt
->next
)
1009 DEBUG_DumpAType(dt
, TRUE
);
1015 enum debug_type
DEBUG_GetType(struct datatype
* dt
)
1020 const char* DEBUG_GetName(struct datatype
* dt
)
1026 DEBUG_TypeCast(enum debug_type type
, const char * name
)
1031 * The last bucket is special, and is used to hold typeless names.
1035 hash
= NR_TYPE_HASH
;
1039 hash
= type_hash(name
);
1042 return DEBUG_LookupDataType(type
, hash
, name
);
1046 DEBUG_PrintTypeCast(const struct datatype
* dt
)
1048 const char* name
= "none";
1052 DEBUG_Printf(DBG_CHN_MESG
, "--invalid--");
1056 if( dt
->name
!= NULL
)
1064 DEBUG_Printf(DBG_CHN_MESG
, "%s", name
);
1067 DEBUG_PrintTypeCast(dt
->un
.pointer
.pointsto
);
1068 DEBUG_Printf(DBG_CHN_MESG
, "*");
1071 DEBUG_Printf(DBG_CHN_MESG
, "struct %s", name
);
1074 DEBUG_Printf(DBG_CHN_MESG
, "%s[]", name
);
1077 DEBUG_Printf(DBG_CHN_MESG
, "enum %s", name
);
1080 DEBUG_Printf(DBG_CHN_MESG
, "unsigned %s", name
);
1083 DEBUG_PrintTypeCast(dt
->un
.funct
.rettype
);
1084 DEBUG_Printf(DBG_CHN_MESG
, "(*%s)()", name
);
1087 DEBUG_Printf(DBG_CHN_ERR
, "Unknown type???\n");
1094 int DEBUG_PrintType( const DBG_VALUE
*value
)
1096 assert(value
->cookie
== DV_TARGET
|| value
->cookie
== DV_HOST
);
1100 DEBUG_Printf(DBG_CHN_MESG
, "Unknown type\n");
1103 if (!DEBUG_PrintTypeCast(value
->type
))
1105 DEBUG_Printf(DBG_CHN_MESG
, "\n");