Skip to content

Commit 6177b45

Browse files
committed
Handle T_HRESULT types in CodeView records
Follow MSVC in having a special type value, T_HRESULT, for (signed) longs that have been typedef'd with the name "HRESULT". This is so that the debugger can display user-friendly constant names when debugging COM code. gcc/ * dwarf2codeview.cc (get_type_num_typedef): New function. (get_type_num): Call get_type_num_typedef. * dwarf2codeview.h (T_HRESULT): Define.
1 parent b0f4f55 commit 6177b45

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

gcc/dwarf2codeview.cc

+24-3
Original file line numberDiff line numberDiff line change
@@ -6220,6 +6220,29 @@ get_type_num_ptr_to_member_type (dw_die_ref type, bool in_struct)
62206220
return ct->num;
62216221
}
62226222

6223+
/* Return the type number that corresponds to a DW_TAG_typedef DIE: either the
6224+
type number of the base type, or follow MSVC in having a special value
6225+
for the HRESULT used by COM. */
6226+
6227+
static uint32_t
6228+
get_type_num_typedef (dw_die_ref type, bool in_struct)
6229+
{
6230+
uint32_t num;
6231+
6232+
num = get_type_num (get_AT_ref (type, DW_AT_type), in_struct, false);
6233+
6234+
if (num == T_LONG)
6235+
{
6236+
const char *name = get_AT_string (type, DW_AT_name);
6237+
6238+
/* longs typedef'd as "HRESULT" get their own type */
6239+
if (name && !strcmp (name, "HRESULT"))
6240+
num = T_HRESULT;
6241+
}
6242+
6243+
return num;
6244+
}
6245+
62236246
/* Process a DIE representing a type definition, add a CodeView type if
62246247
necessary, and return its number. If it's something we can't handle, return
62256248
0. We keep a hash table so that we're not adding the same type multiple
@@ -6254,9 +6277,7 @@ get_type_num (dw_die_ref type, bool in_struct, bool no_fwd_ref)
62546277
break;
62556278

62566279
case DW_TAG_typedef:
6257-
/* FIXME - signed longs typedef'd as "HRESULT" should get their
6258-
own type (T_HRESULT) */
6259-
num = get_type_num (get_AT_ref (type, DW_AT_type), in_struct, false);
6280+
num = get_type_num_typedef (type, in_struct);
62606281
break;
62616282

62626283
case DW_TAG_pointer_type:

gcc/dwarf2codeview.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
2626
/* Constants for in-built types. */
2727

2828
#define T_VOID 0x0003
29+
#define T_HRESULT 0x0008
2930
#define T_CHAR 0x0010
3031
#define T_SHORT 0x0011
3132
#define T_LONG 0x0012

0 commit comments

Comments
 (0)