[llvm] Give a warning when no dwo files are found (PR #94336)

Jinjie Huang via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 9 07:39:34 PDT 2024


https://github.com/Labman-001 updated https://github.com/llvm/llvm-project/pull/94336

>From 673778784c089d0146b293bd5c6c7331d736fb25 Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Tue, 4 Jun 2024 18:31:03 +0800
Subject: [PATCH 1/7] Give a warning when now dwo found

---
 llvm/tools/llvm-dwp/llvm-dwp.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index 81556b3ad4bcb..f0edaeb07f0ba 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -188,8 +188,10 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
                         std::make_move_iterator(DWOs->end()));
   }
 
-  if (DWOFilenames.empty())
+  if (DWOFilenames.empty()) {
+    WithColor::defaultWarningHandler(make_error<DWPError>("No dwo files found!\n"));
     return 0;
+  }
 
   std::string ErrorStr;
   StringRef Context = "dwarf streamer init";

>From 5899de9fb576489e9bdb30adee6a535a98942ace Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Tue, 4 Jun 2024 19:00:32 +0800
Subject: [PATCH 2/7] Give a warning when no dwo found

---
 llvm/tools/llvm-dwp/llvm-dwp.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index f0edaeb07f0ba..0b3941bdc27e0 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -189,8 +189,9 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
   }
 
   if (DWOFilenames.empty()) {
-    WithColor::defaultWarningHandler(make_error<DWPError>("No dwo files found!\n"));
-    return 0;
+    WithColor::defaultWarningHandler(
+        make_error<DWPError>("No dwo files found!"));
+      return 0;
   }
 
   std::string ErrorStr;

>From 2a54154e77f27ccd99978fce7b9f790702cd933b Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Tue, 4 Jun 2024 19:05:25 +0800
Subject: [PATCH 3/7] Give a warning when no dwo found

---
 llvm/tools/llvm-dwp/llvm-dwp.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index 0b3941bdc27e0..3da408b7e8e8c 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -191,7 +191,7 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
   if (DWOFilenames.empty()) {
     WithColor::defaultWarningHandler(
         make_error<DWPError>("No dwo files found!"));
-      return 0;
+    return 0;
   }
 
   std::string ErrorStr;

>From cca758091d00d31db172eb32ba6f573f1a049052 Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Fri, 7 Jun 2024 17:21:48 +0800
Subject: [PATCH 4/7] add test

---
 .../llvm-dwp/Inputs/empty_warning/non_split.s | 218 +++++++++++++
 .../llvm-dwp/Inputs/empty_warning/split.s     | 297 ++++++++++++++++++
 .../tools/llvm-dwp/X86/empty_warning.test     |   6 +
 llvm/tools/llvm-dwp/llvm-dwp.cpp              |   2 +-
 4 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/tools/llvm-dwp/Inputs/empty_warning/non_split.s
 create mode 100644 llvm/test/tools/llvm-dwp/Inputs/empty_warning/split.s
 create mode 100644 llvm/test/tools/llvm-dwp/X86/empty_warning.test

diff --git a/llvm/test/tools/llvm-dwp/Inputs/empty_warning/non_split.s b/llvm/test/tools/llvm-dwp/Inputs/empty_warning/non_split.s
new file mode 100644
index 0000000000000..478db2b7e82cc
--- /dev/null
+++ b/llvm/test/tools/llvm-dwp/Inputs/empty_warning/non_split.s
@@ -0,0 +1,218 @@
+# Note: This file is compiled from the following code, for 
+# 		the purpose of creating an non split-dwarf binary.
+# 
+# clang -g -S -gdwarf-4 main.c
+#
+#include <stdio.h>
+#int main() {
+#    printf("hello\n");
+#    return 0;
+#}
+
+	.text
+	.file	"main.c"
+	.file	1 "/xxx/xxx" "main.c"
+	.globl	main                            # -- Begin function main
+	.p2align	4, 0x90
+	.type	main, at function
+main:                                   # @main
+.Lfunc_begin0:
+	.loc	1 3 0                           # main.c:3:0
+	.cfi_startproc
+# %bb.0:                                # %entry
+	pushq	%rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq	%rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	subq	$16, %rsp
+	movl	$0, -4(%rbp)
+.Ltmp0:
+	.loc	1 4 5 prologue_end              # main.c:4:5
+	leaq	.L.str(%rip), %rdi
+	movb	$0, %al
+	callq	printf at PLT
+	.loc	1 5 5                           # main.c:5:5
+	xorl	%eax, %eax
+	.loc	1 5 5 epilogue_begin is_stmt 0  # main.c:5:5
+	addq	$16, %rsp
+	popq	%rbp
+	.cfi_def_cfa %rsp, 8
+	retq
+.Ltmp1:
+.Lfunc_end0:
+	.size	main, .Lfunc_end0-main
+	.cfi_endproc
+                                        # -- End function
+	.type	.L.str, at object                  # @.str
+	.section	.rodata.str1.1,"aMS", at progbits,1
+.L.str:
+	.asciz	"hello\n"
+	.size	.L.str, 7
+
+	.section	.debug_abbrev,"", at progbits
+	.byte	1                               # Abbreviation Code
+	.byte	17                              # DW_TAG_compile_unit
+	.byte	1                               # DW_CHILDREN_yes
+	.byte	37                              # DW_AT_producer
+	.byte	14                              # DW_FORM_strp
+	.byte	19                              # DW_AT_language
+	.byte	5                               # DW_FORM_data2
+	.byte	3                               # DW_AT_name
+	.byte	14                              # DW_FORM_strp
+	.byte	16                              # DW_AT_stmt_list
+	.byte	23                              # DW_FORM_sec_offset
+	.byte	27                              # DW_AT_comp_dir
+	.byte	14                              # DW_FORM_strp
+	.byte	17                              # DW_AT_low_pc
+	.byte	1                               # DW_FORM_addr
+	.byte	18                              # DW_AT_high_pc
+	.byte	6                               # DW_FORM_data4
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	2                               # Abbreviation Code
+	.byte	52                              # DW_TAG_variable
+	.byte	0                               # DW_CHILDREN_no
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	58                              # DW_AT_decl_file
+	.byte	11                              # DW_FORM_data1
+	.byte	59                              # DW_AT_decl_line
+	.byte	11                              # DW_FORM_data1
+	.byte	2                               # DW_AT_location
+	.byte	24                              # DW_FORM_exprloc
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	3                               # Abbreviation Code
+	.byte	1                               # DW_TAG_array_type
+	.byte	1                               # DW_CHILDREN_yes
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	4                               # Abbreviation Code
+	.byte	33                              # DW_TAG_subrange_type
+	.byte	0                               # DW_CHILDREN_no
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	55                              # DW_AT_count
+	.byte	11                              # DW_FORM_data1
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	5                               # Abbreviation Code
+	.byte	36                              # DW_TAG_base_type
+	.byte	0                               # DW_CHILDREN_no
+	.byte	3                               # DW_AT_name
+	.byte	14                              # DW_FORM_strp
+	.byte	62                              # DW_AT_encoding
+	.byte	11                              # DW_FORM_data1
+	.byte	11                              # DW_AT_byte_size
+	.byte	11                              # DW_FORM_data1
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	6                               # Abbreviation Code
+	.byte	36                              # DW_TAG_base_type
+	.byte	0                               # DW_CHILDREN_no
+	.byte	3                               # DW_AT_name
+	.byte	14                              # DW_FORM_strp
+	.byte	11                              # DW_AT_byte_size
+	.byte	11                              # DW_FORM_data1
+	.byte	62                              # DW_AT_encoding
+	.byte	11                              # DW_FORM_data1
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	7                               # Abbreviation Code
+	.byte	46                              # DW_TAG_subprogram
+	.byte	0                               # DW_CHILDREN_no
+	.byte	17                              # DW_AT_low_pc
+	.byte	1                               # DW_FORM_addr
+	.byte	18                              # DW_AT_high_pc
+	.byte	6                               # DW_FORM_data4
+	.byte	64                              # DW_AT_frame_base
+	.byte	24                              # DW_FORM_exprloc
+	.byte	3                               # DW_AT_name
+	.byte	14                              # DW_FORM_strp
+	.byte	58                              # DW_AT_decl_file
+	.byte	11                              # DW_FORM_data1
+	.byte	59                              # DW_AT_decl_line
+	.byte	11                              # DW_FORM_data1
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	63                              # DW_AT_external
+	.byte	25                              # DW_FORM_flag_present
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	0                               # EOM(3)
+	.section	.debug_info,"", at progbits
+.Lcu_begin0:
+	.long	.Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+	.short	4                               # DWARF version number
+	.long	.debug_abbrev                   # Offset Into Abbrev. Section
+	.byte	8                               # Address Size (in bytes)
+	.byte	1                               # Abbrev [1] 0xb:0x6b DW_TAG_compile_unit
+	.long	.Linfo_string0                  # DW_AT_producer
+	.short	29                              # DW_AT_language
+	.long	.Linfo_string1                  # DW_AT_name
+	.long	.Lline_table_start0             # DW_AT_stmt_list
+	.long	.Linfo_string2                  # DW_AT_comp_dir
+	.quad	.Lfunc_begin0                   # DW_AT_low_pc
+	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+	.byte	2                               # Abbrev [2] 0x2a:0x11 DW_TAG_variable
+	.long	59                              # DW_AT_type
+	.byte	1                               # DW_AT_decl_file
+	.byte	4                               # DW_AT_decl_line
+	.byte	9                               # DW_AT_location
+	.byte	3
+	.quad	.L.str
+	.byte	3                               # Abbrev [3] 0x3b:0xc DW_TAG_array_type
+	.long	71                              # DW_AT_type
+	.byte	4                               # Abbrev [4] 0x40:0x6 DW_TAG_subrange_type
+	.long	78                              # DW_AT_type
+	.byte	7                               # DW_AT_count
+	.byte	0                               # End Of Children Mark
+	.byte	5                               # Abbrev [5] 0x47:0x7 DW_TAG_base_type
+	.long	.Linfo_string3                  # DW_AT_name
+	.byte	6                               # DW_AT_encoding
+	.byte	1                               # DW_AT_byte_size
+	.byte	6                               # Abbrev [6] 0x4e:0x7 DW_TAG_base_type
+	.long	.Linfo_string4                  # DW_AT_name
+	.byte	8                               # DW_AT_byte_size
+	.byte	7                               # DW_AT_encoding
+	.byte	7                               # Abbrev [7] 0x55:0x19 DW_TAG_subprogram
+	.quad	.Lfunc_begin0                   # DW_AT_low_pc
+	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+	.byte	1                               # DW_AT_frame_base
+	.byte	86
+	.long	.Linfo_string5                  # DW_AT_name
+	.byte	1                               # DW_AT_decl_file
+	.byte	3                               # DW_AT_decl_line
+	.long	110                             # DW_AT_type
+                                        # DW_AT_external
+	.byte	5                               # Abbrev [5] 0x6e:0x7 DW_TAG_base_type
+	.long	.Linfo_string6                  # DW_AT_name
+	.byte	5                               # DW_AT_encoding
+	.byte	4                               # DW_AT_byte_size
+	.byte	0                               # End Of Children Mark
+.Ldebug_info_end0:
+	.section	.debug_str,"MS", at progbits,1
+.Linfo_string0:
+	.asciz	"clang version 19.0.0git"       # string offset=0
+.Linfo_string1:
+	.asciz	"main.c"                        # string offset=24
+.Linfo_string2:
+	.asciz	"xxx/xxx" # string offset=31
+.Linfo_string3:
+	.asciz	"char"                          # string offset=95
+.Linfo_string4:
+	.asciz	"__ARRAY_SIZE_TYPE__"           # string offset=100
+.Linfo_string5:
+	.asciz	"main"                          # string offset=120
+.Linfo_string6:
+	.asciz	"int"                           # string offset=125
+	.ident	"clang version 19.0.0git"
+	.section	".note.GNU-stack","", at progbits
+	.addrsig
+	.addrsig_sym printf
+	.section	.debug_line,"", at progbits
+.Lline_table_start0:
diff --git a/llvm/test/tools/llvm-dwp/Inputs/empty_warning/split.s b/llvm/test/tools/llvm-dwp/Inputs/empty_warning/split.s
new file mode 100644
index 0000000000000..50ed62f26727a
--- /dev/null
+++ b/llvm/test/tools/llvm-dwp/Inputs/empty_warning/split.s
@@ -0,0 +1,297 @@
+# Note: This file is compiled from the following code, for 
+# 		the purpose of creating a valid split-dwarf binary,
+#       where the dwo path is modified to a non-existent path.
+# 
+# clang -g -S -gsplit-dwarf -gdwarf-4 main.c
+#
+#include <stdio.h>
+#int main() {
+#    printf("hello\n");
+#    return 0;
+#}
+
+	.text
+	.file	"main.c"
+	.file	1 "/xxx/xxx" "main.c"
+	.globl	main                            # -- Begin function main
+	.p2align	4, 0x90
+	.type	main, at function
+main:                                   # @main
+.Lfunc_begin0:
+	.loc	1 3 0                           # main.c:3:0
+	.cfi_startproc
+# %bb.0:                                # %entry
+	pushq	%rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq	%rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	subq	$16, %rsp
+	movl	$0, -4(%rbp)
+.Ltmp0:
+	.loc	1 4 5 prologue_end              # main.c:4:5
+	leaq	.L.str(%rip), %rdi
+	movb	$0, %al
+	callq	printf at PLT
+	.loc	1 5 5                           # main.c:5:5
+	xorl	%eax, %eax
+	.loc	1 5 5 epilogue_begin is_stmt 0  # main.c:5:5
+	addq	$16, %rsp
+	popq	%rbp
+	.cfi_def_cfa %rsp, 8
+	retq
+.Ltmp1:
+.Lfunc_end0:
+	.size	main, .Lfunc_end0-main
+	.cfi_endproc
+                                        # -- End function
+	.type	.L.str, at object                  # @.str
+	.section	.rodata.str1.1,"aMS", at progbits,1
+.L.str:
+	.asciz	"hello\n"
+	.size	.L.str, 7
+
+	.section	.debug_abbrev,"", at progbits
+	.byte	1                               # Abbreviation Code
+	.byte	17                              # DW_TAG_compile_unit
+	.byte	0                               # DW_CHILDREN_no
+	.byte	16                              # DW_AT_stmt_list
+	.byte	23                              # DW_FORM_sec_offset
+	.byte	27                              # DW_AT_comp_dir
+	.byte	14                              # DW_FORM_strp
+	.ascii	"\264B"                         # DW_AT_GNU_pubnames
+	.byte	25                              # DW_FORM_flag_present
+	.ascii	"\260B"                         # DW_AT_GNU_dwo_name
+	.byte	14                              # DW_FORM_strp
+	.ascii	"\261B"                         # DW_AT_GNU_dwo_id
+	.byte	7                               # DW_FORM_data8
+	.byte	17                              # DW_AT_low_pc
+	.byte	1                               # DW_FORM_addr
+	.byte	18                              # DW_AT_high_pc
+	.byte	6                               # DW_FORM_data4
+	.ascii	"\263B"                         # DW_AT_GNU_addr_base
+	.byte	23                              # DW_FORM_sec_offset
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	0                               # EOM(3)
+	.section	.debug_info,"", at progbits
+.Lcu_begin0:
+	.long	.Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+	.short	4                               # DWARF version number
+	.long	.debug_abbrev                   # Offset Into Abbrev. Section
+	.byte	8                               # Address Size (in bytes)
+	.byte	1                               # Abbrev [1] 0xb:0x25 DW_TAG_compile_unit
+	.long	.Lline_table_start0             # DW_AT_stmt_list
+	.long	.Lskel_string0                  # DW_AT_comp_dir
+                                        # DW_AT_GNU_pubnames
+	.long	.Lskel_string1                  # DW_AT_GNU_dwo_name
+	.quad	-6752972150003664062            # DW_AT_GNU_dwo_id
+	.quad	.Lfunc_begin0                   # DW_AT_low_pc
+	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+	.long	.Laddr_table_base0              # DW_AT_GNU_addr_base
+.Ldebug_info_end0:
+	.section	.debug_str,"MS", at progbits,1
+.Lskel_string0:
+	.asciz	"xxx/xxx" # string offset=0
+.Lskel_string1:
+	.asciz	"main.dwo"                      # string offset=64
+	.section	.debug_str.dwo,"eMS", at progbits,1
+.Linfo_string0:
+	.asciz	"char"                          # string offset=0
+.Linfo_string1:
+	.asciz	"__ARRAY_SIZE_TYPE__"           # string offset=5
+.Linfo_string2:
+	.asciz	"main"                          # string offset=25
+.Linfo_string3:
+	.asciz	"int"                           # string offset=30
+.Linfo_string4:
+	.asciz	"clang version 19.0.0git"       # string offset=34
+.Linfo_string5:
+	.asciz	"main.c"                        # string offset=58
+.Linfo_string6:
+	.asciz	"main.dwo"                      # string offset=65
+	.section	.debug_str_offsets.dwo,"e", at progbits
+	.long	0
+	.long	5
+	.long	25
+	.long	30
+	.long	34
+	.long	58
+	.long	65
+	.section	.debug_info.dwo,"e", at progbits
+	.long	.Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit
+.Ldebug_info_dwo_start0:
+	.short	4                               # DWARF version number
+	.long	0                               # Offset Into Abbrev. Section
+	.byte	8                               # Address Size (in bytes)
+	.byte	1                               # Abbrev [1] 0xb:0x40 DW_TAG_compile_unit
+	.byte	4                               # DW_AT_producer
+	.short	29                              # DW_AT_language
+	.byte	5                               # DW_AT_name
+	.byte	6                               # DW_AT_GNU_dwo_name
+	.quad	-6752972150003664062            # DW_AT_GNU_dwo_id
+	.byte	2                               # Abbrev [2] 0x19:0xa DW_TAG_variable
+	.long	35                              # DW_AT_type
+	.byte	1                               # DW_AT_decl_file
+	.byte	4                               # DW_AT_decl_line
+	.byte	2                               # DW_AT_location
+	.byte	251
+	.byte	0
+	.byte	3                               # Abbrev [3] 0x23:0xc DW_TAG_array_type
+	.long	47                              # DW_AT_type
+	.byte	4                               # Abbrev [4] 0x28:0x6 DW_TAG_subrange_type
+	.long	51                              # DW_AT_type
+	.byte	7                               # DW_AT_count
+	.byte	0                               # End Of Children Mark
+	.byte	5                               # Abbrev [5] 0x2f:0x4 DW_TAG_base_type
+	.byte	0                               # DW_AT_name
+	.byte	6                               # DW_AT_encoding
+	.byte	1                               # DW_AT_byte_size
+	.byte	6                               # Abbrev [6] 0x33:0x4 DW_TAG_base_type
+	.byte	1                               # DW_AT_name
+	.byte	8                               # DW_AT_byte_size
+	.byte	7                               # DW_AT_encoding
+	.byte	7                               # Abbrev [7] 0x37:0xf DW_TAG_subprogram
+	.byte	1                               # DW_AT_low_pc
+	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+	.byte	1                               # DW_AT_frame_base
+	.byte	86
+	.byte	2                               # DW_AT_name
+	.byte	1                               # DW_AT_decl_file
+	.byte	3                               # DW_AT_decl_line
+	.long	70                              # DW_AT_type
+                                        # DW_AT_external
+	.byte	5                               # Abbrev [5] 0x46:0x4 DW_TAG_base_type
+	.byte	3                               # DW_AT_name
+	.byte	5                               # DW_AT_encoding
+	.byte	4                               # DW_AT_byte_size
+	.byte	0                               # End Of Children Mark
+.Ldebug_info_dwo_end0:
+	.section	.debug_abbrev.dwo,"e", at progbits
+	.byte	1                               # Abbreviation Code
+	.byte	17                              # DW_TAG_compile_unit
+	.byte	1                               # DW_CHILDREN_yes
+	.byte	37                              # DW_AT_producer
+	.ascii	"\202>"                         # DW_FORM_GNU_str_index
+	.byte	19                              # DW_AT_language
+	.byte	5                               # DW_FORM_data2
+	.byte	3                               # DW_AT_name
+	.ascii	"\202>"                         # DW_FORM_GNU_str_index
+	.ascii	"\260B"                         # DW_AT_GNU_dwo_name
+	.ascii	"\202>"                         # DW_FORM_GNU_str_index
+	.ascii	"\261B"                         # DW_AT_GNU_dwo_id
+	.byte	7                               # DW_FORM_data8
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	2                               # Abbreviation Code
+	.byte	52                              # DW_TAG_variable
+	.byte	0                               # DW_CHILDREN_no
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	58                              # DW_AT_decl_file
+	.byte	11                              # DW_FORM_data1
+	.byte	59                              # DW_AT_decl_line
+	.byte	11                              # DW_FORM_data1
+	.byte	2                               # DW_AT_location
+	.byte	24                              # DW_FORM_exprloc
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	3                               # Abbreviation Code
+	.byte	1                               # DW_TAG_array_type
+	.byte	1                               # DW_CHILDREN_yes
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	4                               # Abbreviation Code
+	.byte	33                              # DW_TAG_subrange_type
+	.byte	0                               # DW_CHILDREN_no
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	55                              # DW_AT_count
+	.byte	11                              # DW_FORM_data1
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	5                               # Abbreviation Code
+	.byte	36                              # DW_TAG_base_type
+	.byte	0                               # DW_CHILDREN_no
+	.byte	3                               # DW_AT_name
+	.ascii	"\202>"                         # DW_FORM_GNU_str_index
+	.byte	62                              # DW_AT_encoding
+	.byte	11                              # DW_FORM_data1
+	.byte	11                              # DW_AT_byte_size
+	.byte	11                              # DW_FORM_data1
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	6                               # Abbreviation Code
+	.byte	36                              # DW_TAG_base_type
+	.byte	0                               # DW_CHILDREN_no
+	.byte	3                               # DW_AT_name
+	.ascii	"\202>"                         # DW_FORM_GNU_str_index
+	.byte	11                              # DW_AT_byte_size
+	.byte	11                              # DW_FORM_data1
+	.byte	62                              # DW_AT_encoding
+	.byte	11                              # DW_FORM_data1
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	7                               # Abbreviation Code
+	.byte	46                              # DW_TAG_subprogram
+	.byte	0                               # DW_CHILDREN_no
+	.byte	17                              # DW_AT_low_pc
+	.ascii	"\201>"                         # DW_FORM_GNU_addr_index
+	.byte	18                              # DW_AT_high_pc
+	.byte	6                               # DW_FORM_data4
+	.byte	64                              # DW_AT_frame_base
+	.byte	24                              # DW_FORM_exprloc
+	.byte	3                               # DW_AT_name
+	.ascii	"\202>"                         # DW_FORM_GNU_str_index
+	.byte	58                              # DW_AT_decl_file
+	.byte	11                              # DW_FORM_data1
+	.byte	59                              # DW_AT_decl_line
+	.byte	11                              # DW_FORM_data1
+	.byte	73                              # DW_AT_type
+	.byte	19                              # DW_FORM_ref4
+	.byte	63                              # DW_AT_external
+	.byte	25                              # DW_FORM_flag_present
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	0                               # EOM(3)
+	.section	.debug_addr,"", at progbits
+.Laddr_table_base0:
+	.quad	.L.str
+	.quad	.Lfunc_begin0
+	.section	.debug_gnu_pubnames,"", at progbits
+	.long	.LpubNames_end0-.LpubNames_start0 # Length of Public Names Info
+.LpubNames_start0:
+	.short	2                               # DWARF Version
+	.long	.Lcu_begin0                     # Offset of Compilation Unit Info
+	.long	48                              # Compilation Unit Length
+	.long	25                              # DIE offset
+	.byte	160                             # Attributes: VARIABLE, STATIC
+	.byte	0                               # External Name
+	.long	55                              # DIE offset
+	.byte	48                              # Attributes: FUNCTION, EXTERNAL
+	.asciz	"main"                          # External Name
+	.long	0                               # End Mark
+.LpubNames_end0:
+	.section	.debug_gnu_pubtypes,"", at progbits
+	.long	.LpubTypes_end0-.LpubTypes_start0 # Length of Public Types Info
+.LpubTypes_start0:
+	.short	2                               # DWARF Version
+	.long	.Lcu_begin0                     # Offset of Compilation Unit Info
+	.long	48                              # Compilation Unit Length
+	.long	47                              # DIE offset
+	.byte	144                             # Attributes: TYPE, STATIC
+	.asciz	"char"                          # External Name
+	.long	70                              # DIE offset
+	.byte	144                             # Attributes: TYPE, STATIC
+	.asciz	"int"                           # External Name
+	.long	0                               # End Mark
+.LpubTypes_end0:
+	.ident	"clang version 19.0.0git"
+	.section	".note.GNU-stack","", at progbits
+	.addrsig
+	.addrsig_sym printf
+	.section	.debug_line,"", at progbits
+.Lline_table_start0:
diff --git a/llvm/test/tools/llvm-dwp/X86/empty_warning.test b/llvm/test/tools/llvm-dwp/X86/empty_warning.test
new file mode 100644
index 0000000000000..d4bdcb124bc2a
--- /dev/null
+++ b/llvm/test/tools/llvm-dwp/X86/empty_warning.test
@@ -0,0 +1,6 @@
+; RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=%t.split.dwo -dwarf-version=4 %p/../Inputs/empty_warning/split.s -o %t.split.o
+; RUN: llvm-dwp -e %t.split.o -o %t.split.dwp 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OUTPUT --allow-empty
+; CHECK-NO-OUTPUT-NOT: .
+; RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj -dwarf-version=4 %p/../Inputs/empty_warning/non_split.s -o %t.non_split.o
+; RUN: llvm-dwp -e %t.non_split.o -o %t.non_split.dwp 2>&1 | FileCheck %s --check-prefix=CHECK-WARNING
+; CHECK-WARNING: warning: no dwo files found
\ No newline at end of file
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index 3da408b7e8e8c..40207ec5f2b3f 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -190,7 +190,7 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
 
   if (DWOFilenames.empty()) {
     WithColor::defaultWarningHandler(
-        make_error<DWPError>("No dwo files found!"));
+        make_error<DWPError>("no dwo files found"));
     return 0;
   }
 

>From 4ee62b01c7b4825494a6f7ac34795e0257128a45 Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Fri, 7 Jun 2024 17:46:10 +0800
Subject: [PATCH 5/7] update test

---
 .../test/tools/llvm-dwp/Inputs/empty_warning/split.s |  6 +++---
 llvm/test/tools/llvm-dwp/X86/empty_warning.test      | 12 +++++++-----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/llvm/test/tools/llvm-dwp/Inputs/empty_warning/split.s b/llvm/test/tools/llvm-dwp/Inputs/empty_warning/split.s
index 50ed62f26727a..c706efd31cdc5 100644
--- a/llvm/test/tools/llvm-dwp/Inputs/empty_warning/split.s
+++ b/llvm/test/tools/llvm-dwp/Inputs/empty_warning/split.s
@@ -12,7 +12,7 @@
 
 	.text
 	.file	"main.c"
-	.file	1 "/xxx/xxx" "main.c"
+	.file	1 "/xxx/xxx/xxx" "main.c"
 	.globl	main                            # -- Begin function main
 	.p2align	4, 0x90
 	.type	main, at function
@@ -93,9 +93,9 @@ main:                                   # @main
 .Ldebug_info_end0:
 	.section	.debug_str,"MS", at progbits,1
 .Lskel_string0:
