Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
dwarf_expr.c File Reference
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <inttypes.h>
#include <assert.h>
#include "common.h"
#include "dwdebug.h"
#include "dwdebug_priv.h"
#include "memory-access.h"
#include <dwarf.h>
#include <gelf.h>
#include <elfutils/libebl.h>
#include <elfutils/libdw.h>
#include <elfutils/libdwfl.h>
Include dependency graph for dwarf_expr.c:

Go to the source code of this file.

Macros

#define NEED(n)   if (len < (n)) goto errout
 
#define CONSUME(n)   NEED (n); else len -= (n)
 
#define NEEDSTACK(n)
 
#define PUSH(value)
 
#define PEEK()
 
#define POP()
 
#define PICK(i)
 
#define INPLACE1(OP, value)
 
#define INPLACE1SIGNED(OP, value)
 
#define INPLACE1UNARY(OP)
 
#define INPLACE2(OP)
 
#define OPCONSTU(size, tt)
 
#define OPCONSTS(size, tt)
 
#define PRIxDwarfWord   PRIx32
 
#define SNEED(n)   if (len < (Dwarf_Word) (n)) goto errout
 
#define SCONSUME(n)   SNEED(n); else len -= (n)
 
#define ONLYOP(location, setter,...)
 
#define SOPCONSTU(size, tt)
 
#define SOPCONSTS(size, tt)
 

Functions

const char * dwarf_op_string (unsigned int op)
 
loctype_t dwarf_location_resolve (const unsigned char *data, unsigned int len, struct location_ctxt *lctxt, struct symbol *symbol, struct location *o_loc)
 
struct locationdwarf_get_static_ops (struct symbol_root_dwarf *srd, const unsigned char *data, Dwarf_Word len, unsigned int attr)
 

Macro Definition Documentation

