Rizin
unix-like reverse engineering framework and cli tools
bt.c File Reference
#include <rz_analysis.h>
#include "bt/generic-x86.c"
#include "bt/generic-x64.c"
#include "bt/fuzzy-all.c"

Go to the source code of this file.

Typedefs

typedef RzList *(* RzDebugFrameCallback) (RzDebug *dbg, ut64 at)
 

Functions

static void prepend_current_pc (RzDebug *dbg, RzList *list)
 
static RzListrz_debug_native_frames (RzDebug *dbg, ut64 at)
 

Typedef Documentation

◆ RzDebugFrameCallback

typedef RzList*(* RzDebugFrameCallback) (RzDebug *dbg, ut64 at)

Definition at line 13 of file bt.c.

Function Documentation

◆ prepend_current_pc()

static void prepend_current_pc ( RzDebug dbg,
RzList list 
)
static

Definition at line 15 of file bt.c.

15  {
16  RzDebugFrame *frame;
17  const char *pcname;
18  if (list) {
20  if (pcname) {
21  ut64 addr = rz_reg_getv(dbg->reg, pcname);
22  frame = RZ_NEW0(RzDebugFrame);
23  frame->addr = addr;
24  frame->size = 0;
25  rz_list_prepend(list, frame);
26  }
27  }
28 }
RzDebug * dbg
Definition: desil.c:30
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_BORROW RzListIter * rz_list_prepend(RZ_NONNULL RzList *list, void *data)
Appends at the beginning of the list a new element.
Definition: list.c:316
RZ_API ut64 rz_reg_getv(RzReg *reg, const char *name)
Definition: reg.c:332
RZ_API const char * rz_reg_get_name(RzReg *reg, int role)
Definition: reg.c:147
@ RZ_REG_NAME_PC
Definition: rz_reg.h:43
#define RZ_NEW0(x)
Definition: rz_types.h:284
RzReg * reg
Definition: rz_debug.h:286
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58

References addr, rz_debug_frame_t::addr, dbg, list(), rz_debug_t::reg, rz_list_prepend(), RZ_NEW0, rz_reg_get_name(), rz_reg_getv(), RZ_REG_NAME_PC, rz_debug_frame_t::size, and ut64().

Referenced by rz_debug_native_frames().

◆ rz_debug_native_frames()

static RzList* rz_debug_native_frames ( RzDebug dbg,
ut64  at 
)
static

Definition at line 46 of file bt.c.

46  {
48  if (dbg->btalgo) {
49  if (!strcmp(dbg->btalgo, "fuzzy")) {
51  } else if (!strcmp(dbg->btalgo, "analysis")) {
52  if (!strcmp(dbg->arch, "x86")) {
53  if (dbg->bits == RZ_SYS_BITS_64) {
55  } else {
57  }
58  } else {
59  eprintf("Analysis backtrace not available for current architecture (%s)\n", dbg->arch);
60  return NULL;
61  }
62  }
63  }
64  if (!cb) {
65 #if __WINDOWS__
67 #else
68  if (dbg->bits == RZ_SYS_BITS_64) {
70  } else {
72  }
73 #endif
74  }
75 
76  RzList *list;
77  if (dbg->btalgo && !strcmp(dbg->btalgo, "trace")) {
79  } else {
80 #if HAVE_PTRACE
81  struct frames_proxy_args args = { cb, dbg, at };
82  list = rz_debug_ptrace_func(dbg, backtrace_proxy, &args);
83 #else
84  list = cb(dbg, at);
85 #endif
86  }
87 
89  return list;
90 }
RzList *(* RzDebugFrameCallback)(RzDebug *dbg, ut64 at)
Definition: bt.c:13
static void prepend_current_pc(RzDebug *dbg, RzList *list)
Definition: bt.c:15
#define NULL
Definition: cris-opc.c:27
static RzList * backtrace_fuzzy(RzDebug *dbg, ut64 at)
Definition: fuzzy-all.c:41
static RzList * backtrace_x86_64(RzDebug *dbg, ut64 at)
Definition: generic-x64.c:4
static RzList * backtrace_x86_64_analysis(RzDebug *dbg, ut64 at)
Definition: generic-x64.c:58
static RzList * backtrace_x86_32(RzDebug *dbg, ut64 at)
Definition: generic-x86.c:12
static RzList * backtrace_x86_32_analysis(RzDebug *dbg, ut64 at)
Definition: generic-x86.c:45
RZ_API RZ_OWN RzList * rz_list_clone(RZ_NONNULL const RzList *list)
Shallow copies of the list (but doesn't free its elements)
Definition: list.c:496
int args
Definition: mipsasm.c:18
#define eprintf(x, y...)
Definition: rlcc.c:7
@ RZ_SYS_BITS_64
Definition: rz_sys.h:21
char * arch
Definition: rz_debug.h:242
RzList * call_frames
Definition: rz_debug.h:284
char * btalgo
Definition: rz_debug.h:258
int bits
Definition: rz_debug.h:243
static RzList * backtrace_windows(RzDebug *dbg, ut64 at)
Definition: windows-all.c:66
static const char * cb[]
Definition: z80_tab.h:176

References rz_debug_t::arch, args, backtrace_fuzzy(), backtrace_windows(), backtrace_x86_32(), backtrace_x86_32_analysis(), backtrace_x86_64(), backtrace_x86_64_analysis(), rz_debug_t::bits, rz_debug_t::btalgo, rz_debug_t::call_frames, cb, dbg, eprintf, list(), NULL, prepend_current_pc(), rz_list_clone(), and RZ_SYS_BITS_64.

Referenced by rz_debug_gdb_frames().