-	.asciz	"xxx/xxx" # string offset=0
+	.asciz	"xxx/xxx/xxx" # string offset=0
 .Lskel_string1:
-	.asciz	"main.dwo"                      # string offset=64
+	.asciz	"split_invalid.dwo"                      # string offset=64
 	.section	.debug_str.dwo,"eMS", at progbits,1
 .Linfo_string0:
 	.asciz	"char"                          # string offset=0
diff --git a/llvm/test/tools/llvm-dwp/X86/empty_warning.test b/llvm/test/tools/llvm-dwp/X86/empty_warning.test
index d4bdcb124bc2a..f45bbd5b6466a 100644
--- a/llvm/test/tools/llvm-dwp/X86/empty_warning.test
+++ b/llvm/test/tools/llvm-dwp/X86/empty_warning.test
@@ -1,6 +1,8 @@
-; RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=%t.split.dwo -dwarf-version=4 %p/../Inputs/empty_warning/split.s -o %t.split.o
-; RUN: llvm-dwp -e %t.split.o -o %t.split.dwp 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OUTPUT --allow-empty
-; CHECK-NO-OUTPUT-NOT: .
-; RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj -dwarf-version=4 %p/../Inputs/empty_warning/non_split.s -o %t.non_split.o
-; RUN: llvm-dwp -e %t.non_split.o -o %t.non_split.dwp 2>&1 | FileCheck %s --check-prefix=CHECK-WARNING
+; RUN: rm -rf %t
+; RUN: mkdir -p %t
+; RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=%t/split.dwo -dwarf-version=4 %p/../Inputs/empty_warning/split.s -o %t/split.o
+; RUN: not llvm-dwp -e %t/split.o -o %t/split.dwp 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+; CHECK-ERROR: error: 'xxx/xxx/xxx/split_invalid.dwo': No such file or directory
+; RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj -dwarf-version=4 %p/../Inputs/empty_warning/non_split.s -o %t/non_split.o
+; RUN: llvm-dwp -e %t/non_split.o -o %t/non_split.dwp 2>&1 | FileCheck %s --check-prefix=CHECK-WARNING
 ; CHECK-WARNING: warning: no dwo files found
