Skip to contentSkip to conversation

perf jit: Fix inaccurate DWARF line table

PATCH Applied Nick Gasson 3 participants 3 messages May 28, 2020 – May 29, 2020 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf jit: Fix inaccurate DWARF line table

Fix an issue where addresses in the DWARF line table are offset by -0x40 (GEN_ELF_TEXT_OFFSET). This can be seen with objdump -S on the ELF files after perf inject.

---
 tools/perf/util/genelf_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/genelf_debug.c +2 -2
index 30e9f618f6cd..dd40683bd4c0 100644
@@ -342,7 +342,7 @@ static void emit_lineno_info(struct buffer_ext *be,
 	 */
 
 	/* start state of the state machine we take care of */
-	unsigned long last_vma = code_addr;
+	unsigned long last_vma = 0;
 	char const  *cur_filename = NULL;
 	unsigned long cur_file_idx = 0;
 	int last_line = 1;
@@ -473,7 +473,7 @@ jit_process_debug_info(uint64_t code_addr,
 		ent = debug_entry_next(ent);
 	}
 	add_compilation_unit(di, buffer_ext_size(dl));
-	add_debug_line(dl, debug, nr_debug_entries, 0);
+	add_debug_line(dl, debug, nr_debug_entries, GEN_ELF_TEXT_OFFSET);
 	add_debug_abbrev(da);
 	if (0) buffer_ext_dump(da, "abbrev");
 
Signature · 1 line
2.26.2
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Nick Gasson

Fix an issue where addresses in the DWARF line table are offset by -0x40 (GEN_ELF_TEXT_OFFSET). This can be seen with objdump -S on the ELF files after perf inject.

Without too much knowledge this looks good to me. The original code came from oprofile's jit support:
https://sourceforge.net/p/oprofile/oprofile/ci/master/tree/opjitconv/debug_line.c#l325

Quoted 30 lines
---
 tools/perf/util/genelf_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/genelf_debug.c +2 -3
index 30e9f618f6cd..dd40683bd4c0 100644
@@ -342,7 +342,7 @@ static void emit_lineno_info(struct buffer_ext *be,
         */
 
        /* start state of the state machine we take care of */
-       unsigned long last_vma = code_addr;
+       unsigned long last_vma = 0;
        char const  *cur_filename = NULL;
        unsigned long cur_file_idx = 0;
        int last_line = 1;
@@ -473,7 +473,7 @@ jit_process_debug_info(uint64_t code_addr,
                ent = debug_entry_next(ent);
        }
        add_compilation_unit(di, buffer_ext_size(dl));
-       add_debug_line(dl, debug, nr_debug_entries, 0);
+       add_debug_line(dl, debug, nr_debug_entries, GEN_ELF_TEXT_OFFSET);
        add_debug_abbrev(da);
        if (0) buffer_ext_dump(da, "abbrev");
 
--

2.26.2

maintainer Applied
#2 lore raw

Em Thu, May 28, 2020 at 12:44:56AM -0700, Ian Rogers escreveu:

Quoted 11 lines · Nick Gasson
Quoted 4 lines

Fix an issue where addresses in the DWARF line table are offset by -0x40 (GEN_ELF_TEXT_OFFSET). This can be seen with objdump -S on the ELF files after perf inject.

Without too much knowledge this looks good to me. The original code came from oprofile's jit support:
https://sourceforge.net/p/oprofile/oprofile/ci/master/tree/opjitconv/debug_line.c#l325

Thanks, applied and added your comment,

- Arnaldo

Quoted 30 lines
Quoted 30 lines
---
 tools/perf/util/genelf_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/genelf_debug.c +2 -3
index 30e9f618f6cd..dd40683bd4c0 100644
@@ -342,7 +342,7 @@ static void emit_lineno_info(struct buffer_ext *be,
         */
 
        /* start state of the state machine we take care of */
-       unsigned long last_vma = code_addr;
+       unsigned long last_vma = 0;
        char const  *cur_filename = NULL;
        unsigned long cur_file_idx = 0;
        int last_line = 1;
@@ -473,7 +473,7 @@ jit_process_debug_info(uint64_t code_addr,
                ent = debug_entry_next(ent);
        }
        add_compilation_unit(di, buffer_ext_size(dl));
-       add_debug_line(dl, debug, nr_debug_entries, 0);
+       add_debug_line(dl, debug, nr_debug_entries, GEN_ELF_TEXT_OFFSET);
        add_debug_abbrev(da);
        if (0) buffer_ext_dump(da, "abbrev");
 
--

2.26.2

Signature · 1 line
- Arnaldo