2014-01-07 19:47:22 +07:00
|
|
|
#include <linux/compiler.h>
|
2014-04-26 02:31:02 +07:00
|
|
|
#include <linux/types.h>
|
2014-01-07 19:47:22 +07:00
|
|
|
#include <unistd.h>
|
|
|
|
#include "tests.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "machine.h"
|
|
|
|
#include "event.h"
|
|
|
|
#include "unwind.h"
|
|
|
|
#include "perf_regs.h"
|
|
|
|
#include "map.h"
|
|
|
|
#include "thread.h"
|
2014-10-06 07:45:59 +07:00
|
|
|
#include "callchain.h"
|
2014-01-07 19:47:22 +07:00
|
|
|
|
2015-10-05 21:40:20 +07:00
|
|
|
#if defined (__x86_64__) || defined (__i386__)
|
|
|
|
#include "arch-tests.h"
|
|
|
|
#endif
|
|
|
|
|
perf test: Fix dwarf unwind using libunwind.
Perf tool fails to unwind user stack if the event raises in a shared
object. This patch improves tests/dwarf-unwind.c to demonstrate the
problem by utilizing commonly used glibc function "bsearch". If perf is
not statically linked, the testcase will try to unwind a mixed call
trace.
By debugging libunwind I found that there is a bug in unwind-libunwind:
it always passes 0 as segbase to libunwind, cause libunwind unable to
locate debug_frame entry fir first level ip address (I add some more
debugging output into libunwind to make things clear):
>_Uarm_dwarf_find_debug_frame: start_ip = 10be98, end_ip = 10c2a4
>_Uarm_dwarf_find_debug_frame: found debug_frame table `/lib/libc-2.18.so': segbase=0x0, len=7, gp=0x0, table_data=0x449388
>_Uarm_dwarf_search_unwind_table: call lookup:ip = b6cd3bcc, segbase = 0, rel_ip = b6cd3bcc
>lookup: e->start_ip_offset = bcf18 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 6d314 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 33d0c (rel_ip = b6cd3bcc)
...
>lookup: e->start_ip_offset = 15d0c (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 15c40 (rel_ip = b6cd3bcc)
>_Uarm_dwarf_search_unwind_table: IP b6cd3bcc inside range b6c12000-b6d4c000, but no explicit unwind info found
>put_rs_cache: unmasking signals/interrupts and releasing lock
>_Uarm_dwarf_step: returning -10
>_Uarm_step: dwarf_step()=-10
This patch passes map->start as segbase to dwarf_find_debug_frame(), so
di will be initialized correctly.
In addition, dso and executable are different when setting segbase. This
patch first check whether the elf is executable, and pass segbase only
for shared object.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1421203007-75799-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-01-14 09:36:47 +07:00
|
|
|
/* For bsearch. We try to unwind functions in shared object. */
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2014-01-07 19:47:22 +07:00
|
|
|
static int mmap_handler(struct perf_tool *tool __maybe_unused,
|
|
|
|
union perf_event *event,
|
|
|
|
struct perf_sample *sample __maybe_unused,
|
|
|
|
struct machine *machine)
|
|
|
|
{
|
2014-05-30 21:49:42 +07:00
|
|
|
return machine__process_mmap2_event(machine, event, NULL);
|
2014-01-07 19:47:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int init_live_machine(struct machine *machine)
|
|
|
|
{
|
|
|
|
union perf_event event;
|
|
|
|
pid_t pid = getpid();
|
|
|
|
|
|
|
|
return perf_event__synthesize_mmap_events(NULL, &event, pid, pid,
|
2015-06-17 20:51:11 +07:00
|
|
|
mmap_handler, machine, true, 500);
|
2014-01-07 19:47:22 +07:00
|
|
|
}
|
|
|
|
|
perf test: Fix dwarf unwind using libunwind.
Perf tool fails to unwind user stack if the event raises in a shared
object. This patch improves tests/dwarf-unwind.c to demonstrate the
problem by utilizing commonly used glibc function "bsearch". If perf is
not statically linked, the testcase will try to unwind a mixed call
trace.
By debugging libunwind I found that there is a bug in unwind-libunwind:
it always passes 0 as segbase to libunwind, cause libunwind unable to
locate debug_frame entry fir first level ip address (I add some more
debugging output into libunwind to make things clear):
>_Uarm_dwarf_find_debug_frame: start_ip = 10be98, end_ip = 10c2a4
>_Uarm_dwarf_find_debug_frame: found debug_frame table `/lib/libc-2.18.so': segbase=0x0, len=7, gp=0x0, table_data=0x449388
>_Uarm_dwarf_search_unwind_table: call lookup:ip = b6cd3bcc, segbase = 0, rel_ip = b6cd3bcc
>lookup: e->start_ip_offset = bcf18 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 6d314 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 33d0c (rel_ip = b6cd3bcc)
...
>lookup: e->start_ip_offset = 15d0c (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 15c40 (rel_ip = b6cd3bcc)
>_Uarm_dwarf_search_unwind_table: IP b6cd3bcc inside range b6c12000-b6d4c000, but no explicit unwind info found
>put_rs_cache: unmasking signals/interrupts and releasing lock
>_Uarm_dwarf_step: returning -10
>_Uarm_step: dwarf_step()=-10
This patch passes map->start as segbase to dwarf_find_debug_frame(), so
di will be initialized correctly.
In addition, dso and executable are different when setting segbase. This
patch first check whether the elf is executable, and pass segbase only
for shared object.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1421203007-75799-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-01-14 09:36:47 +07:00
|
|
|
#define MAX_STACK 8
|
2014-01-07 19:47:22 +07:00
|
|
|
|
|
|
|
static int unwind_entry(struct unwind_entry *entry, void *arg)
|
|
|
|
{
|
|
|
|
unsigned long *cnt = (unsigned long *) arg;
|
|
|
|
char *symbol = entry->sym ? entry->sym->name : NULL;
|
|
|
|
static const char *funcs[MAX_STACK] = {
|
|
|
|
"test__arch_unwind_sample",
|
|
|
|
"unwind_thread",
|
perf test: Fix dwarf unwind using libunwind.
Perf tool fails to unwind user stack if the event raises in a shared
object. This patch improves tests/dwarf-unwind.c to demonstrate the
problem by utilizing commonly used glibc function "bsearch". If perf is
not statically linked, the testcase will try to unwind a mixed call
trace.
By debugging libunwind I found that there is a bug in unwind-libunwind:
it always passes 0 as segbase to libunwind, cause libunwind unable to
locate debug_frame entry fir first level ip address (I add some more
debugging output into libunwind to make things clear):
>_Uarm_dwarf_find_debug_frame: start_ip = 10be98, end_ip = 10c2a4
>_Uarm_dwarf_find_debug_frame: found debug_frame table `/lib/libc-2.18.so': segbase=0x0, len=7, gp=0x0, table_data=0x449388
>_Uarm_dwarf_search_unwind_table: call lookup:ip = b6cd3bcc, segbase = 0, rel_ip = b6cd3bcc
>lookup: e->start_ip_offset = bcf18 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 6d314 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 33d0c (rel_ip = b6cd3bcc)
...
>lookup: e->start_ip_offset = 15d0c (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 15c40 (rel_ip = b6cd3bcc)
>_Uarm_dwarf_search_unwind_table: IP b6cd3bcc inside range b6c12000-b6d4c000, but no explicit unwind info found
>put_rs_cache: unmasking signals/interrupts and releasing lock
>_Uarm_dwarf_step: returning -10
>_Uarm_step: dwarf_step()=-10
This patch passes map->start as segbase to dwarf_find_debug_frame(), so
di will be initialized correctly.
In addition, dso and executable are different when setting segbase. This
patch first check whether the elf is executable, and pass segbase only
for shared object.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1421203007-75799-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-01-14 09:36:47 +07:00
|
|
|
"compare",
|
|
|
|
"bsearch",
|
2014-01-07 19:47:22 +07:00
|
|
|
"krava_3",
|
|
|
|
"krava_2",
|
|
|
|
"krava_1",
|
|
|
|
"test__dwarf_unwind"
|
|
|
|
};
|
2015-11-17 22:05:39 +07:00
|
|
|
/*
|
|
|
|
* The funcs[MAX_STACK] array index, based on the
|
|
|
|
* callchain order setup.
|
|
|
|
*/
|
|
|
|
int idx = callchain_param.order == ORDER_CALLER ?
|
|
|
|
MAX_STACK - *cnt - 1 : *cnt;
|
2014-01-07 19:47:22 +07:00
|
|
|
|
|
|
|
if (*cnt >= MAX_STACK) {
|
|
|
|
pr_debug("failed: crossed the max stack value %d\n", MAX_STACK);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!symbol) {
|
|
|
|
pr_debug("failed: got unresolved address 0x%" PRIx64 "\n",
|
|
|
|
entry->ip);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-11-17 22:05:39 +07:00
|
|
|
(*cnt)++;
|
|
|
|
pr_debug("got: %s 0x%" PRIx64 ", expecting %s\n",
|
|
|
|
symbol, entry->ip, funcs[idx]);
|
|
|
|
return strcmp((const char *) symbol, funcs[idx]);
|
2014-01-07 19:47:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__ ((noinline))
|
2014-10-24 02:42:19 +07:00
|
|
|
static int unwind_thread(struct thread *thread)
|
2014-01-07 19:47:22 +07:00
|
|
|
{
|
|
|
|
struct perf_sample sample;
|
|
|
|
unsigned long cnt = 0;
|
|
|
|
int err = -1;
|
|
|
|
|
|
|
|
memset(&sample, 0, sizeof(sample));
|
|
|
|
|
|
|
|
if (test__arch_unwind_sample(&sample, thread)) {
|
|
|
|
pr_debug("failed to get unwind sample\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2014-10-24 02:42:19 +07:00
|
|
|
err = unwind__get_entries(unwind_entry, &cnt, thread,
|
2014-01-07 19:47:25 +07:00
|
|
|
&sample, MAX_STACK);
|
2014-01-07 19:47:22 +07:00
|
|
|
if (err)
|
|
|
|
pr_debug("unwind failed\n");
|
|
|
|
else if (cnt != MAX_STACK) {
|
|
|
|
pr_debug("got wrong number of stack entries %lu != %d\n",
|
|
|
|
cnt, MAX_STACK);
|
|
|
|
err = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
free(sample.user_stack.data);
|
|
|
|
free(sample.user_regs.regs);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
perf test: Fix dwarf unwind using libunwind.
Perf tool fails to unwind user stack if the event raises in a shared
object. This patch improves tests/dwarf-unwind.c to demonstrate the
problem by utilizing commonly used glibc function "bsearch". If perf is
not statically linked, the testcase will try to unwind a mixed call
trace.
By debugging libunwind I found that there is a bug in unwind-libunwind:
it always passes 0 as segbase to libunwind, cause libunwind unable to
locate debug_frame entry fir first level ip address (I add some more
debugging output into libunwind to make things clear):
>_Uarm_dwarf_find_debug_frame: start_ip = 10be98, end_ip = 10c2a4
>_Uarm_dwarf_find_debug_frame: found debug_frame table `/lib/libc-2.18.so': segbase=0x0, len=7, gp=0x0, table_data=0x449388
>_Uarm_dwarf_search_unwind_table: call lookup:ip = b6cd3bcc, segbase = 0, rel_ip = b6cd3bcc
>lookup: e->start_ip_offset = bcf18 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 6d314 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 33d0c (rel_ip = b6cd3bcc)
...
>lookup: e->start_ip_offset = 15d0c (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 15c40 (rel_ip = b6cd3bcc)
>_Uarm_dwarf_search_unwind_table: IP b6cd3bcc inside range b6c12000-b6d4c000, but no explicit unwind info found
>put_rs_cache: unmasking signals/interrupts and releasing lock
>_Uarm_dwarf_step: returning -10
>_Uarm_step: dwarf_step()=-10
This patch passes map->start as segbase to dwarf_find_debug_frame(), so
di will be initialized correctly.
In addition, dso and executable are different when setting segbase. This
patch first check whether the elf is executable, and pass segbase only
for shared object.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1421203007-75799-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-01-14 09:36:47 +07:00
|
|
|
static int global_unwind_retval = -INT_MAX;
|
|
|
|
|
|
|
|
__attribute__ ((noinline))
|
|
|
|
static int compare(void *p1, void *p2)
|
|
|
|
{
|
|
|
|
/* Any possible value should be 'thread' */
|
|
|
|
struct thread *thread = *(struct thread **)p1;
|
|
|
|
|
2015-11-17 22:05:39 +07:00
|
|
|
if (global_unwind_retval == -INT_MAX) {
|
|
|
|
/* Call unwinder twice for both callchain orders. */
|
|
|
|
callchain_param.order = ORDER_CALLER;
|
|
|
|
|
perf test: Fix dwarf unwind using libunwind.
Perf tool fails to unwind user stack if the event raises in a shared
object. This patch improves tests/dwarf-unwind.c to demonstrate the
problem by utilizing commonly used glibc function "bsearch". If perf is
not statically linked, the testcase will try to unwind a mixed call
trace.
By debugging libunwind I found that there is a bug in unwind-libunwind:
it always passes 0 as segbase to libunwind, cause libunwind unable to
locate debug_frame entry fir first level ip address (I add some more
debugging output into libunwind to make things clear):
>_Uarm_dwarf_find_debug_frame: start_ip = 10be98, end_ip = 10c2a4
>_Uarm_dwarf_find_debug_frame: found debug_frame table `/lib/libc-2.18.so': segbase=0x0, len=7, gp=0x0, table_data=0x449388
>_Uarm_dwarf_search_unwind_table: call lookup:ip = b6cd3bcc, segbase = 0, rel_ip = b6cd3bcc
>lookup: e->start_ip_offset = bcf18 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 6d314 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 33d0c (rel_ip = b6cd3bcc)
...
>lookup: e->start_ip_offset = 15d0c (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 15c40 (rel_ip = b6cd3bcc)
>_Uarm_dwarf_search_unwind_table: IP b6cd3bcc inside range b6c12000-b6d4c000, but no explicit unwind info found
>put_rs_cache: unmasking signals/interrupts and releasing lock
>_Uarm_dwarf_step: returning -10
>_Uarm_step: dwarf_step()=-10
This patch passes map->start as segbase to dwarf_find_debug_frame(), so
di will be initialized correctly.
In addition, dso and executable are different when setting segbase. This
patch first check whether the elf is executable, and pass segbase only
for shared object.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1421203007-75799-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-01-14 09:36:47 +07:00
|
|
|
global_unwind_retval = unwind_thread(thread);
|
2015-11-17 22:05:39 +07:00
|
|
|
if (!global_unwind_retval) {
|
|
|
|
callchain_param.order = ORDER_CALLEE;
|
|
|
|
global_unwind_retval = unwind_thread(thread);
|
|
|
|
}
|
|
|
|
}
|
perf test: Fix dwarf unwind using libunwind.
Perf tool fails to unwind user stack if the event raises in a shared
object. This patch improves tests/dwarf-unwind.c to demonstrate the
problem by utilizing commonly used glibc function "bsearch". If perf is
not statically linked, the testcase will try to unwind a mixed call
trace.
By debugging libunwind I found that there is a bug in unwind-libunwind:
it always passes 0 as segbase to libunwind, cause libunwind unable to
locate debug_frame entry fir first level ip address (I add some more
debugging output into libunwind to make things clear):
>_Uarm_dwarf_find_debug_frame: start_ip = 10be98, end_ip = 10c2a4
>_Uarm_dwarf_find_debug_frame: found debug_frame table `/lib/libc-2.18.so': segbase=0x0, len=7, gp=0x0, table_data=0x449388
>_Uarm_dwarf_search_unwind_table: call lookup:ip = b6cd3bcc, segbase = 0, rel_ip = b6cd3bcc
>lookup: e->start_ip_offset = bcf18 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 6d314 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 33d0c (rel_ip = b6cd3bcc)
...
>lookup: e->start_ip_offset = 15d0c (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 15c40 (rel_ip = b6cd3bcc)
>_Uarm_dwarf_search_unwind_table: IP b6cd3bcc inside range b6c12000-b6d4c000, but no explicit unwind info found
>put_rs_cache: unmasking signals/interrupts and releasing lock
>_Uarm_dwarf_step: returning -10
>_Uarm_step: dwarf_step()=-10
This patch passes map->start as segbase to dwarf_find_debug_frame(), so
di will be initialized correctly.
In addition, dso and executable are different when setting segbase. This
patch first check whether the elf is executable, and pass segbase only
for shared object.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1421203007-75799-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-01-14 09:36:47 +07:00
|
|
|
|
|
|
|
return p1 - p2;
|
|
|
|
}
|
|
|
|
|
2014-01-07 19:47:22 +07:00
|
|
|
__attribute__ ((noinline))
|
2014-10-24 02:42:19 +07:00
|
|
|
static int krava_3(struct thread *thread)
|
2014-01-07 19:47:22 +07:00
|
|
|
{
|
perf test: Fix dwarf unwind using libunwind.
Perf tool fails to unwind user stack if the event raises in a shared
object. This patch improves tests/dwarf-unwind.c to demonstrate the
problem by utilizing commonly used glibc function "bsearch". If perf is
not statically linked, the testcase will try to unwind a mixed call
trace.
By debugging libunwind I found that there is a bug in unwind-libunwind:
it always passes 0 as segbase to libunwind, cause libunwind unable to
locate debug_frame entry fir first level ip address (I add some more
debugging output into libunwind to make things clear):
>_Uarm_dwarf_find_debug_frame: start_ip = 10be98, end_ip = 10c2a4
>_Uarm_dwarf_find_debug_frame: found debug_frame table `/lib/libc-2.18.so': segbase=0x0, len=7, gp=0x0, table_data=0x449388
>_Uarm_dwarf_search_unwind_table: call lookup:ip = b6cd3bcc, segbase = 0, rel_ip = b6cd3bcc
>lookup: e->start_ip_offset = bcf18 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 6d314 (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 33d0c (rel_ip = b6cd3bcc)
...
>lookup: e->start_ip_offset = 15d0c (rel_ip = b6cd3bcc)
>lookup: e->start_ip_offset = 15c40 (rel_ip = b6cd3bcc)
>_Uarm_dwarf_search_unwind_table: IP b6cd3bcc inside range b6c12000-b6d4c000, but no explicit unwind info found
>put_rs_cache: unmasking signals/interrupts and releasing lock
>_Uarm_dwarf_step: returning -10
>_Uarm_step: dwarf_step()=-10
This patch passes map->start as segbase to dwarf_find_debug_frame(), so
di will be initialized correctly.
In addition, dso and executable are different when setting segbase. This
patch first check whether the elf is executable, and pass segbase only
for shared object.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1421203007-75799-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-01-14 09:36:47 +07:00
|
|
|
struct thread *array[2] = {thread, thread};
|
|
|
|
void *fp = &bsearch;
|
|
|
|
/*
|
|
|
|
* make _bsearch a volatile function pointer to
|
|
|
|
* prevent potential optimization, which may expand
|
|
|
|
* bsearch and call compare directly from this function,
|
|
|
|
* instead of libc shared object.
|
|
|
|
*/
|
|
|
|
void *(*volatile _bsearch)(void *, void *, size_t,
|
|
|
|
size_t, int (*)(void *, void *));
|
|
|
|
|
|
|
|
_bsearch = fp;
|
|
|
|
_bsearch(array, &thread, 2, sizeof(struct thread **), compare);
|
|
|
|
return global_unwind_retval;
|
2014-01-07 19:47:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__ ((noinline))
|
2014-10-24 02:42:19 +07:00
|
|
|
static int krava_2(struct thread *thread)
|
2014-01-07 19:47:22 +07:00
|
|
|
{
|
2014-10-24 02:42:19 +07:00
|
|
|
return krava_3(thread);
|
2014-01-07 19:47:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__ ((noinline))
|
2014-10-24 02:42:19 +07:00
|
|
|
static int krava_1(struct thread *thread)
|
2014-01-07 19:47:22 +07:00
|
|
|
{
|
2014-10-24 02:42:19 +07:00
|
|
|
return krava_2(thread);
|
2014-01-07 19:47:22 +07:00
|
|
|
}
|
|
|
|
|
perf tests: Pass the subtest index to each test routine
Some tests have sub-tests we want to run, so allow passing this.
Wang tried to avoid having to touch all tests, but then, having the
test.func in an anonymous union makes the build fail on older compilers,
like the one in RHEL6, where:
test a = {
.func = foo,
};
fails.
To fix it leave the func pointer in the main structure and pass the subtest
index to all tests, end result function is the same, but we have just one
function pointer, not two, with and without the subtest index as an argument.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-5genj0ficwdmelpoqlds0u4y@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-19 22:01:48 +07:00
|
|
|
int test__dwarf_unwind(int subtest __maybe_unused)
|
2014-01-07 19:47:22 +07:00
|
|
|
{
|
|
|
|
struct machines machines;
|
|
|
|
struct machine *machine;
|
|
|
|
struct thread *thread;
|
|
|
|
int err = -1;
|
|
|
|
|
|
|
|
machines__init(&machines);
|
|
|
|
|
|
|
|
machine = machines__find(&machines, HOST_KERNEL_ID);
|
|
|
|
if (!machine) {
|
|
|
|
pr_err("Could not get machine\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-10-06 07:45:59 +07:00
|
|
|
callchain_param.record_mode = CALLCHAIN_DWARF;
|
|
|
|
|
2014-01-07 19:47:22 +07:00
|
|
|
if (init_live_machine(machine)) {
|
|
|
|
pr_err("Could not init machine\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (verbose > 1)
|
|
|
|
machine__fprintf(machine, stderr);
|
|
|
|
|
2014-03-14 21:00:03 +07:00
|
|
|
thread = machine__find_thread(machine, getpid(), getpid());
|
2014-01-07 19:47:22 +07:00
|
|
|
if (!thread) {
|
|
|
|
pr_err("Could not get thread\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2014-10-24 02:42:19 +07:00
|
|
|
err = krava_1(thread);
|
perf machine: Protect the machine->threads with a rwlock
In addition to using refcounts for the struct thread lifetime
management, we need to protect access to machine->threads from
concurrent access.
That happens in 'perf top', where a thread processes events, inserting
and deleting entries from that rb_tree while another thread decays
hist_entries, that end up dropping references and ultimately deleting
threads from the rb_tree and releasing its resources when no further
hist_entry (or other data structures, like in 'perf sched') references
it.
So the rule is the same for refcounts + protected trees in the kernel,
get the tree lock, find object, bump the refcount, drop the tree lock,
return, use object, drop the refcount if no more use of it is needed,
keep it if storing it in some other data structure, drop when releasing
that data structure.
I.e. pair "t = machine__find(new)_thread()" with a "thread__put(t)", and
"perf_event__preprocess_sample(&al)" with "addr_location__put(&al)".
The addr_location__put() one is because as we return references to
several data structures, we may end up adding more reference counting
for the other data structures and then we'll drop it at
addr_location__put() time.
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-bs9rt4n0jw3hi9f3zxyy3xln@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-07 06:43:22 +07:00
|
|
|
thread__put(thread);
|
2014-01-07 19:47:22 +07:00
|
|
|
|
|
|
|
out:
|
|
|
|
machine__delete_threads(machine);
|
|
|
|
machine__exit(machine);
|
|
|
|
machines__exit(&machines);
|
|
|
|
return err;
|
|
|
|
}
|