\ No newline at end of file

>From 7cea95dd4f3ee571106a58da0dcf9af77fb16459 Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Sun, 9 Jun 2024 22:20:48 +0800
Subject: [PATCH 6/7] modify warnging messages

---
 llvm/test/tools/llvm-dwp/X86/empty_warning.test | 4 ++--
 llvm/tools/llvm-dwp/llvm-dwp.cpp                | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/test/tools/llvm-dwp/X86/empty_warning.test b/llvm/test/tools/llvm-dwp/X86/empty_warning.test
index f45bbd5b6466a..ed83c3eb3cd05 100644
--- a/llvm/test/tools/llvm-dwp/X86/empty_warning.test
+++ b/llvm/test/tools/llvm-dwp/X86/empty_warning.test
@@ -2,7 +2,7 @@
 ; RUN: mkdir -p %t
 ; RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=%t/split.dwo -dwarf-version=4 %p/../Inputs/empty_warning/split.s -o %t/split.o
 ; RUN: not llvm-dwp -e %t/split.o -o %t/split.dwp 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
-; CHECK-ERROR: error: 'xxx/xxx/xxx/split_invalid.dwo': No such file or directory
+; CHECK-ERROR: error: 'xxx/xxx/xxx{{/\\}}split_invalid.dwo': No such file or directory
 ; RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj -dwarf-version=4 %p/../Inputs/empty_warning/non_split.s -o %t/non_split.o
 ; RUN: llvm-dwp -e %t/non_split.o -o %t/non_split.dwp 2>&1 | FileCheck %s --check-prefix=CHECK-WARNING
-; CHECK-WARNING: warning: no dwo files found
\ No newline at end of file
+; CHECK-WARNING: warning: executable file does not contain any references to dwo files
\ No newline at end of file
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index 40207ec5f2b3f..fa1a792cf4868 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -190,7 +190,7 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
 
   if (DWOFilenames.empty()) {
     WithColor::defaultWarningHandler(
-        make_error<DWPError>("no dwo files found"));
+        make_error<DWPError>("executable file does not contain any references to dwo files"));
     return 0;
   }
 

>From 9ad6ffa2f7d4d6a7029f555642af0fbd07b70f45 Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Sun, 9 Jun 2024 22:39:19 +0800
Subject: [PATCH 7/7] modify warnging messages

---
 llvm/tools/llvm-dwp/llvm-dwp.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index fa1a792cf4868..7afcbafeef9e4 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -189,8 +189,8 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
   }
 
   if (DWOFilenames.empty()) {
-    WithColor::defaultWarningHandler(
-        make_error<DWPError>("executable file does not contain any references to dwo files"));
+    WithColor::defaultWarningHandler(make_error<DWPError>(
+        "executable file does not contain any references to dwo files"));
     return 0;
   }
 



More information about the llvm-commits mailing list