mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 23:01:04 +07:00
ca58d7e64b
tools/perf/jvmti is broken in so far as it generates incorrect debug
information. Specifically it attributes all debug lines to the original
method being output even in the case that some code is being inlined
from elsewhere. This patch fixes the issue.
To test (from within linux/tools/perf):
export JDIR=/usr/lib/jvm/java-8-openjdk-amd64/
make
cat << __EOF > Test.java
public class Test
{
private StringBuilder b = new StringBuilder();
private void loop(int i, String... args)
{
for (String a : args)
b.append(a);
long hc = b.hashCode() * System.nanoTime();
b = new StringBuilder();
b.append(hc);
System.out.printf("Iteration %d = %d\n", i, hc);
}
public void run(String... args)
{
for (int i = 0; i < 10000; ++i)
{
loop(i, args);
}
}
public static void main(String... args)
{
Test t = new Test();
t.run(args);
}
}
__EOF
$JDIR/bin/javac Test.java
./perf record -F 10000 -g -k mono $JDIR/bin/java -agentpath:`pwd`/libperf-jvmti.so Test
./perf inject --jit -i perf.data -o perf.data.jitted
./perf annotate -i perf.data.jitted --stdio | grep Test\.java: | sort -u
Before this patch, Test.java line numbers get reported that are greater
than the number of lines in the Test.java file. They come from the
source file of the inlined function, e.g. java/lang/String.java:1085.
For further validation one can examine those lines in the JDK source
distribution and confirm that they map to inlined functions called by
Test.java.
After this patch, the filename of the inlined function is output
rather than the incorrect original source filename.
Signed-off-by: Ben Gainey <ben.gainey@arm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Stephane Eranian <eranian@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ben Gainey <ben.gainey@arm.com>
Cc: Colin King <colin.king@canonical.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 598b7c6919
("perf jit: add source line info support")
Link: http://lkml.kernel.org/r/20171122182541.d25599a3eb1ada3480d142fa@arm.com
Signed-off-by: Kim Phillips <kim.phillips@arm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
35 lines
751 B
C
35 lines
751 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __JVMTI_AGENT_H__
|
|
#define __JVMTI_AGENT_H__
|
|
|
|
#include <sys/types.h>
|
|
#include <stdint.h>
|
|
#include <jvmti.h>
|
|
|
|
#if defined(__cplusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct {
|
|
unsigned long pc;
|
|
int line_number;
|
|
int discrim; /* discriminator -- 0 for now */
|
|
jmethodID methodID;
|
|
} jvmti_line_info_t;
|
|
|
|
void *jvmti_open(void);
|
|
int jvmti_close(void *agent);
|
|
int jvmti_write_code(void *agent, char const *symbol_name,
|
|
uint64_t vma, void const *code,
|
|
const unsigned int code_size);
|
|
|
|
int jvmti_write_debug_info(void *agent, uint64_t code, int nr_lines,
|
|
jvmti_line_info_t *li,
|
|
const char * const * file_names);
|
|
|
|
#if defined(__cplusplus)
|
|
}
|
|
|
|
#endif
|
|
#endif /* __JVMTI_H__ */
|