NeoMutt  2020-06-26-250-g349c94
Teaching an old dog new tricks
DOXYGEN
backtrace.c File Reference

Code backtrace. More...

#include "config.h"
#include <libunwind.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "lib.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. More...
 

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 38 of file backtrace.c.

39 {
40  unw_cursor_t cursor;
41  unw_context_t uc;
42  unw_word_t ip, sp;
43  char buf[256];
44 
45  printf("\nBacktrace\n");
46  mutt_debug(LL_DEBUG1, "\nBacktrace\n");
47  unw_getcontext(&uc);
48  unw_init_local(&cursor, &uc);
49  while (unw_step(&cursor) > 0)
50  {
51  unw_get_reg(&cursor, UNW_REG_IP, &ip);
52  unw_get_reg(&cursor, UNW_REG_SP, &sp);
53  unw_get_proc_name(&cursor, buf, sizeof(buf), &ip);
54  if (buf[0] == '_')
55  break;
56  printf("\t%s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
57  mutt_debug(LL_DEBUG1, "\t%s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
58  }
59  printf("\n");
60 }
Log at debug level 1.
Definition: logging.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
+ Here is the caller graph for this function: