]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Handle T_HRESULT types in CodeView records
authorMark Harmstone <mark@harmstone.com>
Sat, 2 Nov 2024 15:31:12 +0000 (15:31 +0000)
committerMark Harmstone <mark@harmstone.com>
Tue, 5 Nov 2024 00:47:41 +0000 (00:47 +0000)
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.

gcc/dwarf2codeview.cc
gcc/dwarf2codeview.h

index 876057b5a8c2aa917dceed3c436719f4a1b6de74..5e8a4ab39e7dc0f640666f1518a3d993bc31de4d 100644 (file)
@@ -6220,6 +6220,29 @@ get_type_num_ptr_to_member_type (dw_die_ref type, bool in_struct)
   return ct->num;
 }
 
+/* Return the type number that corresponds to a DW_TAG_typedef DIE: either the
+   type number of the base type, or follow MSVC in having a special value
+   for the HRESULT used by COM.  */
+
+static uint32_t
+get_type_num_typedef (dw_die_ref type, bool in_struct)
+{
+  uint32_t num;
+
+  num = get_type_num (get_AT_ref (type, DW_AT_type), in_struct, false);
+
+  if (num == T_LONG)
+    {
+      const char *name = get_AT_string (type, DW_AT_name);
+
+      /* longs typedef'd as "HRESULT" get their own type */
+      if (name && !strcmp (name, "HRESULT"))
+       num = T_HRESULT;
+    }
+
+  return num;
+}
+
 /* Process a DIE representing a type definition, add a CodeView type if
    necessary, and return its number.  If it's something we can't handle, return
    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)
       break;
 
     case DW_TAG_typedef:
-      /* FIXME - signed longs typedef'd as "HRESULT" should get their
-                own type (T_HRESULT) */
-      num = get_type_num (get_AT_ref (type, DW_AT_type), in_struct, false);
+      num = get_type_num_typedef (type, in_struct);
       break;
 
     case DW_TAG_pointer_type:
index c895ef3e04c9982a13a582e24dce9606cdfb8b01..52ffc6cfb99b37940ebab9696306fa7a1a9f6afd 100644 (file)
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Constants for in-built types.  */
 
 #define T_VOID                 0x0003
+#define T_HRESULT              0x0008
 #define T_CHAR                 0x0010
 #define T_SHORT                        0x0011
 #define T_LONG                 0x0012