@@ -286,6 +286,114 @@ TEST_F(DWARFASTParserClangTests, TestCallingConventionParsing) {
286286 ASSERT_EQ (found_function_types, expected_function_types);
287287}
288288
289+ TEST_F (DWARFASTParserClangTests, TestPtrAuthParsing) {
290+ // Tests parsing values with type DW_TAG_LLVM_ptrauth_type
291+
292+ const char *yamldata = R"(
293+ --- !ELF
294+ FileHeader:
295+ Class: ELFCLASS64
296+ Data: ELFDATA2LSB
297+ Type: ET_EXEC
298+ Machine: EM_AARCH64
299+ DWARF:
300+ debug_str:
301+ - a
302+ debug_abbrev:
303+ - ID: 0
304+ Table:
305+ - Code: 0x1
306+ Tag: DW_TAG_compile_unit
307+ Children: DW_CHILDREN_yes
308+ Attributes:
309+ - Attribute: DW_AT_language
310+ Form: DW_FORM_data2
311+ - Code: 0x2
312+ Tag: DW_TAG_variable
313+ Children: DW_CHILDREN_no
314+ Attributes:
315+ - Attribute: DW_AT_name
316+ Form: DW_FORM_strx1
317+ - Attribute: DW_AT_type
318+ Form: DW_FORM_ref4
319+ - Attribute: DW_AT_external
320+ Form: DW_FORM_flag_present
321+ - Code: 0x3
322+ Tag: DW_TAG_LLVM_ptrauth_type
323+ Children: DW_CHILDREN_no
324+ Attributes:
325+ - Attribute: DW_AT_type
326+ Form: DW_FORM_ref4
327+ - Attribute: DW_AT_LLVM_ptrauth_key
328+ Form: DW_FORM_data1
329+ - Attribute: DW_AT_LLVM_ptrauth_extra_discriminator
330+ Form: DW_FORM_data2
331+ - Code: 0x4
332+ Tag: DW_TAG_pointer_type
333+ Children: DW_CHILDREN_no
334+ Attributes:
335+ - Attribute: DW_AT_type
336+ Form: DW_FORM_ref4
337+ - Code: 0x5
338+ Tag: DW_TAG_subroutine_type
339+ Children: DW_CHILDREN_yes
340+ - Code: 0x6
341+ Tag: DW_TAG_unspecified_parameters
342+ Children: DW_CHILDREN_no
343+
344+ debug_info:
345+ - Version: 5
346+ UnitType: DW_UT_compile
347+ AddrSize: 8
348+ Entries:
349+ - AbbrCode: 0x1
350+ Values:
351+ - Value: 0xC
352+ - AbbrCode: 0x2
353+ Values:
354+ - Value: 0x00
355+ - Value: 0x15
356+ - AbbrCode: 0x3
357+ Values:
358+ - Value: 0x1D
359+ - Value: 0x00
360+ - Value: 0x2A
361+ - AbbrCode: 0x4
362+ Values:
363+ - Value: 0x22
364+ - AbbrCode: 0x5
365+ - AbbrCode: 0x6
366+ - AbbrCode: 0x0
367+ - AbbrCode: 0x0
368+ ...
369+ )" ;
370+ YAMLModuleTester t (yamldata);
371+
372+ DWARFUnit *unit = t.GetDwarfUnit ();
373+ ASSERT_NE (unit, nullptr );
374+ const DWARFDebugInfoEntry *cu_entry = unit->DIE ().GetDIE ();
375+ ASSERT_EQ (cu_entry->Tag (), DW_TAG_compile_unit);
376+ DWARFDIE cu_die (unit, cu_entry);
377+
378+ auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>(" ast" );
379+ auto &ast_ctx = *holder->GetAST ();
380+ DWARFASTParserClangStub ast_parser (ast_ctx);
381+
382+ DWARFDIE ptrauth_variable = cu_die.GetFirstChild ();
383+ ASSERT_EQ (ptrauth_variable.Tag (), DW_TAG_variable);
384+ DWARFDIE ptrauth_type =
385+ ptrauth_variable.GetAttributeValueAsReferenceDIE (DW_AT_type);
386+ ASSERT_EQ (ptrauth_type.Tag (), DW_TAG_LLVM_ptrauth_type);
387+
388+ SymbolContext sc;
389+ bool new_type = false ;
390+ lldb::TypeSP type =
391+ ast_parser.ParseTypeFromDWARF (sc, ptrauth_type, &new_type);
392+ std::string type_as_string =
393+ type->GetForwardCompilerType ().GetTypeName ().AsCString ();
394+ ASSERT_EQ (type_as_string, " void (*__ptrauth(0,0,42))(...)" );
395+ }
396+
289397struct ExtractIntFromFormValueTest : public testing ::Test {
290398 SubsystemRAII<FileSystem, HostInfo> subsystems;
291399 clang_utils::TypeSystemClangHolder holder;
0 commit comments