NeoMutt  2019-12-07
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/mutt.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 37 of file backtrace.c.

38 {
39  unw_cursor_t cursor;
40  unw_context_t uc;
41  unw_word_t ip, sp;
42  char buf[256];
43 
44  printf("\nBacktrace\n");
45  mutt_debug(LL_DEBUG1, "\nBacktrace\n");
46  unw_getcontext(&uc);
47  unw_init_local(&cursor, &uc);
48  while (unw_step(&cursor) > 0)
49  {
50  unw_get_reg(&cursor, UNW_REG_IP, &ip);
51  unw_get_reg(&cursor, UNW_REG_SP, &sp);
52  unw_get_proc_name(&cursor, buf, sizeof(buf), &ip);
53  if (buf[0] == '_')
54  break;
55  printf("\t%s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
56  mutt_debug(LL_DEBUG1, "\t%s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
57  }
58  printf("\n");
59 }
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: