NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
backtrace.c File Reference
#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.


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

Detailed Description

Code backtrace

  • 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

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