mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-02 01:20:49 +00:00
MINOR: debug: always export the my_backtrace function
In order to simplify the code and remove annoying ifdefs everywhere, let's always export my_backtrace() and make it adapt to the situation and return zero if not supported. A small update in the thread dump function was needed to make sure we don't use its results if it fails now.
This commit is contained in:
parent
3d4631fec6
commit
2f1227eb3f
@ -993,13 +993,14 @@ int may_access(const void *ptr);
|
|||||||
const void *resolve_sym_name(struct buffer *buf, const char *pfx, const void *addr);
|
const void *resolve_sym_name(struct buffer *buf, const char *pfx, const void *addr);
|
||||||
const char *get_exec_path();
|
const char *get_exec_path();
|
||||||
|
|
||||||
#if defined(USE_BACKTRACE)
|
|
||||||
/* Note that this may result in opening libgcc() on first call, so it may need
|
/* Note that this may result in opening libgcc() on first call, so it may need
|
||||||
* to have been called once before chrooting.
|
* to have been called once before chrooting.
|
||||||
*/
|
*/
|
||||||
static forceinline int my_backtrace(void **buffer, int max)
|
static forceinline int my_backtrace(void **buffer, int max)
|
||||||
{
|
{
|
||||||
#ifdef HA_HAVE_WORKING_BACKTRACE
|
#if !defined(USE_BACKTRACE)
|
||||||
|
return 0;
|
||||||
|
#elif defined(HA_HAVE_WORKING_BACKTRACE)
|
||||||
return backtrace(buffer, max);
|
return backtrace(buffer, max);
|
||||||
#else
|
#else
|
||||||
const struct frame {
|
const struct frame {
|
||||||
@ -1016,7 +1017,6 @@ static forceinline int my_backtrace(void **buffer, int max)
|
|||||||
return count;
|
return count;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* same as realloc() except that ptr is also freed upon failure */
|
/* same as realloc() except that ptr is also freed upon failure */
|
||||||
static inline void *my_realloc2(void *ptr, size_t size)
|
static inline void *my_realloc2(void *ptr, size_t size)
|
||||||
|
@ -100,7 +100,6 @@ void ha_thread_dump(struct buffer *buf, int thr, int calling_tid)
|
|||||||
chunk_appendf(buf, " curr_task=");
|
chunk_appendf(buf, " curr_task=");
|
||||||
ha_task_dump(buf, sched->current, " ");
|
ha_task_dump(buf, sched->current, " ");
|
||||||
|
|
||||||
#ifdef USE_BACKTRACE
|
|
||||||
if (stuck) {
|
if (stuck) {
|
||||||
/* We only emit the backtrace for stuck threads in order not to
|
/* We only emit the backtrace for stuck threads in order not to
|
||||||
* waste precious output buffer space with non-interesting data.
|
* waste precious output buffer space with non-interesting data.
|
||||||
@ -119,7 +118,7 @@ void ha_thread_dump(struct buffer *buf, int thr, int calling_tid)
|
|||||||
if (nptrs)
|
if (nptrs)
|
||||||
chunk_appendf(buf, " call trace(%d):\n", nptrs);
|
chunk_appendf(buf, " call trace(%d):\n", nptrs);
|
||||||
|
|
||||||
for (j = 0; j < nptrs || dump < 2; j++) {
|
for (j = 0; nptrs && (j < nptrs || dump < 2); j++) {
|
||||||
if (j == nptrs && !dump) {
|
if (j == nptrs && !dump) {
|
||||||
/* we failed to spot the starting point of the
|
/* we failed to spot the starting point of the
|
||||||
* dump, let's start over dumping everything we
|
* dump, let's start over dumping everything we
|
||||||
@ -162,7 +161,6 @@ void ha_thread_dump(struct buffer *buf, int thr, int calling_tid)
|
|||||||
chunk_appendf(buf, "\n");
|
chunk_appendf(buf, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1094,15 +1092,13 @@ static int init_debug_per_thread()
|
|||||||
static int init_debug()
|
static int init_debug()
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
void *callers[1];
|
||||||
|
|
||||||
#ifdef USE_BACKTRACE
|
|
||||||
/* calling backtrace() will access libgcc at runtime. We don't want to
|
/* calling backtrace() will access libgcc at runtime. We don't want to
|
||||||
* do it after the chroot, so let's perform a first call to have it
|
* do it after the chroot, so let's perform a first call to have it
|
||||||
* ready in memory for later use.
|
* ready in memory for later use.
|
||||||
*/
|
*/
|
||||||
void *callers[1];
|
|
||||||
my_backtrace(callers, sizeof(callers)/sizeof(*callers));
|
my_backtrace(callers, sizeof(callers)/sizeof(*callers));
|
||||||
#endif
|
|
||||||
sa.sa_handler = NULL;
|
sa.sa_handler = NULL;
|
||||||
sa.sa_sigaction = debug_handler;
|
sa.sa_sigaction = debug_handler;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
|
Loading…
Reference in New Issue
Block a user