mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 13:20:52 +07:00
perf debug: Move dump_stack() and sighandler_dump_stack() to debug.h
Two more out of util.h. Link: http://lkml.kernel.org/n/tip-polkuxm1cpr06lbgue5pyqum@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
bb8c16db43
commit
8c2b7cac78
@ -8,7 +8,9 @@
|
||||
#include <stdio.h>
|
||||
#include <api/debug.h>
|
||||
#include <linux/time64.h>
|
||||
|
||||
#ifdef HAVE_BACKTRACE_SUPPORT
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
#include "cache.h"
|
||||
#include "color.h"
|
||||
#include "event.h"
|
||||
@ -248,3 +250,31 @@ void perf_debug_setup(void)
|
||||
{
|
||||
libapi_set_print(pr_warning_wrapper, pr_warning_wrapper, pr_debug_wrapper);
|
||||
}
|
||||
|
||||
/* Obtain a backtrace and print it to stdout. */
|
||||
#ifdef HAVE_BACKTRACE_SUPPORT
|
||||
void dump_stack(void)
|
||||
{
|
||||
void *array[16];
|
||||
size_t size = backtrace(array, ARRAY_SIZE(array));
|
||||
char **strings = backtrace_symbols(array, size);
|
||||
size_t i;
|
||||
|
||||
printf("Obtained %zd stack frames.\n", size);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
printf("%s\n", strings[i]);
|
||||
|
||||
free(strings);
|
||||
}
|
||||
#else
|
||||
void dump_stack(void) {}
|
||||
#endif
|
||||
|
||||
void sighandler_dump_stack(int sig)
|
||||
{
|
||||
psignal(sig, "perf");
|
||||
dump_stack();
|
||||
signal(sig, SIG_DFL);
|
||||
raise(sig);
|
||||
}
|
||||
|
@ -56,4 +56,7 @@ int perf_debug_option(const char *str);
|
||||
void perf_debug_setup(void);
|
||||
int perf_quiet_option(void);
|
||||
|
||||
void dump_stack(void);
|
||||
void sighandler_dump_stack(int sig);
|
||||
|
||||
#endif /* __PERF_DEBUG_H */
|
||||
|
@ -4,9 +4,6 @@
|
||||
#include <api/fs/fs.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/utsname.h>
|
||||
#ifdef HAVE_BACKTRACE_SUPPORT
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include <inttypes.h>
|
||||
#include <signal.h>
|
||||
@ -353,34 +350,6 @@ int hex2u64(const char *ptr, u64 *long_val)
|
||||
return p - ptr;
|
||||
}
|
||||
|
||||
/* Obtain a backtrace and print it to stdout. */
|
||||
#ifdef HAVE_BACKTRACE_SUPPORT
|
||||
void dump_stack(void)
|
||||
{
|
||||
void *array[16];
|
||||
size_t size = backtrace(array, ARRAY_SIZE(array));
|
||||
char **strings = backtrace_symbols(array, size);
|
||||
size_t i;
|
||||
|
||||
printf("Obtained %zd stack frames.\n", size);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
printf("%s\n", strings[i]);
|
||||
|
||||
free(strings);
|
||||
}
|
||||
#else
|
||||
void dump_stack(void) {}
|
||||
#endif
|
||||
|
||||
void sighandler_dump_stack(int sig)
|
||||
{
|
||||
psignal(sig, "perf");
|
||||
dump_stack();
|
||||
signal(sig, SIG_DFL);
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
unsigned long parse_tag_value(const char *str, struct parse_tag *tags)
|
||||
{
|
||||
struct parse_tag *i = tags;
|
||||
|
@ -80,9 +80,6 @@ void event_attr_init(struct perf_event_attr *attr);
|
||||
size_t hex_width(u64 v);
|
||||
int hex2u64(const char *ptr, u64 *val);
|
||||
|
||||
void dump_stack(void);
|
||||
void sighandler_dump_stack(int sig);
|
||||
|
||||
extern unsigned int page_size;
|
||||
extern int cacheline_size;
|
||||
extern int sysctl_perf_event_max_stack;
|
||||
|
Loading…
Reference in New Issue
Block a user