#define CONSUME (   n)    NEED (n); else len -= (n)
#define INPLACE1 (   OP,
  value 
)
Value:
do { \
if (overflowstack) \
overflowstack[stackdepth - 1] = \
overflowstack[stackdepth - 1] OP (value); \
else \
stack[stackdepth - 1] = \
stack[stackdepth - 1] OP (value); \
} while (0)
#define NEEDSTACK(n)
#define INPLACE1SIGNED (   OP,
  value 
)
Value:
do { \
if (overflowstack) \
overflowstack[stackdepth - 1] = (Dwarf_Word) \
((int64_t)overflowstack[stackdepth - 1] OP (int64_t)(value)); \
else \
stack[stackdepth - 1] = (Dwarf_Word) \
((int64_t)stack[stackdepth - 1] OP (int64_t)(value)); \
} while (0)
#define NEEDSTACK(n)
#define INPLACE1UNARY (   OP)
Value:
do { \
if (overflowstack) \
overflowstack[stackdepth - 1] = \
OP overflowstack[stackdepth - 1]; \
else \
stack[stackdepth - 1] = \
OP stack[stackdepth - 1]; \
} while (0)
#define NEEDSTACK(n)
#define INPLACE2 (   OP)
Value:
do { \
if (overflowstack) \
overflowstack[stackdepth - 2] = \
overflowstack[stackdepth - 2] OP overflowstack[stackdepth - 1]; \
else \
stack[stackdepth - 2] = \
stack[stackdepth - 1] OP stack[stackdepth - 2]; \
--stackdepth; \
} while (0)
#define NEEDSTACK(n)
#define NEED (   n)    if (len < (n)) goto errout
#define NEEDSTACK (   n)
Value:
do { \
if (n > stackdepth) { \
verror("op %s needed %d stack values, but only %d available!\n", \
known_ops[op],(n),stackdepth); \
goto errout; \
} \
} while (0)
#define verror(format,...)
Definition: log.h:30
#define ONLYOP (   location,
  setter,
  ... 
)
Value:
if (start == (origdata + 1) && len == 0) { \
location_set_ ## setter((location), ## __VA_ARGS__); \
goto out; \
} \
else { \
"unsupported %s op with other ops!\n",known_ops[op]); \
}
Definition: log.h:69
int len
Definition: dumptarget.c:52
#define vdebug(devel, areas, flags, format,...)
Definition: log.h:302
#define OPCONSTS (   size,
  tt 
)
Value:
NEED(size); \
s64 = (int64_t)*((tt *)data); \
data += size; \
CONSUME(size); \
vdebug(6,LA_DEBUG,LF_DWARFOPS,"%s -> 0x%"PRIx64"\n", \
known_ops[op],s64); \
PUSH((Dwarf_Word)s64)
#define CONSUME(n)
Definition: log.h:69
#define vdebug(devel, areas, flags, format,...)
Definition: log.h:302
#define PUSH(value)
#define NEED(n)
#define OPCONSTU (   size,
  tt 
)
Value:
NEED(size); \
u64 = (uint64_t)*((tt *)data); \
data += size; \
CONSUME(size); \
vdebug(6,LA_DEBUG,LF_DWARFOPS,"%s -> 0x%"PRIu64"\n", \
known_ops[op],u64); \
PUSH((Dwarf_Word)u64)
#define CONSUME(n)
Definition: log.h:69
#define vdebug(devel, areas, flags, format,...)
Definition: log.h:302
#define PUSH(value)
#define NEED(n)
#define PEEK ( )
Value:
((overflowstack) ? overflowstack[stackdepth - 1] \
: stack[stackdepth - 1])
#define PICK (   i)
Value:
((overflowstack) ? overflowstack[stackdepth - 1 - i] \
: stack[stackdepth - 1 - i])
static uint64_t unsigned int i
#define POP ( )
Value:
((overflowstack) ? overflowstack[--stackdepth] \
: stack[--stackdepth])
#define PRIxDwarfWord   PRIx32
#define PUSH (   value)
Value:
do { \
if (overflowstack) { \
if (stackdepth == overflowstacklen) { \
overflowstack = \
realloc(overflowstack, \
(overflowstacklen + 4) * sizeof(Dwarf_Word)); \
overflowstacklen += 4; \
} \
overflowstack[stackdepth] = value; \
} \
else if (stackdepth == (sizeof(stack) / sizeof(Dwarf_Word))) { \
overflowstacklen = stackdepth + 4; \
overflowstack = calloc(overflowstacklen,sizeof(Dwarf_Word)); \
memcpy(overflowstack,&stack,sizeof(stack)); \
overflowstack[stackdepth] = value; \
} \
else { \
stack[stackdepth] = value; \
} \
++stackdepth; \
} while (0)
void * realloc(void *ptr, size_t size)
Definition: debugserver.c:221
void * calloc(size_t nmemb, size_t size)
Definition: debugserver.c:200
#define SCONSUME (   n)    SNEED(n); else len -= (n)
#define SNEED (   n)    if (len < (Dwarf_Word) (n)) goto errout
#define SOPCONSTS (   size,
  tt 
)
Value:
SNEED(size); \
s64 = (int64_t)*((tt *)data); \
data += size; \
SCONSUME(size); \
vdebug(6,LA_DEBUG,LF_DWARFSOPS,"%s -> 0x%" PRIxMAX "\n",known_ops[op],s64); \
if (attr == DW_AT_data_member_location) { \
ONLYOP(retval,member_offset,(int32_t)s64); \
} \
else { \
"assuming constXs is for loctype_addr!\n"); \
ONLYOP(retval,addr,(uint64_t)s64); \
}
#define SNEED(n)
Definition: log.h:69
#define SCONSUME(n)
#define vdebug(devel, areas, flags, format,...)
Definition: log.h:302
#define ONLYOP(location, setter,...)
#define SOPCONSTU (   size,
  tt 
)
Value:
SNEED(size); \
u64 = (uint64_t)*((tt *)data); \
data += size; \
SCONSUME(size); \
vdebug(6,LA_DEBUG,LF_DWARFSOPS,"%s -> 0x%" PRIuMAX "\n",known_ops[op],u64); \
if (attr == DW_AT_data_member_location) { \
ONLYOP(retval,member_offset,(int32_t)u64); \
} \
else { \
"assuming constXu is for loctype_addr!\n"); \
ONLYOP(retval,addr,u64); \
}
#define SNEED(n)
Definition: log.h:69
#define SCONSUME(n)
#define vdebug(devel, areas, flags, format,...)
Definition: log.h:302
#define ONLYOP(location, setter,...)

Function Documentation

struct location* dwarf_get_static_ops ( struct symbol_root_dwarf srd,
const unsigned char *  data,
Dwarf_Word  len,
unsigned int  attr 
)

Definition at line 987 of file dwarf_expr.c.

loctype_t dwarf_location_resolve ( const unsigned char *  data,
unsigned int  len,
struct location_ctxt lctxt,
struct symbol symbol,
struct location o_loc 
)

Definition at line 213 of file dwarf_expr.c.

const char* dwarf_op_string ( unsigned int  op)

Definition at line 207 of file dwarf_expr.c.