NeoMutt  2024-04-25-89-g194907
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
backtrace.c File Reference

Code backtrace. More...

#include "config.h"
#include <libunwind.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "lib.h"
#include "muttlib.h"
+ Include dependency graph for backtrace.c:

Go to the source code of this file.

Functions

void show_backtrace (void)
 Log the program's call stack.
 

Detailed Description

Code backtrace.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file backtrace.c.

Function Documentation

◆ show_backtrace()

void show_backtrace ( void  )

Log the program's call stack.

Definition at line 39 of file backtrace.c.

40{
41 unw_cursor_t cursor = { 0 };
42 unw_context_t uc = { 0 };
43 unw_word_t ip = 0;
44 unw_word_t sp = 0;
45 char buf[256] = { 0 };
46
47 printf("\n%s\n", mutt_make_version());
48 printf("Backtrace\n");
49 mutt_debug(LL_DEBUG1, "\nBacktrace\n");
50 unw_getcontext(&uc);
51 unw_init_local(&cursor, &uc);
52 while (unw_step(&cursor) > 0)
53 {
54 unw_get_reg(&cursor, UNW_REG_IP, &ip);
55 unw_get_reg(&cursor, UNW_REG_SP, &sp);
56 unw_get_proc_name(&cursor, buf, sizeof(buf), &ip);
57 if (buf[0] == '_')
58 continue;
59 printf(" %s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
60 mutt_debug(LL_DEBUG1, " %s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
61 }
62 printf("\n");
63}
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:858
+ Here is the call graph for this function:
+ Here is the caller graph for this function: