ReactOS  0.4.13-dev-986-g029b8f2
dwarf.c File Reference
#include "config.h"
#include <sys/types.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#include "windef.h"
#include "winternl.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "oleauto.h"
#include "dbghelp_private.h"
#include "image_private.h"
#include "wine/debug.h"
#include "dwarf.h"
Include dependency graph for dwarf.c:

Go to the source code of this file.

Classes

struct  dwarf2_abbrev_entry_attr_s
 
struct  dwarf2_abbrev_entry_s
 
struct  dwarf2_block
 
struct  attribute
 
struct  dwarf2_debug_info_s
 
struct  dwarf2_section_s
 
struct  dwarf2_traverse_context_s
 
struct  dwarf2_parse_context_s
 
struct  dwarf2_module_info_s
 
struct  dwarf2_subprogram_s
 
struct  frame_state
 
struct  frame_info
 

Macros

#define NONAMELESSUNION
 
#define sc_void   0
 
#define sc_int1   1
 
#define sc_int2   2
 
#define sc_int4   3
 
#define sc_num   4
 
#define loc_dwarf2_location_list   (loc_user + 0)
 
#define loc_dwarf2_block   (loc_user + 1)
 
#define Wine_DW_no_register   0x7FFFFFFF
 
#define NB_FRAME_REGS   64
 
#define MAX_SAVED_STATES   16
 

Typedefs

typedef struct dwarf2_abbrev_entry_attr_s dwarf2_abbrev_entry_attr_t
 
typedef struct dwarf2_abbrev_entry_s dwarf2_abbrev_entry_t
 
typedef struct dwarf2_debug_info_s dwarf2_debug_info_t
 
typedef struct dwarf2_section_s dwarf2_section_t
 
typedef struct dwarf2_traverse_context_s dwarf2_traverse_context_t
 
typedef struct dwarf2_parse_context_s dwarf2_parse_context_t
 
typedef struct dwarf2_subprogram_s dwarf2_subprogram_t
 

Enumerations

enum  dwarf2_sections {
  section_debug, section_string, section_abbrev, section_line,
  section_ranges, section_max
}
 
enum  reg_rule {
  RULE_UNSET, RULE_UNDEFINED, RULE_SAME, RULE_CFA_OFFSET,
  RULE_OTHER_REG, RULE_EXPRESSION, RULE_VAL_EXPRESSION
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dbghelp_dwarf)
 
static struct symtdwarf2_parse_enumeration_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *entry)
 
static unsigned char dwarf2_get_byte (const unsigned char *ptr)
 
static unsigned char dwarf2_parse_byte (dwarf2_traverse_context_t *ctx)
 
static unsigned short dwarf2_get_u2 (const unsigned char *ptr)
 
static unsigned short dwarf2_parse_u2 (dwarf2_traverse_context_t *ctx)
 
static unsigned long dwarf2_get_u4 (const unsigned char *ptr)
 
static unsigned long dwarf2_parse_u4 (dwarf2_traverse_context_t *ctx)
 
static DWORD64 dwarf2_get_u8 (const unsigned char *ptr)
 
static DWORD64 dwarf2_parse_u8 (dwarf2_traverse_context_t *ctx)
 
static unsigned long dwarf2_get_leb128_as_unsigned (const unsigned char *ptr, const unsigned char **end)
 
static unsigned long dwarf2_leb128_as_unsigned (dwarf2_traverse_context_t *ctx)
 
static long dwarf2_get_leb128_as_signed (const unsigned char *ptr, const unsigned char **end)
 
static long dwarf2_leb128_as_signed (dwarf2_traverse_context_t *ctx)
 
static unsigned dwarf2_leb128_length (const dwarf2_traverse_context_t *ctx)
 
static unsigned long dwarf2_get_addr (const unsigned char *ptr, unsigned word_size)
 
static unsigned long dwarf2_parse_addr (dwarf2_traverse_context_t *ctx)
 
static const chardwarf2_debug_traverse_ctx (const dwarf2_traverse_context_t *ctx)
 
static const chardwarf2_debug_ctx (const dwarf2_parse_context_t *ctx)
 
static const chardwarf2_debug_di (const dwarf2_debug_info_t *di)
 
static dwarf2_abbrev_entry_tdwarf2_abbrev_table_find_entry (const struct sparse_array *abbrev_table, unsigned long entry_code)
 
static void dwarf2_parse_abbrev_set (dwarf2_traverse_context_t *abbrev_ctx, struct sparse_array *abbrev_table, struct pool *pool)
 
static void dwarf2_swallow_attribute (dwarf2_traverse_context_t *ctx, const dwarf2_abbrev_entry_attr_t *abbrev_attr)
 
static void dwarf2_fill_attr (const dwarf2_parse_context_t *ctx, const dwarf2_abbrev_entry_attr_t *abbrev_attr, const unsigned char *data, struct attribute *attr)
 
static BOOL dwarf2_find_attribute (const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
 
static void dwarf2_load_one_entry (dwarf2_parse_context_t *, dwarf2_debug_info_t *)
 
static unsigned dwarf2_map_register (int regno)
 
static enum location_error compute_location (dwarf2_traverse_context_t *ctx, struct location *loc, HANDLE hproc, const struct location *frame)
 
static BOOL dwarf2_compute_location_attr (dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned long dw, struct location *loc, const struct location *frame)
 
static struct symtdwarf2_lookup_type (dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di)
 
static const chardwarf2_get_cpp_name (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, const char *name)
 
static BOOL dwarf2_read_range (dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned long *plow, unsigned long *phigh)
 
static BOOL dwarf2_read_one_debug_info (dwarf2_parse_context_t *ctx, dwarf2_traverse_context_t *traverse, dwarf2_debug_info_t *parent_di, dwarf2_debug_info_t **pdi)
 
static struct vectordwarf2_get_di_children (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_base_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_typedef (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_pointer_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_array_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_const_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_volatile_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_unspecified_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_reference_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static void dwarf2_parse_udt_member (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, struct symt_udt *parent)
 
static struct symtdwarf2_parse_subprogram (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_udt_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, enum UdtKind udt)
 
static void dwarf2_parse_enumerator (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, struct symt_enum *parent)
 
static void dwarf2_parse_variable (dwarf2_subprogram_t *subpgm, struct symt_block *block, dwarf2_debug_info_t *di)
 
static void dwarf2_parse_subprogram_label (dwarf2_subprogram_t *subpgm, const dwarf2_debug_info_t *di)
 
static void dwarf2_parse_subprogram_block (dwarf2_subprogram_t *subpgm, struct symt_block *parent_block, dwarf2_debug_info_t *di)
 
static struct symtdwarf2_parse_subroutine_type (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static void dwarf2_parse_inlined_subroutine (dwarf2_subprogram_t *subpgm, struct symt_block *parent_block, dwarf2_debug_info_t *di)
 
static void dwarf2_parse_namespace (dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
 
static void dwarf2_set_line_number (struct module *module, unsigned long address, const struct vector *v, unsigned file, unsigned line)
 
static BOOL dwarf2_parse_line_numbers (const dwarf2_section_t *sections, dwarf2_parse_context_t *ctx, const char *compile_dir, unsigned long offset)
 
static BOOL dwarf2_parse_compilation_unit (const dwarf2_section_t *sections, struct module *module, const struct elf_thunk_area *thunks, dwarf2_traverse_context_t *mod_ctx, unsigned long load_offset)
 
static BOOL dwarf2_lookup_loclist (const struct module_format *modfmt, const BYTE *start, unsigned long ip, dwarf2_traverse_context_t *lctx)
 
static enum location_error loc_compute_frame (struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, DWORD_PTR ip, struct location *frame)
 
static ULONG_PTR dwarf2_parse_augmentation_ptr (dwarf2_traverse_context_t *ctx, unsigned char encoding)
 
static BOOL parse_cie_details (dwarf2_traverse_context_t *ctx, struct frame_info *info)
 
static BOOL dwarf2_get_cie (unsigned long addr, struct module *module, DWORD_PTR delta, dwarf2_traverse_context_t *fde_ctx, dwarf2_traverse_context_t *cie_ctx, struct frame_info *info, BOOL in_eh_frame)
 
static int valid_reg (ULONG_PTR reg)
 
static void execute_cfa_instructions (dwarf2_traverse_context_t *ctx, ULONG_PTR last_ip, struct frame_info *info)
 
static ULONG_PTR get_context_reg (CONTEXT *context, ULONG_PTR dw_reg)
 
static void set_context_reg (struct cpu_stack_walk *csw, CONTEXT *context, ULONG_PTR dw_reg, ULONG_PTR val, BOOL isdebuggee)
 
static void copy_context_reg (CONTEXT *dstcontext, ULONG_PTR dwregdst, CONTEXT *srccontext, ULONG_PTR dwregsrc)
 
static ULONG_PTR eval_expression (const struct module *module, struct cpu_stack_walk *csw, const unsigned char *zp, CONTEXT *context)
 
static void apply_frame_state (const struct module *module, struct cpu_stack_walk *csw, CONTEXT *context, struct frame_state *state, ULONG_PTR *cfa)
 
BOOL dwarf2_virtual_unwind (struct cpu_stack_walk *csw, ULONG_PTR ip, CONTEXT *context, ULONG_PTR *cfa)
 
static void dwarf2_location_compute (struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
 
static BOOL dwarf2_init_section (dwarf2_section_t *section, struct image_file_map *fmap, const char *sectname, const char *zsectname, struct image_section_map *ism)
 
static void dwarf2_fini_section (dwarf2_section_t *section)
 
static void dwarf2_module_remove (struct process *pcs, struct module_format *modfmt)
 
BOOL dwarf2_parse (struct module *module, unsigned long load_offset, const struct elf_thunk_area *thunks, struct image_file_map *fmap)
 

Macro Definition Documentation

◆ loc_dwarf2_block

#define loc_dwarf2_block   (loc_user + 1)

Definition at line 220 of file dwarf.c.

◆ loc_dwarf2_location_list

#define loc_dwarf2_location_list   (loc_user + 0)

Definition at line 219 of file dwarf.c.

◆ MAX_SAVED_STATES

#define MAX_SAVED_STATES   16

Definition at line 2583 of file dwarf.c.

◆ NB_FRAME_REGS

#define NB_FRAME_REGS   64

Definition at line 2582 of file dwarf.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 25 of file dwarf.c.

◆ sc_int1

#define sc_int1   1

Definition at line 189 of file dwarf.c.

◆ sc_int2

#define sc_int2   2

Definition at line 190 of file dwarf.c.

◆ sc_int4

#define sc_int4   3

Definition at line 191 of file dwarf.c.

◆ sc_num

#define sc_num   4

Definition at line 192 of file dwarf.c.

◆ sc_void

#define sc_void   0

Definition at line 188 of file dwarf.c.

◆ Wine_DW_no_register

#define Wine_DW_no_register   0x7FFFFFFF

Definition at line 656 of file dwarf.c.

Typedef Documentation

◆ dwarf2_abbrev_entry_attr_t

◆ dwarf2_abbrev_entry_t

◆ dwarf2_debug_info_t

◆ dwarf2_parse_context_t

◆ dwarf2_section_t

◆ dwarf2_subprogram_t

◆ dwarf2_traverse_context_t

Enumeration Type Documentation

◆ dwarf2_sections

Enumerator
section_debug 
section_string 
section_abbrev 
section_line 
section_ranges 
section_max 

Definition at line 178 of file dwarf.c.

◆ reg_rule

Enumerator
RULE_UNSET 
RULE_UNDEFINED 
RULE_SAME 
RULE_CFA_OFFSET 
RULE_OTHER_REG 
RULE_EXPRESSION 
RULE_VAL_EXPRESSION 

Definition at line 2570 of file dwarf.c.

2571 {
2572  RULE_UNSET, /* not set at all */
2573  RULE_UNDEFINED, /* undefined value */
2574  RULE_SAME, /* same value as previous frame */
2575  RULE_CFA_OFFSET, /* stored at cfa offset */
2576  RULE_OTHER_REG, /* stored in other register */
2577  RULE_EXPRESSION, /* address specified by expression */
2578  RULE_VAL_EXPRESSION /* value specified by expression */
2579 };

Function Documentation

◆ apply_frame_state()

static void apply_frame_state ( const struct module module,
struct cpu_stack_walk csw,
CONTEXT context,
struct frame_state state,
ULONG_PTR cfa 
)
static

Definition at line 3208 of file dwarf.c.

3210 {
3211  unsigned int i;
3212  ULONG_PTR value;
3213  CONTEXT new_context = *context;
3214 
3215  switch (state->cfa_rule)
3216  {
3217  case RULE_EXPRESSION:
3218  *cfa = eval_expression(module, csw, (const unsigned char*)state->cfa_offset, context);
3219  if (!sw_read_mem(csw, *cfa, cfa, sizeof(*cfa)))
3220  {
3221  WARN("Couldn't read memory at %p\n", (void*)*cfa);
3222  return;
3223  }
3224  break;
3225  case RULE_VAL_EXPRESSION:
3226  *cfa = eval_expression(module, csw, (const unsigned char*)state->cfa_offset, context);
3227  break;
3228  default:
3229  *cfa = get_context_reg(context, state->cfa_reg) + state->cfa_offset;
3230  break;
3231  }
3232  if (!*cfa) return;
3233 
3234  for (i = 0; i < NB_FRAME_REGS; i++)
3235  {
3236  switch (state->rules[i])
3237  {
3238  case RULE_UNSET:
3239  case RULE_UNDEFINED:
3240  case RULE_SAME:
3241  break;
3242  case RULE_CFA_OFFSET:
3243  set_context_reg(csw, &new_context, i, *cfa + state->regs[i], TRUE);
3244  break;
3245  case RULE_OTHER_REG:
3246  copy_context_reg(&new_context, i, context, state->regs[i]);
3247  break;
3248  case RULE_EXPRESSION:
3249  value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context);
3250  set_context_reg(csw, &new_context, i, value, TRUE);
3251  break;
3252  case RULE_VAL_EXPRESSION:
3253  value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context);
3254  set_context_reg(csw, &new_context, i, value, FALSE);
3255  break;
3256  }
3257  }
3258  *context = new_context;
3259 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
#define WARN(fmt,...)
Definition: debug.h:111
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static void set_context_reg(struct cpu_stack_walk *csw, CONTEXT *context, ULONG_PTR dw_reg, ULONG_PTR val, BOOL isdebuggee)
Definition: dwarf.c:3047
static int state
Definition: maze.c:121
GLsizei const GLfloat * value
Definition: glext.h:6069
BOOL sw_read_mem(struct cpu_stack_walk *csw, DWORD64 addr, void *ptr, DWORD sz) DECLSPEC_HIDDEN
Definition: stack.c:96
static void copy_context_reg(CONTEXT *dstcontext, ULONG_PTR dwregdst, CONTEXT *srccontext, ULONG_PTR dwregsrc)
Definition: dwarf.c:3081
#define NB_FRAME_REGS
Definition: dwarf.c:2582
static ULONG_PTR eval_expression(const struct module *module, struct cpu_stack_walk *csw, const unsigned char *zp, CONTEXT *context)
Definition: dwarf.c:3097
static ULONG_PTR get_context_reg(CONTEXT *context, ULONG_PTR dw_reg)
Definition: dwarf.c:3033

Referenced by dwarf2_virtual_unwind().

◆ compute_location()

static enum location_error compute_location ( dwarf2_traverse_context_t ctx,
struct location loc,
HANDLE  hproc,
const struct location frame 
)
static

Definition at line 669 of file dwarf.c.

671 {
672  DWORD_PTR tmp, stack[64];
673  unsigned stk;
674  unsigned char op;
675  BOOL piece_found = FALSE;
676 
677  stack[stk = 0] = 0;
678 
679  loc->kind = loc_absolute;
680  loc->reg = Wine_DW_no_register;
681 
682  while (ctx->data < ctx->end_data)
683  {
684  op = dwarf2_parse_byte(ctx);
685 
686  if (op >= DW_OP_lit0 && op <= DW_OP_lit31)
687  stack[++stk] = op - DW_OP_lit0;
688  else if (op >= DW_OP_reg0 && op <= DW_OP_reg31)
689  {
690  /* dbghelp APIs don't know how to cope with this anyway
691  * (for example 'long long' stored in two registers)
692  * FIXME: We should tell winedbg how to deal with it (sigh)
693  */
694  if (!piece_found)
695  {
697  if (loc->reg != Wine_DW_no_register)
698  FIXME("Only supporting one reg (%s/%d -> %s/%d)\n",
699  dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg,
700  dbghelp_current_cpu->fetch_regname(cvreg), cvreg);
701  loc->reg = cvreg;
702  }
703  loc->kind = loc_register;
704  }
705  else if (op >= DW_OP_breg0 && op <= DW_OP_breg31)
706  {
707  /* dbghelp APIs don't know how to cope with this anyway
708  * (for example 'long long' stored in two registers)
709  * FIXME: We should tell winedbg how to deal with it (sigh)
710  */
711  if (!piece_found)
712  {
714  if (loc->reg != Wine_DW_no_register)
715  FIXME("Only supporting one breg (%s/%d -> %s/%d)\n",
716  dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg,
717  dbghelp_current_cpu->fetch_regname(cvreg), cvreg);
718  loc->reg = cvreg;
719  }
720  stack[++stk] = dwarf2_leb128_as_signed(ctx);
721  loc->kind = loc_regrel;
722  }
723  else switch (op)
724  {
725  case DW_OP_nop: break;
726  case DW_OP_addr: stack[++stk] = dwarf2_parse_addr(ctx); break;
727  case DW_OP_const1u: stack[++stk] = dwarf2_parse_byte(ctx); break;
728  case DW_OP_const1s: stack[++stk] = dwarf2_parse_byte(ctx); break;
729  case DW_OP_const2u: stack[++stk] = dwarf2_parse_u2(ctx); break;
730  case DW_OP_const2s: stack[++stk] = dwarf2_parse_u2(ctx); break;
731  case DW_OP_const4u: stack[++stk] = dwarf2_parse_u4(ctx); break;
732  case DW_OP_const4s: stack[++stk] = dwarf2_parse_u4(ctx); break;
733  case DW_OP_const8u: stack[++stk] = dwarf2_parse_u8(ctx); break;
734  case DW_OP_const8s: stack[++stk] = dwarf2_parse_u8(ctx); break;
735  case DW_OP_constu: stack[++stk] = dwarf2_leb128_as_unsigned(ctx); break;
736  case DW_OP_consts: stack[++stk] = dwarf2_leb128_as_signed(ctx); break;
737  case DW_OP_dup: stack[stk + 1] = stack[stk]; stk++; break;
738  case DW_OP_drop: stk--; break;
739  case DW_OP_over: stack[stk + 1] = stack[stk - 1]; stk++; break;
740  case DW_OP_pick: stack[stk + 1] = stack[stk - dwarf2_parse_byte(ctx)]; stk++; break;
741  case DW_OP_swap: tmp = stack[stk]; stack[stk] = stack[stk-1]; stack[stk-1] = tmp; break;
742  case DW_OP_rot: tmp = stack[stk]; stack[stk] = stack[stk-1]; stack[stk-1] = stack[stk-2]; stack[stk-2] = tmp; break;
743  case DW_OP_abs: stack[stk] = labs(stack[stk]); break;
744  case DW_OP_neg: stack[stk] = -stack[stk]; break;
745  case DW_OP_not: stack[stk] = ~stack[stk]; break;
746  case DW_OP_and: stack[stk-1] &= stack[stk]; stk--; break;
747  case DW_OP_or: stack[stk-1] |= stack[stk]; stk--; break;
748  case DW_OP_minus: stack[stk-1] -= stack[stk]; stk--; break;
749  case DW_OP_mul: stack[stk-1] *= stack[stk]; stk--; break;
750  case DW_OP_plus: stack[stk-1] += stack[stk]; stk--; break;
751  case DW_OP_xor: stack[stk-1] ^= stack[stk]; stk--; break;
752  case DW_OP_shl: stack[stk-1] <<= stack[stk]; stk--; break;
753  case DW_OP_shr: stack[stk-1] >>= stack[stk]; stk--; break;
754  case DW_OP_plus_uconst: stack[stk] += dwarf2_leb128_as_unsigned(ctx); break;
755  case DW_OP_shra: stack[stk-1] = stack[stk-1] / (1 << stack[stk]); stk--; break;
756  case DW_OP_div: stack[stk-1] = stack[stk-1] / stack[stk]; stk--; break;
757  case DW_OP_mod: stack[stk-1] = stack[stk-1] % stack[stk]; stk--; break;
758  case DW_OP_ge: stack[stk-1] = (stack[stk-1] >= stack[stk]); stk--; break;
759  case DW_OP_gt: stack[stk-1] = (stack[stk-1] > stack[stk]); stk--; break;
760  case DW_OP_le: stack[stk-1] = (stack[stk-1] <= stack[stk]); stk--; break;
761  case DW_OP_lt: stack[stk-1] = (stack[stk-1] < stack[stk]); stk--; break;
762  case DW_OP_eq: stack[stk-1] = (stack[stk-1] == stack[stk]); stk--; break;
763  case DW_OP_ne: stack[stk-1] = (stack[stk-1] != stack[stk]); stk--; break;
764  case DW_OP_skip: tmp = dwarf2_parse_u2(ctx); ctx->data += tmp; break;
765  case DW_OP_bra: tmp = dwarf2_parse_u2(ctx); if (!stack[stk--]) ctx->data += tmp; break;
766  case DW_OP_regx:
767  tmp = dwarf2_leb128_as_unsigned(ctx);
768  if (!piece_found)
769  {
770  if (loc->reg != Wine_DW_no_register)
771  FIXME("Only supporting one reg\n");
772  loc->reg = dwarf2_map_register(tmp);
773  }
774  loc->kind = loc_register;
775  break;
776  case DW_OP_bregx:
777  tmp = dwarf2_leb128_as_unsigned(ctx);
778  if (loc->reg != Wine_DW_no_register)
779  FIXME("Only supporting one regx\n");
780  loc->reg = dwarf2_map_register(tmp);
781  stack[++stk] = dwarf2_leb128_as_signed(ctx);
782  loc->kind = loc_regrel;
783  break;
784  case DW_OP_fbreg:
785  if (loc->reg != Wine_DW_no_register)
786  FIXME("Only supporting one reg (%s/%d -> -2)\n",
787  dbghelp_current_cpu->fetch_regname(loc->reg), loc->reg);
788  if (frame && frame->kind == loc_register)
789  {
790  loc->kind = loc_regrel;
791  loc->reg = frame->reg;
792  stack[++stk] = dwarf2_leb128_as_signed(ctx);
793  }
794  else if (frame && frame->kind == loc_regrel)
795  {
796  loc->kind = loc_regrel;
797  loc->reg = frame->reg;
798  stack[++stk] = dwarf2_leb128_as_signed(ctx) + frame->offset;
799  }
800  else
801  {
802  /* FIXME: this could be later optimized by not recomputing
803  * this very location expression
804  */
805  loc->kind = loc_dwarf2_block;
806  stack[++stk] = dwarf2_leb128_as_signed(ctx);
807  }
808  break;
809  case DW_OP_piece:
810  {
811  unsigned sz = dwarf2_leb128_as_unsigned(ctx);
812  WARN("Not handling OP_piece (size=%d)\n", sz);
813  piece_found = TRUE;
814  }
815  break;
816  case DW_OP_deref:
817  if (!stk)
818  {
819  FIXME("Unexpected empty stack\n");
820  return loc_err_internal;
821  }
822  if (loc->reg != Wine_DW_no_register)
823  {
824  WARN("Too complex expression for deref\n");
825  return loc_err_too_complex;
826  }
827  if (hproc)
828  {
829  DWORD_PTR addr = stack[stk--];
830  DWORD_PTR deref;
831 
832  if (!ReadProcessMemory(hproc, (void*)addr, &deref, sizeof(deref), NULL))
833  {
834  WARN("Couldn't read memory at %lx\n", addr);
835  return loc_err_cant_read;
836  }
837  stack[++stk] = deref;
838  }
839  else
840  {
841  loc->kind = loc_dwarf2_block;
842  }
843  break;
844  case DW_OP_deref_size:
845  if (!stk)
846  {
847  FIXME("Unexpected empty stack\n");
848  return loc_err_internal;
849  }
850  if (loc->reg != Wine_DW_no_register)
851  {
852  WARN("Too complex expression for deref\n");
853  return loc_err_too_complex;
854  }
855  if (hproc)
856  {
857  DWORD_PTR addr = stack[stk--];
858  BYTE derefsize = dwarf2_parse_byte(ctx);
859  DWORD64 deref;
860 
861  if (!ReadProcessMemory(hproc, (void*)addr, &deref, derefsize, NULL))
862  {
863  WARN("Couldn't read memory at %lx\n", addr);
864  return loc_err_cant_read;
865  }
866 
867  switch (derefsize)
868  {
869  case 1: stack[++stk] = *(unsigned char*)&deref; break;
870  case 2: stack[++stk] = *(unsigned short*)&deref; break;
871  case 4: stack[++stk] = *(DWORD*)&deref; break;
872  case 8: if (ctx->word_size >= derefsize) stack[++stk] = deref; break;
873  }
874  }
875  else
876  {
877  dwarf2_parse_byte(ctx);
878  loc->kind = loc_dwarf2_block;
879  }
880  break;
881  case DW_OP_stack_value:
882  /* Expected behaviour is that this is the last instruction of this
883  * expression and just the "top of stack" value should be put to loc->offset. */
884  break;
885  default:
886  if (op < DW_OP_lo_user) /* as DW_OP_hi_user is 0xFF, we don't need to test against it */
887  FIXME("Unhandled attr op: %x\n", op);
888  /* FIXME else unhandled extension */
889  return loc_err_internal;
890  }
891  }
892  loc->offset = stack[stk];
893  return 0;
894 }
#define TRUE
Definition: types.h:120
struct cpu * dbghelp_current_cpu
Definition: dbghelp.c:150
const unsigned char * data
Definition: dwarf.c:182
#define WARN(fmt,...)
Definition: debug.h:111
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:415
static unsigned long dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:290
const unsigned char * end_data
Definition: dwarf.c:183
#define Wine_DW_no_register
Definition: dwarf.c:656
static unsigned char dwarf2_parse_byte(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:230
unsigned int BOOL
Definition: ntddk_ex.h:94
static long dwarf2_leb128_as_signed(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:326
static unsigned long dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:254
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
Definition: _stack.h:47
unsigned long DWORD
Definition: ntddk_ex.h:95
#define loc_dwarf2_block
Definition: dwarf.c:220
unsigned reg
GLenum const GLvoid * addr
Definition: glext.h:9621
unsigned char BYTE
Definition: mem.h:68
uint32_t DWORD_PTR
Definition: typedefs.h:63
static unsigned long dwarf2_parse_addr(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:369
unsigned kind
uint64_t DWORD64
Definition: typedefs.h:65
static unsigned short dwarf2_parse_u2(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:242
static unsigned dwarf2_map_register(int regno)
Definition: dwarf.c:658
unsigned long offset
unsigned char word_size
Definition: dwarf.c:184
UINT op
Definition: effect.c:223
_Check_return_ long __cdecl labs(_In_ long x)
static DWORD64 dwarf2_parse_u8(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:266

Referenced by dwarf2_compute_location_attr(), dwarf2_location_compute(), and loc_compute_frame().

◆ copy_context_reg()

static void copy_context_reg ( CONTEXT dstcontext,
ULONG_PTR  dwregdst,
CONTEXT srccontext,
ULONG_PTR  dwregsrc 
)
static

Definition at line 3081 of file dwarf.c.

3082 {
3083  unsigned regdstno = dbghelp_current_cpu->map_dwarf_register(dwregdst, TRUE), szdst;
3084  unsigned regsrcno = dbghelp_current_cpu->map_dwarf_register(dwregsrc, TRUE), szsrc;
3085  ULONG_PTR* ptrdst = dbghelp_current_cpu->fetch_context_reg(dstcontext, regdstno, &szdst);
3086  ULONG_PTR* ptrsrc = dbghelp_current_cpu->fetch_context_reg(srccontext, regsrcno, &szsrc);
3087 
3088  if (szdst != szsrc)
3089  {
3090  FIXME("Cannot copy register %lu/%u => %lu/%u because of size mismatch (%u => %u)\n",
3091  dwregsrc, regsrcno, dwregdst, regdstno, szsrc, szdst);
3092  return;
3093  }
3094  memcpy(ptrdst, ptrsrc, szdst);
3095 }
#define TRUE
Definition: types.h:120
struct cpu * dbghelp_current_cpu
Definition: dbghelp.c:150
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define FIXME(fmt,...)
Definition: debug.h:110
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by apply_frame_state().

◆ dwarf2_abbrev_table_find_entry()

static dwarf2_abbrev_entry_t* dwarf2_abbrev_table_find_entry ( const struct sparse_array abbrev_table,
unsigned long  entry_code 
)
static

Definition at line 394 of file dwarf.c.

396 {
397  assert( NULL != abbrev_table );
398  return sparse_array_find(abbrev_table, entry_code);
399 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
void * sparse_array_find(const struct sparse_array *sa, unsigned long idx) DECLSPEC_HIDDEN
Definition: storage.c:272

Referenced by dwarf2_read_one_debug_info().

◆ dwarf2_compute_location_attr()

static BOOL dwarf2_compute_location_attr ( dwarf2_parse_context_t ctx,
const dwarf2_debug_info_t di,
unsigned long  dw,
struct location loc,
const struct location frame 
)
static

Definition at line 896 of file dwarf.c.

901 {
902  struct attribute xloc;
903 
904  if (!dwarf2_find_attribute(ctx, di, dw, &xloc)) return FALSE;
905 
906  switch (xloc.form)
907  {
908  case DW_FORM_data1: case DW_FORM_data2:
909  case DW_FORM_udata: case DW_FORM_sdata:
910  loc->kind = loc_absolute;
911  loc->reg = 0;
912  loc->offset = xloc.u.uvalue;
913  return TRUE;
914  case DW_FORM_data4: case DW_FORM_data8:
916  loc->reg = Wine_DW_no_register;
917  loc->offset = xloc.u.uvalue;
918  return TRUE;
919  case DW_FORM_block:
920  case DW_FORM_block1:
921  case DW_FORM_block2:
922  case DW_FORM_block4:
923  break;
924  default: FIXME("Unsupported yet form %lx\n", xloc.form);
925  return FALSE;
926  }
927 
928  /* assume we have a block form */
929 
930  if (xloc.u.block.size)
931  {
933  enum location_error err;
934 
935  lctx.data = xloc.u.block.ptr;
936  lctx.end_data = xloc.u.block.ptr + xloc.u.block.size;
937  lctx.word_size = ctx->module->format_info[DFI_DWARF]->u.dwarf2_info->word_size;
938 
939  err = compute_location(&lctx, loc, NULL, frame);
940  if (err < 0)
941  {
942  loc->kind = loc_error;
943  loc->reg = err;
944  }
945  else if (loc->kind == loc_dwarf2_block)
946  {
947  unsigned* ptr = pool_alloc(&ctx->module->pool,
948  sizeof(unsigned) + xloc.u.block.size);
949  *ptr = xloc.u.block.size;
950  memcpy(ptr + 1, xloc.u.block.ptr, xloc.u.block.size);
951 #ifndef __REACTOS__
952  loc->offset = (unsigned long)ptr;
953 #else
954  loc->offset = (uintptr_t)ptr;
955 #endif
956  }
957  }
958  return TRUE;
959 }
#define TRUE
Definition: types.h:120
static enum location_error compute_location(dwarf2_traverse_context_t *ctx, struct location *loc, HANDLE hproc, const struct location *frame)
Definition: dwarf.c:669
const unsigned char * data
Definition: dwarf.c:182
struct module * module
Definition: dwarf.c:199
const unsigned char * end_data
Definition: dwarf.c:183
#define Wine_DW_no_register
Definition: dwarf.c:656
void * pool_alloc(struct pool *a, size_t len) DECLSPEC_HIDDEN
Definition: storage.c:90
location_error
#define FIXME(fmt,...)
Definition: debug.h:110
unsigned int uintptr_t
Definition: crtdefs.h:300
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
REFIID LPVOID DWORD dw
Definition: atlbase.h:40
#define loc_dwarf2_block
Definition: dwarf.c:220
unsigned reg
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define err(...)
unsigned kind
#define long
Definition: qsort.c:33
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
unsigned long offset
unsigned char word_size
Definition: dwarf.c:184
#define loc_dwarf2_location_list
Definition: dwarf.c:219

Referenced by dwarf2_parse_subprogram(), dwarf2_parse_udt_member(), and dwarf2_parse_variable().

◆ dwarf2_debug_ctx()

◆ dwarf2_debug_di()

◆ dwarf2_debug_traverse_ctx()

static const char* dwarf2_debug_traverse_ctx ( const dwarf2_traverse_context_t ctx)
static

Definition at line 376 of file dwarf.c.

377 {
378  return wine_dbg_sprintf("ctx(%p)", ctx->data);
379 }
const unsigned char * data
Definition: dwarf.c:182
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271

Referenced by dwarf2_parse_abbrev_set(), and dwarf2_read_one_debug_info().

◆ dwarf2_fill_attr()

static void dwarf2_fill_attr ( const dwarf2_parse_context_t ctx,
const dwarf2_abbrev_entry_attr_t abbrev_attr,
const unsigned char data,
struct attribute attr 
)
static

Definition at line 500 of file dwarf.c.

504 {
505  attr->form = abbrev_attr->form;
506  switch (attr->form)
507  {
508  case DW_FORM_ref_addr:
509  case DW_FORM_addr:
510  attr->u.uvalue = dwarf2_get_addr(data,
511  ctx->module->format_info[DFI_DWARF]->u.dwarf2_info->word_size);
512  TRACE("addr<0x%lx>\n", attr->u.uvalue);
513  break;
514 
515  case DW_FORM_flag:
516  attr->u.uvalue = dwarf2_get_byte(data);
517  TRACE("flag<0x%lx>\n", attr->u.uvalue);
518  break;
519 
521  attr->u.uvalue = 1;
522  TRACE("flag_present\n");
523  break;
524 
525  case DW_FORM_data1:
526  attr->u.uvalue = dwarf2_get_byte(data);
527  TRACE("data1<%lu>\n", attr->u.uvalue);
528  break;
529 
530  case DW_FORM_data2:
531  attr->u.uvalue = dwarf2_get_u2(data);
532  TRACE("data2<%lu>\n", attr->u.uvalue);
533  break;
534 
535  case DW_FORM_data4:
536  attr->u.uvalue = dwarf2_get_u4(data);
537  TRACE("data4<%lu>\n", attr->u.uvalue);
538  break;
539 
540  case DW_FORM_data8:
541  attr->u.lluvalue = dwarf2_get_u8(data);
542  TRACE("data8<%s>\n", wine_dbgstr_longlong(attr->u.uvalue));
543  break;
544 
545  case DW_FORM_ref1:
546  attr->u.uvalue = ctx->ref_offset + dwarf2_get_byte(data);
547  TRACE("ref1<0x%lx>\n", attr->u.uvalue);
548  break;
549 
550  case DW_FORM_ref2:
551  attr->u.uvalue = ctx->ref_offset + dwarf2_get_u2(data);
552  TRACE("ref2<0x%lx>\n", attr->u.uvalue);
553  break;
554 
555  case DW_FORM_ref4:
556  attr->u.uvalue = ctx->ref_offset + dwarf2_get_u4(data);
557  TRACE("ref4<0x%lx>\n", attr->u.uvalue);
558  break;
559 
560  case DW_FORM_ref8:
561  FIXME("Unhandled 64-bit support\n");
562  break;
563 
564  case DW_FORM_sdata:
566  break;
567 
568  case DW_FORM_ref_udata:
570  break;
571 
572  case DW_FORM_udata:
574  break;
575 
576  case DW_FORM_string:
577  attr->u.string = (const char *)data;
578  TRACE("string<%s>\n", attr->u.string);
579  break;
580 
581  case DW_FORM_strp:
582  {
583  unsigned long offset = dwarf2_get_u4(data);
584  attr->u.string = (const char*)ctx->sections[section_string].address + offset;
585  }
586  TRACE("strp<%s>\n", attr->u.string);
587  break;
588 
589  case DW_FORM_block:
590  attr->u.block.size = dwarf2_get_leb128_as_unsigned(data, &attr->u.block.ptr);
591  break;
592 
593  case DW_FORM_block1:
594  attr->u.block.size = dwarf2_get_byte(data);
595  attr->u.block.ptr = data + 1;
596  break;
597 
598  case DW_FORM_block2:
599  attr->u.block.size = dwarf2_get_u2(data);
600  attr->u.block.ptr = data + 2;
601  break;
602 
603  case DW_FORM_block4:
604  attr->u.block.size = dwarf2_get_u4(data);
605  attr->u.block.ptr = data + 4;
606  break;
607 
608  default:
609  FIXME("Unhandled attribute form %lx\n", abbrev_attr->form);
610  break;
611  }
612 }
const unsigned char * address
Definition: dwarf.c:173
const dwarf2_section_t * sections
Definition: dwarf.c:196
static unsigned long dwarf2_get_addr(const unsigned char *ptr, unsigned word_size)
Definition: dwarf.c:350
static unsigned char dwarf2_get_byte(const unsigned char *ptr)
Definition: dwarf.c:225
GLintptr offset
Definition: glext.h:5920
struct module * module
Definition: dwarf.c:199
static unsigned long dwarf2_get_u4(const unsigned char *ptr)
Definition: dwarf.c:249
static long dwarf2_get_leb128_as_signed(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:301
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static DWORD64 dwarf2_get_u8(const unsigned char *ptr)
Definition: dwarf.c:261
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long ref_offset
Definition: dwarf.c:205
Definition: cookie.c:170
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned long form
Definition: dwarf.c:128
static unsigned short dwarf2_get_u2(const unsigned char *ptr)
Definition: dwarf.c:237
static unsigned long dwarf2_get_leb128_as_unsigned(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:273
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

Referenced by dwarf2_find_attribute().

◆ dwarf2_find_attribute()

static BOOL dwarf2_find_attribute ( const dwarf2_parse_context_t ctx,
const dwarf2_debug_info_t di,
unsigned  at,
struct attribute attr 
)
static

Definition at line 614 of file dwarf.c.

617 {
618  unsigned i, refidx = 0;
619  dwarf2_abbrev_entry_attr_t* abbrev_attr;
620  dwarf2_abbrev_entry_attr_t* ref_abbrev_attr = NULL;
621 
622  attr->gotten_from = attr_direct;
623  while (di)
624  {
625  ref_abbrev_attr = NULL;
626  for (i = 0, abbrev_attr = di->abbrev->attrs; abbrev_attr; i++, abbrev_attr = abbrev_attr->next)
627  {
628  if (abbrev_attr->attribute == at)
629  {
630  dwarf2_fill_attr(ctx, abbrev_attr, di->data[i], attr);
631  return TRUE;
632  }
633  if ((abbrev_attr->attribute == DW_AT_abstract_origin ||
634  abbrev_attr->attribute == DW_AT_specification) &&
635  at != DW_AT_sibling)
636  {
637  if (ref_abbrev_attr)
638  FIXME("two references %lx and %lx\n", ref_abbrev_attr->attribute, abbrev_attr->attribute);
639  ref_abbrev_attr = abbrev_attr;
640  refidx = i;
641  attr->gotten_from = (abbrev_attr->attribute == DW_AT_abstract_origin) ?
643  }
644  }
645  /* do we have either an abstract origin or a specification debug entry to look into ? */
646  if (!ref_abbrev_attr) break;
647  dwarf2_fill_attr(ctx, ref_abbrev_attr, di->data[refidx], attr);
648  if (!(di = sparse_array_find(&ctx->debug_info_table, attr->u.uvalue)))
649  FIXME("Should have found the debug info entry\n");
650  }
651  return FALSE;
652 }
#define TRUE
Definition: types.h:120
unsigned long attribute
Definition: dwarf.c:127
const unsigned char ** data
Definition: dwarf.c:165
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:163
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FIXME(fmt,...)
Definition: debug.h:110
dwarf2_abbrev_entry_attr_t * attrs
Definition: dwarf.c:138
smooth NULL
Definition: ftsmooth.c:416
struct sparse_array debug_info_table
Definition: dwarf.c:203
struct dwarf2_abbrev_entry_attr_s * next
Definition: dwarf.c:129
static void dwarf2_fill_attr(const dwarf2_parse_context_t *ctx, const dwarf2_abbrev_entry_attr_t *abbrev_attr, const unsigned char *data, struct attribute *attr)
Definition: dwarf.c:500
Definition: cookie.c:170
Definition: dwarf.c:125
void * sparse_array_find(const struct sparse_array *sa, unsigned long idx) DECLSPEC_HIDDEN
Definition: storage.c:272

Referenced by dwarf2_compute_location_attr(), dwarf2_get_cpp_name(), dwarf2_get_di_children(), dwarf2_lookup_type(), dwarf2_parse_array_type(), dwarf2_parse_base_type(), dwarf2_parse_compilation_unit(), dwarf2_parse_enumeration_type(), dwarf2_parse_enumerator(), dwarf2_parse_pointer_type(), dwarf2_parse_subprogram(), dwarf2_parse_subprogram_label(), dwarf2_parse_typedef(), dwarf2_parse_udt_member(), dwarf2_parse_udt_type(), dwarf2_parse_unspecified_type(), dwarf2_parse_variable(), dwarf2_read_one_debug_info(), and dwarf2_read_range().

◆ dwarf2_fini_section()

static void dwarf2_fini_section ( dwarf2_section_t section)
inlinestatic

Definition at line 3509 of file dwarf.c.

3510 {
3511  if (section->compressed)
3512  HeapFree(GetProcessHeap(), 0, (void*)section->address);
3513 }
Definition: parser.c:55
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by dwarf2_module_remove(), and dwarf2_parse().

◆ dwarf2_get_addr()

static unsigned long dwarf2_get_addr ( const unsigned char ptr,
unsigned  word_size 
)
static

Definition at line 350 of file dwarf.c.

351 {
352  unsigned long ret;
353 
354  switch (word_size)
355  {
356  case 4:
357  ret = dwarf2_get_u4(ptr);
358  break;
359  case 8:
360  ret = dwarf2_get_u8(ptr);
361  break;
362  default:
363  FIXME("Unsupported Word Size %u\n", word_size);
364  ret = 0;
365  }
366  return ret;
367 }
static unsigned long dwarf2_get_u4(const unsigned char *ptr)
Definition: dwarf.c:249
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
static DWORD64 dwarf2_get_u8(const unsigned char *ptr)
Definition: dwarf.c:261
int ret

Referenced by dwarf2_fill_attr(), dwarf2_lookup_loclist(), and dwarf2_parse_addr().

◆ dwarf2_get_byte()

static unsigned char dwarf2_get_byte ( const unsigned char ptr)
static

Definition at line 225 of file dwarf.c.

226 {
227  return *ptr;
228 }
static PVOID ptr
Definition: dispmode.c:27

Referenced by dwarf2_fill_attr(), dwarf2_get_leb128_as_signed(), dwarf2_get_leb128_as_unsigned(), and dwarf2_parse_byte().

◆ dwarf2_get_cie()

static BOOL dwarf2_get_cie ( unsigned long  addr,
struct module module,
DWORD_PTR  delta,
dwarf2_traverse_context_t fde_ctx,
dwarf2_traverse_context_t cie_ctx,
struct frame_info info,
BOOL  in_eh_frame 
)
static

Definition at line 2729 of file dwarf.c.

2732 {
2733  const unsigned char* ptr_blk;
2734  const unsigned char* cie_ptr;
2735  const unsigned char* last_cie_ptr = (const unsigned char*)~0;
2736  unsigned len, id;
2737  unsigned long start, range;
2738  unsigned cie_id;
2739  const BYTE* start_data = fde_ctx->data;
2740 
2741  cie_id = in_eh_frame ? 0 : DW_CIE_ID;
2742  /* skip 0-padding at beginning of section (alignment) */
2743  while (fde_ctx->data + 2 * 4 < fde_ctx->end_data)
2744  {
2745  if (dwarf2_parse_u4(fde_ctx))
2746  {
2747  fde_ctx->data -= 4;
2748  break;
2749  }
2750  }
2751  for (; fde_ctx->data + 2 * 4 < fde_ctx->end_data; fde_ctx->data = ptr_blk)
2752  {
2753  /* find the FDE for address addr (skip CIE) */
2754  len = dwarf2_parse_u4(fde_ctx);
2755  if (len == 0xffffffff) FIXME("Unsupported yet 64-bit CIEs\n");
2756  ptr_blk = fde_ctx->data + len;
2757  id = dwarf2_parse_u4(fde_ctx);
2758  if (id == cie_id)
2759  {
2760  last_cie_ptr = fde_ctx->data - 8;
2761  /* we need some bits out of the CIE in order to parse all contents */
2762  if (!parse_cie_details(fde_ctx, info)) return FALSE;
2763  cie_ctx->data = fde_ctx->data;
2764  cie_ctx->end_data = ptr_blk;
2765  cie_ctx->word_size = fde_ctx->word_size;
2766  continue;
2767  }
2768  cie_ptr = (in_eh_frame) ? fde_ctx->data - id - 4 : start_data + id;
2769  if (cie_ptr != last_cie_ptr)
2770  {
2771  last_cie_ptr = cie_ptr;
2772  cie_ctx->data = cie_ptr;
2773  cie_ctx->word_size = fde_ctx->word_size;
2774  cie_ctx->end_data = cie_ptr + 4;
2775  cie_ctx->end_data = cie_ptr + 4 + dwarf2_parse_u4(cie_ctx);
2776  if (dwarf2_parse_u4(cie_ctx) != cie_id)
2777  {
2778  FIXME("wrong CIE pointer at %x from FDE %x\n",
2779  (unsigned)(cie_ptr - start_data),
2780  (unsigned)(fde_ctx->data - start_data));
2781  return FALSE;
2782  }
2783  if (!parse_cie_details(cie_ctx, info)) return FALSE;
2784  }
2785  start = delta + dwarf2_parse_augmentation_ptr(fde_ctx, info->fde_encoding);
2786  range = dwarf2_parse_augmentation_ptr(fde_ctx, info->fde_encoding & 0x0F);
2787 
2788  if (addr >= start && addr < start + range)
2789  {
2790  /* reset the FDE context */
2791  fde_ctx->end_data = ptr_blk;
2792 
2793  info->ip = start;
2794  return TRUE;
2795  }
2796  }
2797  return FALSE;
2798 }
#define TRUE
Definition: types.h:120
const unsigned char * data
Definition: dwarf.c:182
static BOOL parse_cie_details(dwarf2_traverse_context_t *ctx, struct frame_info *info)
Definition: dwarf.c:2654
const unsigned char * end_data
Definition: dwarf.c:183
static ULONG_PTR dwarf2_parse_augmentation_ptr(dwarf2_traverse_context_t *ctx, unsigned char encoding)
Definition: dwarf.c:2609
static unsigned long dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:254
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ fcb _In_ chunk _In_ UINT64 start_data
Definition: btrfs_drv.h:1351
#define DW_CIE_ID
Definition: dwarf.h:503
if(!(yy_init))
Definition: macro.lex.yy.c:714
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
GLenum GLint * range
Definition: glext.h:7539
GLuint start
Definition: gl.h:1545
unsigned char word_size
Definition: dwarf.c:184
GLenum GLuint id
Definition: glext.h:5579

Referenced by dwarf2_virtual_unwind().

◆ dwarf2_get_cpp_name()

static const char* dwarf2_get_cpp_name ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di,
const char name 
)
static

Definition at line 984 of file dwarf.c.

985 {
986  char* last;
987  struct attribute diname;
988  struct attribute spec;
989 
990  if (di->abbrev->tag == DW_TAG_compile_unit) return name;
991  if (!ctx->cpp_name)
992  ctx->cpp_name = pool_alloc(&ctx->pool, MAX_SYM_NAME);
993  last = ctx->cpp_name + MAX_SYM_NAME - strlen(name) - 1;
994  strcpy(last, name);
995 
996  /* if the di is a definition, but has also a (previous) declaration, then scope must
997  * be gotten from declaration not definition
998  */
999  if (dwarf2_find_attribute(ctx, di, DW_AT_specification, &spec) && spec.gotten_from == attr_direct)
1000  {
1001  di = sparse_array_find(&ctx->debug_info_table, spec.u.uvalue);
1002  if (!di)
1003  {
1004  FIXME("Should have found the debug info entry\n");
1005  return NULL;
1006  }
1007  }
1008 
1009  for (di = di->parent; di; di = di->parent)
1010  {
1011  switch (di->abbrev->tag)
1012  {
1013  case DW_TAG_namespace:
1014  case DW_TAG_structure_type:
1015  case DW_TAG_class_type:
1016  case DW_TAG_interface_type:
1017  case DW_TAG_union_type:
1018  if (dwarf2_find_attribute(ctx, di, DW_AT_name, &diname))
1019  {
1020  size_t len = strlen(diname.u.string);
1021  last -= 2 + len;
1022  if (last < ctx->cpp_name) return NULL;
1023  memcpy(last, diname.u.string, len);
1024  last[len] = last[len + 1] = ':';
1025  }
1026  break;
1027  default:
1028  break;
1029  }
1030  }
1031  return last;
1032 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
POINT last
Definition: font.c:46
void * pool_alloc(struct pool *a, size_t len) DECLSPEC_HIDDEN
Definition: storage.c:90
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:163
#define FIXME(fmt,...)
Definition: debug.h:110
unsigned long tag
Definition: dwarf.c:135
smooth NULL
Definition: ftsmooth.c:416
struct sparse_array debug_info_table
Definition: dwarf.c:203
#define MAX_SYM_NAME
Definition: compat.h:624
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
struct dwarf2_debug_info_s * parent
Definition: dwarf.c:167
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
Definition: name.c:36
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
struct pool pool
Definition: dwarf.c:198
void * sparse_array_find(const struct sparse_array *sa, unsigned long idx) DECLSPEC_HIDDEN
Definition: storage.c:272
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by dwarf2_parse_subprogram(), dwarf2_parse_udt_type(), and dwarf2_parse_variable().

◆ dwarf2_get_di_children()

static struct vector* dwarf2_get_di_children ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di 
)
static

Definition at line 1159 of file dwarf.c.

1161 {
1162  struct attribute spec;
1163 
1164  while (di)
1165  {
1166  if (di->abbrev->have_child)
1167  return &di->children;
1168  if (!dwarf2_find_attribute(ctx, di, DW_AT_specification, &spec)) break;
1169  if (!(di = sparse_array_find(&ctx->debug_info_table, spec.u.uvalue)))
1170  FIXME("Should have found the debug info entry\n");
1171  }
1172  return NULL;
1173 }
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:163
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
struct sparse_array debug_info_table
Definition: dwarf.c:203
unsigned char have_child
Definition: dwarf.c:136
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
struct vector children
Definition: dwarf.c:166
void * sparse_array_find(const struct sparse_array *sa, unsigned long idx) DECLSPEC_HIDDEN
Definition: storage.c:272

Referenced by dwarf2_parse_array_type(), dwarf2_parse_base_type(), dwarf2_parse_compilation_unit(), dwarf2_parse_const_type(), dwarf2_parse_enumeration_type(), dwarf2_parse_enumerator(), dwarf2_parse_inlined_subroutine(), dwarf2_parse_namespace(), dwarf2_parse_pointer_type(), dwarf2_parse_reference_type(), dwarf2_parse_subprogram(), dwarf2_parse_subprogram_block(), dwarf2_parse_subroutine_type(), dwarf2_parse_typedef(), dwarf2_parse_udt_member(), dwarf2_parse_udt_type(), dwarf2_parse_unspecified_type(), dwarf2_parse_variable(), and dwarf2_parse_volatile_type().

◆ dwarf2_get_leb128_as_signed()

static long dwarf2_get_leb128_as_signed ( const unsigned char ptr,
const unsigned char **  end 
)
static

Definition at line 301 of file dwarf.c.

302 {
303  long ret = 0;
304  unsigned char byte;
305  unsigned shift = 0;
306  const unsigned size = sizeof(int) * 8;
307 
308  do
309  {
310  byte = dwarf2_get_byte(ptr++);
311  ret |= (byte & 0x7f) << shift;
312  shift += 7;
313  } while (byte & 0x80);
314  if (end) *end = ptr;
315 
316  /* as spec: sign bit of byte is 2nd high order bit (80x40)
317  * -> 0x80 is used as flag.
318  */
319  if ((shift < size) && (byte & 0x40))
320  {
321  ret |= - (1 << shift);
322  }
323  return ret;
324 }
#define shift
Definition: input.c:1668
static unsigned char dwarf2_get_byte(const unsigned char *ptr)
Definition: dwarf.c:225
GLuint GLuint end
Definition: gl.h:1545
static PVOID ptr
Definition: dispmode.c:27
GLsizeiptr size
Definition: glext.h:5919
int ret
#define byte(x, n)
Definition: tomcrypt.h:118
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by dwarf2_fill_attr(), and dwarf2_leb128_as_signed().

◆ dwarf2_get_leb128_as_unsigned()

static unsigned long dwarf2_get_leb128_as_unsigned ( const unsigned char ptr,
const unsigned char **  end 
)
static

Definition at line 273 of file dwarf.c.

274 {
275  unsigned long ret = 0;
276  unsigned char byte;
277  unsigned shift = 0;
278 
279  do
280  {
281  byte = dwarf2_get_byte(ptr++);
282  ret |= (byte & 0x7f) << shift;
283  shift += 7;
284  } while (byte & 0x80);
285 
286  if (end) *end = ptr;
287  return ret;
288 }
#define shift
Definition: input.c:1668
static unsigned char dwarf2_get_byte(const unsigned char *ptr)
Definition: dwarf.c:225
GLuint GLuint end
Definition: gl.h:1545
static PVOID ptr
Definition: dispmode.c:27
int ret
#define byte(x, n)
Definition: tomcrypt.h:118

Referenced by dwarf2_fill_attr(), and dwarf2_leb128_as_unsigned().

◆ dwarf2_get_u2()

static unsigned short dwarf2_get_u2 ( const unsigned char ptr)
static

Definition at line 237 of file dwarf.c.

238 {
239  return *(const UINT16*)ptr;
240 }
static PVOID ptr
Definition: dispmode.c:27
unsigned short UINT16

Referenced by dwarf2_fill_attr(), dwarf2_lookup_loclist(), and dwarf2_parse_u2().

◆ dwarf2_get_u4()

static unsigned long dwarf2_get_u4 ( const unsigned char ptr)
static

Definition at line 249 of file dwarf.c.

250 {
251  return *(const UINT32*)ptr;
252 }
unsigned int UINT32
static PVOID ptr
Definition: dispmode.c:27

Referenced by dwarf2_fill_attr(), dwarf2_get_addr(), and dwarf2_parse_u4().

◆ dwarf2_get_u8()

static DWORD64 dwarf2_get_u8 ( const unsigned char ptr)
static

Definition at line 261 of file dwarf.c.

262 {
263  return *(const UINT64*)ptr;
264 }
static PVOID ptr
Definition: dispmode.c:27
unsigned long long UINT64

Referenced by dwarf2_fill_attr(), dwarf2_get_addr(), and dwarf2_parse_u8().

◆ dwarf2_init_section()

static BOOL dwarf2_init_section ( dwarf2_section_t section,
struct image_file_map fmap,
const char sectname,
const char zsectname,
struct image_section_map ism 
)
inlinestatic

Definition at line 3476 of file dwarf.c.

3479 {
3480  struct image_section_map local_ism;
3481 
3482  if (!ism) ism = &local_ism;
3483 
3484  section->compressed = FALSE;
3485  if (image_find_section(fmap, sectname, ism))
3486  {
3487  section->address = (const BYTE*)image_map_section(ism);
3488  section->size = image_get_map_size(ism);
3489  section->rva = image_get_map_rva(ism);
3490  return TRUE;
3491  }
3492 
3493  section->address = NULL;
3494  section->size = 0;
3495  section->rva = 0;
3496 
3497  if (zsectname && image_find_section(fmap, zsectname, ism))
3498  {
3499 #ifdef HAVE_ZLIB
3500  return dwarf2_init_zsection(section, zsectname, ism);
3501 #else
3502  FIXME("dbghelp not built with zlib, but compressed section found\n" );
3503 #endif
3504  }
3505 
3506  return FALSE;
3507 }
#define TRUE
Definition: types.h:120
struct image_file_map * fmap
Definition: parser.c:55
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static unsigned image_get_map_size(const struct image_section_map *ism)
unsigned char BYTE
Definition: mem.h:68
static BOOL image_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism)
static const char * image_map_section(struct image_section_map *ism)
static DWORD_PTR image_get_map_rva(const struct image_section_map *ism)

Referenced by dwarf2_parse().

◆ dwarf2_leb128_as_signed()

static long dwarf2_leb128_as_signed ( dwarf2_traverse_context_t ctx)
static

Definition at line 326 of file dwarf.c.

327 {
328  long ret = 0;
329 
330  assert(ctx);
331 
332  ret = dwarf2_get_leb128_as_signed(ctx->data, &ctx->data);
333  return ret;
334 }
const unsigned char * data
Definition: dwarf.c:182
#define assert(x)
Definition: debug.h:53
static long dwarf2_get_leb128_as_signed(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:301
int ret

Referenced by compute_location(), dwarf2_parse_augmentation_ptr(), dwarf2_parse_line_numbers(), eval_expression(), execute_cfa_instructions(), and parse_cie_details().

◆ dwarf2_leb128_as_unsigned()

static unsigned long dwarf2_leb128_as_unsigned ( dwarf2_traverse_context_t ctx)
static

Definition at line 290 of file dwarf.c.

291 {
292  unsigned long ret;
293 
294  assert(ctx);
295 
297 
298  return ret;
299 }
const unsigned char * data
Definition: dwarf.c:182
#define assert(x)
Definition: debug.h:53
int ret
static unsigned long dwarf2_get_leb128_as_unsigned(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:273

Referenced by compute_location(), dwarf2_parse_abbrev_set(), dwarf2_parse_augmentation_ptr(), dwarf2_parse_line_numbers(), dwarf2_read_one_debug_info(), dwarf2_swallow_attribute(), dwarf2_virtual_unwind(), eval_expression(), execute_cfa_instructions(), and parse_cie_details().

◆ dwarf2_leb128_length()

static unsigned dwarf2_leb128_length ( const dwarf2_traverse_context_t ctx)
static

Definition at line 336 of file dwarf.c.

337 {
338  unsigned ret;
339  for (ret = 0; ctx->data[ret] & 0x80; ret++);
340  return ret + 1;
341 }
const unsigned char * data
Definition: dwarf.c:182
int ret

Referenced by dwarf2_swallow_attribute().

◆ dwarf2_load_one_entry()

static void dwarf2_load_one_entry ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di 
)
static

Definition at line 2105 of file dwarf.c.

2107 {
2108  switch (di->abbrev->tag)
2109  {
2110  case DW_TAG_typedef:
2111  dwarf2_parse_typedef(ctx, di);
2112  break;
2113  case DW_TAG_base_type:
2114  dwarf2_parse_base_type(ctx, di);
2115  break;
2116  case DW_TAG_pointer_type:
2117  dwarf2_parse_pointer_type(ctx, di);
2118  break;
2119  case DW_TAG_class_type:
2120  dwarf2_parse_udt_type(ctx, di, UdtClass);
2121  break;
2122  case DW_TAG_structure_type:
2123  dwarf2_parse_udt_type(ctx, di, UdtStruct);
2124  break;
2125  case DW_TAG_union_type:
2126  dwarf2_parse_udt_type(ctx, di, UdtUnion);
2127  break;
2128  case DW_TAG_array_type:
2129  dwarf2_parse_array_type(ctx, di);
2130  break;
2131  case DW_TAG_const_type:
2132  dwarf2_parse_const_type(ctx, di);
2133  break;
2134  case DW_TAG_volatile_type:
2135  dwarf2_parse_volatile_type(ctx, di);
2136  break;
2139  break;
2140  case DW_TAG_reference_type:
2141  dwarf2_parse_reference_type(ctx, di);
2142  break;
2145  break;
2146  case DW_TAG_subprogram:
2147  dwarf2_parse_subprogram(ctx, di);
2148  break;
2151  break;
2152  case DW_TAG_variable:
2153  {
2154  dwarf2_subprogram_t subpgm;
2155 
2156  subpgm.ctx = ctx;
2157  subpgm.func = NULL;
2158  subpgm.frame.kind = loc_absolute;
2159  subpgm.frame.offset = 0;
2160  subpgm.frame.reg = Wine_DW_no_register;
2161  dwarf2_parse_variable(&subpgm, NULL, di);
2162  }
2163  break;
2164  case DW_TAG_namespace:
2165  dwarf2_parse_namespace(ctx, di);
2166  break;
2167  /* silence a couple of C++ defines */
2171  break;
2172  default:
2173  FIXME("Unhandled Tag type 0x%lx at %s, for %lu\n",
2174  di->abbrev->tag, dwarf2_debug_ctx(ctx), di->abbrev->entry_code);
2175  }
2176 }
struct location frame
Definition: dwarf.c:1594
static struct symt * dwarf2_parse_pointer_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1248
dwarf2_parse_context_t * ctx
Definition: dwarf.c:1591
unsigned long entry_code
Definition: dwarf.c:134
static struct symt * dwarf2_parse_udt_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, enum UdtKind udt)
Definition: dwarf.c:1456
static struct symt * dwarf2_parse_enumeration_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *entry)
Definition: dwarf.c:1542
static void dwarf2_parse_variable(dwarf2_subprogram_t *subpgm, struct symt_block *block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1602
static struct symt * dwarf2_parse_base_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1175
static struct symt * dwarf2_parse_volatile_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1337
#define Wine_DW_no_register
Definition: dwarf.c:656
static struct symt * dwarf2_parse_typedef(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1229
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:163
static struct symt * dwarf2_parse_unspecified_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1357
static void dwarf2_parse_namespace(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:2084
#define FIXME(fmt,...)
Definition: debug.h:110
static struct symt * dwarf2_parse_array_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1269
unsigned long tag
Definition: dwarf.c:135
smooth NULL
Definition: ftsmooth.c:416
static struct symt * dwarf2_parse_const_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1317
static struct symt * dwarf2_parse_subroutine_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:2042
static struct symt * dwarf2_parse_subprogram(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1904
struct symt_function * func
Definition: dwarf.c:1592
static struct symt * dwarf2_parse_reference_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1382
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381

Referenced by dwarf2_lookup_type(), dwarf2_parse_compilation_unit(), and dwarf2_parse_namespace().

◆ dwarf2_location_compute()

static void dwarf2_location_compute ( struct process pcs,
const struct module_format modfmt,
const struct symt_function func,
struct location loc 
)
static

Definition at line 3330 of file dwarf.c.

3334 {
3335  struct location frame;
3336  DWORD_PTR ip;
3337  int err;
3339 
3340  if (!func->container || func->container->tag != SymTagCompiland)
3341  {
3342  WARN("We'd expect function %s's container to exist and be a compiland\n", func->hash_elt.name);
3344  }
3345  else
3346  {
3347  /* instruction pointer relative to compiland's start */
3348  ip = pcs->ctx_frame.InstructionOffset - ((struct symt_compiland*)func->container)->address;
3349 
3350  if ((err = loc_compute_frame(pcs, modfmt, func, ip, &frame)) == 0)
3351  {
3352  switch (loc->kind)
3353  {
3355  /* Then, if the variable has a location list, find it !! */
3356  if (dwarf2_lookup_loclist(modfmt,
3357  modfmt->u.dwarf2_info->debug_loc.address + loc->offset,
3358  ip, &lctx))
3359  goto do_compute;
3361  break;
3362  case loc_dwarf2_block:
3363  /* or if we have a copy of an existing block, get ready for it */
3364  {
3365  unsigned* ptr = (unsigned*)loc->offset;
3366 
3367  lctx.data = (const BYTE*)(ptr + 1);
3368  lctx.end_data = lctx.data + *ptr;
3369  lctx.word_size = modfmt->u.dwarf2_info->word_size;
3370  }
3371  do_compute:
3372  /* now get the variable */
3373  err = compute_location(&lctx, loc, pcs->handle, &frame);
3374  break;
3375  case loc_register:
3376  case loc_regrel:
3377  /* nothing to do */
3378  break;
3379  default:
3380  WARN("Unsupported local kind %d\n", loc->kind);
3382  }
3383  }
3384  }
3385  if (err < 0)
3386  {
3387  loc->kind = loc_register;
3388  loc->reg = err;
3389  }
3390 }
GLenum func
Definition: glext.h:6028
static enum location_error compute_location(dwarf2_traverse_context_t *ctx, struct location *loc, HANDLE hproc, const struct location *frame)
Definition: dwarf.c:669
const unsigned char * data
Definition: dwarf.c:182
#define WARN(fmt,...)
Definition: debug.h:111
static BOOL dwarf2_lookup_loclist(const struct module_format *modfmt, const BYTE *start, unsigned long ip, dwarf2_traverse_context_t *lctx)
Definition: dwarf.c:2494
const unsigned char * end_data
Definition: dwarf.c:183
union module_format::@356 u
IMAGEHLP_STACK_FRAME ctx_frame
static enum location_error loc_compute_frame(struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, DWORD_PTR ip, struct location *frame)
Definition: dwarf.c:2521
static PVOID ptr
Definition: dispmode.c:27
int ip[4]
Definition: rtl.c:1176
Definition: dhcpd.h:61
#define loc_dwarf2_block
Definition: dwarf.c:220
struct dwarf2_module_info_s * dwarf2_info
unsigned reg
ULONG64 InstructionOffset
Definition: compat.h:1017
unsigned char BYTE
Definition: mem.h:68
#define err(...)
uint32_t DWORD_PTR
Definition: typedefs.h:63
unsigned kind
unsigned long offset
unsigned char word_size
Definition: dwarf.c:184
HANDLE handle
#define loc_dwarf2_location_list
Definition: dwarf.c:219

Referenced by dwarf2_parse().

◆ dwarf2_lookup_loclist()

static BOOL dwarf2_lookup_loclist ( const struct module_format modfmt,
const BYTE start,
unsigned long  ip,
dwarf2_traverse_context_t lctx 
)
static

Definition at line 2494 of file dwarf.c.

2496 {
2497  DWORD_PTR beg, end;
2498  const BYTE* ptr = start;
2499  DWORD len;
2500 
2501  while (ptr < modfmt->u.dwarf2_info->debug_loc.address + modfmt->u.dwarf2_info->debug_loc.size)
2502  {
2503  beg = dwarf2_get_addr(ptr, modfmt->u.dwarf2_info->word_size); ptr += modfmt->u.dwarf2_info->word_size;
2504  end = dwarf2_get_addr(ptr, modfmt->u.dwarf2_info->word_size); ptr += modfmt->u.dwarf2_info->word_size;
2505  if (!beg && !end) break;
2506  len = dwarf2_get_u2(ptr); ptr += 2;
2507 
2508  if (beg <= ip && ip < end)
2509  {
2510  lctx->data = ptr;
2511  lctx->end_data = ptr + len;
2512  lctx->word_size = modfmt->u.dwarf2_info->word_size;
2513  return TRUE;
2514  }
2515  ptr += len;
2516  }
2517  WARN("Couldn't find ip in location list\n");
2518  return FALSE;
2519 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define TRUE
Definition: types.h:120
static unsigned long dwarf2_get_addr(const unsigned char *ptr, unsigned word_size)
Definition: dwarf.c:350
const unsigned char * data
Definition: dwarf.c:182
#define WARN(fmt,...)
Definition: debug.h:111
GLuint GLuint end
Definition: gl.h:1545
const unsigned char * end_data
Definition: dwarf.c:183
union module_format::@356 u
static PVOID ptr
Definition: dispmode.c:27
Definition: dhcpd.h:61
unsigned long DWORD
Definition: ntddk_ex.h:95
struct dwarf2_module_info_s * dwarf2_info
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
static unsigned short dwarf2_get_u2(const unsigned char *ptr)
Definition: dwarf.c:237
uint32_t DWORD_PTR
Definition: typedefs.h:63
GLuint start
Definition: gl.h:1545
unsigned char word_size
Definition: dwarf.c:184

Referenced by dwarf2_location_compute(), and loc_compute_frame().

◆ dwarf2_lookup_type()

static struct symt* dwarf2_lookup_type ( dwarf2_parse_context_t ctx,
const dwarf2_debug_info_t di 
)
static

Definition at line 961 of file dwarf.c.

963 {
964  struct attribute attr;
966 
967  if (!dwarf2_find_attribute(ctx, di, DW_AT_type, &attr))
968  return NULL;
969  if (!(type = sparse_array_find(&ctx->debug_info_table, attr.u.uvalue)))
970  {
971  FIXME("Unable to find back reference to type %lx\n", attr.u.uvalue);
972  return NULL;
973  }
974  if (!type->symt)
975  {
976  /* load the debug info entity */
978  if (!type->symt)
979  FIXME("Unable to load forward reference for tag %lx\n", type->abbrev->tag);
980  }
981  return type->symt;
982 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static void dwarf2_load_one_entry(dwarf2_parse_context_t *, dwarf2_debug_info_t *)
Definition: dwarf.c:2105
struct sparse_array debug_info_table
Definition: dwarf.c:203
Definition: cookie.c:170
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
void * sparse_array_find(const struct sparse_array *sa, unsigned long idx) DECLSPEC_HIDDEN
Definition: storage.c:272

Referenced by dwarf2_parse_array_type(), dwarf2_parse_const_type(), dwarf2_parse_pointer_type(), dwarf2_parse_reference_type(), dwarf2_parse_subprogram(), dwarf2_parse_subroutine_type(), dwarf2_parse_typedef(), dwarf2_parse_udt_member(), dwarf2_parse_variable(), and dwarf2_parse_volatile_type().

◆ dwarf2_map_register()

static unsigned dwarf2_map_register ( int  regno)
static

Definition at line 658 of file dwarf.c.

659 {
660  if (regno == Wine_DW_no_register)
661  {
662  FIXME("What the heck map reg 0x%x\n",regno);
663  return 0;
664  }
665  return dbghelp_current_cpu->map_dwarf_register(regno, FALSE);
666 }
struct cpu * dbghelp_current_cpu
Definition: dbghelp.c:150
#define Wine_DW_no_register
Definition: dwarf.c:656
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by compute_location().

◆ dwarf2_module_remove()

static void dwarf2_module_remove ( struct process pcs,
struct module_format modfmt 
)
static

Definition at line 3515 of file dwarf.c.

3516 {
3517  dwarf2_fini_section(&modfmt->u.dwarf2_info->debug_loc);
3518  dwarf2_fini_section(&modfmt->u.dwarf2_info->debug_frame);
3519  HeapFree(GetProcessHeap(), 0, modfmt);
3520 }
union module_format::@356 u
#define GetProcessHeap()
Definition: compat.h:395
static void dwarf2_fini_section(dwarf2_section_t *section)
Definition: dwarf.c:3509
struct dwarf2_module_info_s * dwarf2_info
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by dwarf2_parse().

◆ dwarf2_parse()

BOOL dwarf2_parse ( struct module module,
unsigned long  load_offset,
const struct elf_thunk_area *  thunks,
struct image_file_map fmap 
)

Definition at line 3522 of file dwarf.c.

3525 {
3527  dwarf2_traverse_context_t mod_ctx;
3528  struct image_section_map debug_sect, debug_str_sect, debug_abbrev_sect,
3529  debug_line_sect, debug_ranges_sect, eh_frame_sect;
3530  BOOL ret = TRUE;
3531  struct module_format* dwarf2_modfmt;
3532 
3533  dwarf2_init_section(&eh_frame, fmap, ".eh_frame", NULL, &eh_frame_sect);
3534  dwarf2_init_section(&section[section_debug], fmap, ".debug_info", ".zdebug_info", &debug_sect);
3535  dwarf2_init_section(&section[section_abbrev], fmap, ".debug_abbrev", ".zdebug_abbrev", &debug_abbrev_sect);
3536  dwarf2_init_section(&section[section_string], fmap, ".debug_str", ".zdebug_str", &debug_str_sect);
3537  dwarf2_init_section(&section[section_line], fmap, ".debug_line", ".zdebug_line", &debug_line_sect);
3538  dwarf2_init_section(&section[section_ranges], fmap, ".debug_ranges", ".zdebug_ranges", &debug_ranges_sect);
3539 
3540  /* to do anything useful we need either .eh_frame or .debug_info */
3541  if ((!eh_frame.address || eh_frame.address == IMAGE_NO_MAP) &&
3542  (!section[section_debug].address || section[section_debug].address == IMAGE_NO_MAP))
3543  {
3544  ret = FALSE;
3545  goto leave;
3546  }
3547 
3548  if (fmap->modtype == DMT_ELF && debug_sect.fmap)
3549  {
3550  /* debug info might have a different base address than .so file
3551  * when elf file is prelinked after splitting off debug info
3552  * adjust symbol base addresses accordingly
3553  */
3554  load_offset += fmap->u.elf.elf_start - debug_sect.fmap->u.elf.elf_start;
3555  }
3556 
3557  TRACE("Loading Dwarf2 information for %s\n", debugstr_w(module->module.ModuleName));
3558 
3559  mod_ctx.data = section[section_debug].address;
3560  mod_ctx.end_data = mod_ctx.data + section[section_debug].size;
3561  mod_ctx.word_size = 0; /* will be correctly set later on */
3562 
3563  dwarf2_modfmt = HeapAlloc(GetProcessHeap(), 0,
3564  sizeof(*dwarf2_modfmt) + sizeof(*dwarf2_modfmt->u.dwarf2_info));
3565  if (!dwarf2_modfmt)
3566  {
3567  ret = FALSE;
3568  goto leave;
3569  }
3570  dwarf2_modfmt->module = module;
3571  dwarf2_modfmt->remove = dwarf2_module_remove;
3572  dwarf2_modfmt->loc_compute = dwarf2_location_compute;
3573  dwarf2_modfmt->u.dwarf2_info = (struct dwarf2_module_info_s*)(dwarf2_modfmt + 1);
3574  dwarf2_modfmt->u.dwarf2_info->word_size = 0; /* will be correctly set later on */
3575  dwarf2_modfmt->module->format_info[DFI_DWARF] = dwarf2_modfmt;
3576 
3577  /* As we'll need later some sections' content, we won't unmap these
3578  * sections upon existing this function
3579  */
3580  dwarf2_init_section(&dwarf2_modfmt->u.dwarf2_info->debug_loc, fmap, ".debug_loc", ".zdebug_loc", NULL);
3581  dwarf2_init_section(&dwarf2_modfmt->u.dwarf2_info->debug_frame, fmap, ".debug_frame", ".zdebug_frame", NULL);
3582  dwarf2_modfmt->u.dwarf2_info->eh_frame = eh_frame;
3583 
3584  while (mod_ctx.data < mod_ctx.end_data)
3585  {
3586  dwarf2_parse_compilation_unit(section, dwarf2_modfmt->module, thunks, &mod_ctx, load_offset);
3587  }
3588  dwarf2_modfmt->module->module.SymType = SymDia;
3589  dwarf2_modfmt->module->module.CVSig = 'D' | ('W' << 8) | ('A' << 16) | ('R' << 24);
3590  /* FIXME: we could have a finer grain here */
3591  dwarf2_modfmt->module->module.GlobalSymbols = TRUE;
3592  dwarf2_modfmt->module->module.TypeInfo = TRUE;
3593  dwarf2_modfmt->module->module.SourceIndexed = TRUE;
3594  dwarf2_modfmt->module->module.Publics = TRUE;
3595 
3596  /* set the word_size for eh_frame parsing */
3597  dwarf2_modfmt->u.dwarf2_info->word_size = fmap->addr_size / 8;
3598 
3599 leave:
3605 
3606  image_unmap_section(&debug_sect);
3607  image_unmap_section(&debug_abbrev_sect);
3608  image_unmap_section(&debug_str_sect);
3609  image_unmap_section(&debug_line_sect);
3610  image_unmap_section(&debug_ranges_sect);
3611  if (!ret) image_unmap_section(&eh_frame_sect);
3612 
3613  return ret;
3614 }
union image_file_map::@363 u
void(* remove)(struct process *pcs, struct module_format *modfmt)
unsigned addr_size
Definition: image_private.h:90
enum module_type modtype
Definition: image_private.h:89
const unsigned char * address
Definition: dwarf.c:173
#define TRUE
Definition: types.h:120
HMODULE module
Definition: main.cpp:47
static BOOL dwarf2_init_section(dwarf2_section_t *section, struct image_file_map *fmap, const char *sectname, const char *zsectname, struct image_section_map *ism)
Definition: dwarf.c:3476
Definition: compat.h:712
WCHAR ModuleName[32]
Definition: compat.h:725
const unsigned char * data
Definition: dwarf.c:182
const unsigned char * end_data
Definition: dwarf.c:183
Definition: parser.c:55
union module_format::@356 u
#define IMAGE_NO_MAP
Definition: image_private.h:59
struct image_file_map::@363::elf_file_map elf
static void dwarf2_module_remove(struct process *pcs, struct module_format *modfmt)
Definition: dwarf.c:3515
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void(* loc_compute)(struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
static BOOL dwarf2_parse_compilation_unit(const dwarf2_section_t *sections, struct module *module, const struct elf_thunk_area *thunks, dwarf2_traverse_context_t *mod_ctx, unsigned long load_offset)
Definition: dwarf.c:2385
static void dwarf2_fini_section(dwarf2_section_t *section)
Definition: dwarf.c:3509
struct dwarf2_module_info_s * dwarf2_info
int ret
static void image_unmap_section(struct image_section_map *ism)
dwarf2_section_t eh_frame
Definition: dwarf.c:215
struct module * module
static void dwarf2_location_compute(struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
Definition: dwarf.c:3330
unsigned char word_size
Definition: dwarf.c:184
IMAGEHLP_MODULEW64 module

Referenced by pe_load_dwarf().

◆ dwarf2_parse_abbrev_set()

static void dwarf2_parse_abbrev_set ( dwarf2_traverse_context_t abbrev_ctx,
struct sparse_array abbrev_table,
struct pool pool 
)
static

Definition at line 401 of file dwarf.c.

404 {
405  unsigned long entry_code;
406  dwarf2_abbrev_entry_t* abbrev_entry;
409  unsigned long attribute;
410  unsigned long form;
411 
412  assert( NULL != abbrev_ctx );
413 
414  TRACE("%s, end at %p\n",
415  dwarf2_debug_traverse_ctx(abbrev_ctx), abbrev_ctx->end_data);
416 
417  sparse_array_init(abbrev_table, sizeof(dwarf2_abbrev_entry_t), 32);
418  while (abbrev_ctx->data < abbrev_ctx->end_data)
419  {
420  TRACE("now at %s\n", dwarf2_debug_traverse_ctx(abbrev_ctx));
421  entry_code = dwarf2_leb128_as_unsigned(abbrev_ctx);
422  TRACE("found entry_code %lu\n", entry_code);
423  if (!entry_code)
424  {
425  TRACE("NULL entry code at %s\n", dwarf2_debug_traverse_ctx(abbrev_ctx));
426  break;
427  }
428  abbrev_entry = sparse_array_add(abbrev_table, entry_code, pool);
429  assert( NULL != abbrev_entry );
430 
431  abbrev_entry->entry_code = entry_code;
432  abbrev_entry->tag = dwarf2_leb128_as_unsigned(abbrev_ctx);
433  abbrev_entry->have_child = dwarf2_parse_byte(abbrev_ctx);
434  abbrev_entry->attrs = NULL;
435  abbrev_entry->num_attr = 0;
436 
437  TRACE("table:(%p,#%u) entry_code(%lu) tag(0x%lx) have_child(%u) -> %p\n",
438  abbrev_table, sparse_array_length(abbrev_table),
439  entry_code, abbrev_entry->tag, abbrev_entry->have_child, abbrev_entry);
440 
441  last = NULL;
442  while (1)
443  {
444  attribute = dwarf2_leb128_as_unsigned(abbrev_ctx);
445  form = dwarf2_leb128_as_unsigned(abbrev_ctx);
446  if (!attribute) break;
447 
449  assert(new);
450 
451  new->attribute = attribute;
452  new->form = form;
453  new->next = NULL;
454  if (abbrev_entry->attrs) last->next = new;
455  else abbrev_entry->attrs = new;
456  last = new;
457  abbrev_entry->num_attr++;
458  }
459  }
460  TRACE("found %u entries\n", sparse_array_length(abbrev_table));
461 }
unsigned num_attr
Definition: dwarf.c:137
unsigned long entry_code
Definition: dwarf.c:134
const unsigned char * data
Definition: dwarf.c:182
POINT last
Definition: font.c:46
int form
Definition: main.c:89
#define assert(x)
Definition: debug.h:53
static unsigned long dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:290
const unsigned char * end_data
Definition: dwarf.c:183
void * pool_alloc(struct pool *a, size_t len) DECLSPEC_HIDDEN
Definition: storage.c:90
static unsigned char dwarf2_parse_byte(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:230
dwarf2_abbrev_entry_attr_t * attrs
Definition: dwarf.c:138
unsigned long tag
Definition: dwarf.c:135
smooth NULL
Definition: ftsmooth.c:416
Definition: dwarf.c:132
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char have_child
Definition: dwarf.c:136
void sparse_array_init(struct sparse_array *sa, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:214
unsigned long form
Definition: dwarf.c:149
unsigned sparse_array_length(const struct sparse_array *sa) DECLSPEC_HIDDEN
Definition: storage.c:315
void * sparse_array_add(struct sparse_array *sa, unsigned long key, struct pool *pool) DECLSPEC_HIDDEN
Definition: storage.c:282
static const char * dwarf2_debug_traverse_ctx(const dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:376
Definition: dwarf.c:125

Referenced by dwarf2_parse_compilation_unit().

◆ dwarf2_parse_addr()

static unsigned long dwarf2_parse_addr ( dwarf2_traverse_context_t ctx)
static

Definition at line 369 of file dwarf.c.

370 {
371  unsigned long ret = dwarf2_get_addr(ctx->data, ctx->word_size);
372  ctx->data += ctx->word_size;
373  return ret;
374 }
static unsigned long dwarf2_get_addr(const unsigned char *ptr, unsigned word_size)
Definition: dwarf.c:350
const unsigned char * data
Definition: dwarf.c:182
int ret
unsigned char word_size
Definition: dwarf.c:184

Referenced by compute_location(), dwarf2_parse_augmentation_ptr(), dwarf2_parse_line_numbers(), dwarf2_read_range(), and eval_expression().

◆ dwarf2_parse_array_type()

static struct symt* dwarf2_parse_array_type ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di 
)
static

Definition at line 1269 of file dwarf.c.

1271 {
1272  struct symt* ref_type;
1273  struct symt* idx_type = NULL;
1274  struct attribute min, max, cnt;
1276  unsigned int i;
1277  const struct vector* children;
1278 
1279  if (di->symt) return di->symt;
1280 
1281  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1282 
1283  ref_type = dwarf2_lookup_type(ctx, di);
1284 
1285  if (!(children = dwarf2_get_di_children(ctx, di)))
1286  {
1287  /* fake an array with unknown size */
1288  /* FIXME: int4 even on 64bit machines??? */
1289  idx_type = ctx->symt_cache[sc_int4];
1290  min.u.uvalue = 0;
1291  max.u.uvalue = -1;
1292  }
1293  else for (i = 0; i < vector_length(children); i++)
1294  {
1295  child = *(dwarf2_debug_info_t**)vector_at(children, i);
1296  switch (child->abbrev->tag)
1297  {
1298  case DW_TAG_subrange_type:
1299  idx_type = dwarf2_lookup_type(ctx, child);
1301  min.u.uvalue = 0;
1303  max.u.uvalue = 0;
1304  if (dwarf2_find_attribute(ctx, child, DW_AT_count, &cnt))
1305  max.u.uvalue = min.u.uvalue + cnt.u.uvalue;
1306  break;
1307  default:
1308  FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
1309  child->abbrev->tag, dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1310  break;
1311  }
1312  }
1313  di->symt = &symt_new_array(ctx->module, min.u.uvalue, max.u.uvalue, ref_type, idx_type)->symt;
1314  return di->symt;
1315 }
#define max(a, b)
Definition: svc.c:63
#define sc_int4
Definition: dwarf.c:191
static struct symt * dwarf2_lookup_type(dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di)
Definition: dwarf.c:961
struct symt * symt_cache[sc_num]
Definition: dwarf.c:206
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:163
struct module * module
Definition: dwarf.c:199
static HWND child
Definition: cursoricon.c:298
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
struct symt * symt
Definition: dwarf.c:164
#define TRACE(s)
Definition: solgame.cpp:4
struct symt_array * symt_new_array(struct module *module, int min, int max, struct symt *base, struct symt *index) DECLSPEC_HIDDEN
Definition: type.c:346
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:387
#define min(a, b)
Definition: monoChain.cc:55
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:158

Referenced by dwarf2_load_one_entry(), and dwarf2_parse_udt_type().

◆ dwarf2_parse_augmentation_ptr()

static ULONG_PTR dwarf2_parse_augmentation_ptr ( dwarf2_traverse_context_t ctx,
unsigned char  encoding 
)
static

Definition at line 2609 of file dwarf.c.

2610 {
2611  ULONG_PTR base;
2612 
2613  if (encoding == DW_EH_PE_omit) return 0;
2614 
2615  switch (encoding & 0xf0)
2616  {
2617  case DW_EH_PE_abs:
2618  base = 0;
2619  break;
2620  case DW_EH_PE_pcrel:
2621  base = (ULONG_PTR)ctx->data;
2622  break;
2623  default:
2624  FIXME("unsupported encoding %02x\n", encoding);
2625  return 0;
2626  }
2627 
2628  switch (encoding & 0x0f)
2629  {
2630  case DW_EH_PE_native:
2631  return base + dwarf2_parse_addr(ctx);
2632  case DW_EH_PE_leb128:
2633  return base + dwarf2_leb128_as_unsigned(ctx);
2634  case DW_EH_PE_data2:
2635  return base + dwarf2_parse_u2(ctx);
2636  case DW_EH_PE_data4:
2637  return base + dwarf2_parse_u4(ctx);
2638  case DW_EH_PE_data8:
2639  return base + dwarf2_parse_u8(ctx);
2641  return base + dwarf2_leb128_as_signed(ctx);
2643  return base + (signed short)dwarf2_parse_u2(ctx);
2645  return base + (signed int)dwarf2_parse_u4(ctx);
2647  return base + (LONG64)dwarf2_parse_u8(ctx);
2648  default:
2649  FIXME("unsupported encoding %02x\n", encoding);
2650  return 0;
2651  }
2652 }
const unsigned char * data
Definition: dwarf.c:182
static unsigned long dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:290
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
GLuint base
Definition: 3dtext.c:35
static long dwarf2_leb128_as_signed(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:326
static unsigned long dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:254
#define FIXME(fmt,...)
Definition: debug.h:110
#define DW_EH_PE_signed
Definition: dwarf.h:545
int64_t LONG64
Definition: typedefs.h:66
#define DW_EH_PE_data4
Definition: dwarf.h:543
#define DW_EH_PE_abs
Definition: dwarf.h:546
#define DW_EH_PE_pcrel
Definition: dwarf.h:547
ed encoding
Definition: write.c:2847
static unsigned long dwarf2_parse_addr(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:369
#define DW_EH_PE_omit
Definition: dwarf.h:553
#define DW_EH_PE_native
Definition: dwarf.h:540
static unsigned short dwarf2_parse_u2(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:242
#define DW_EH_PE_data2
Definition: dwarf.h:542
#define DW_EH_PE_leb128
Definition: dwarf.h:541
#define DW_EH_PE_data8
Definition: dwarf.h:544
#define ULONG_PTR
Definition: config.h:101
static DWORD64 dwarf2_parse_u8(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:266
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by dwarf2_get_cie(), dwarf2_virtual_unwind(), eval_expression(), execute_cfa_instructions(), and parse_cie_details().

◆ dwarf2_parse_base_type()

static struct symt* dwarf2_parse_base_type ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di 
)
static

Definition at line 1175 of file dwarf.c.

1177 {
1178  struct attribute name;
1179  struct attribute size;
1180  struct attribute encoding;
1181  enum BasicType bt;
1182  int cache_idx = -1;
1183  if (di->symt) return di->symt;
1184 
1185  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1186 
1187  if (!dwarf2_find_attribute(ctx, di, DW_AT_name, &name))
1188  name.u.string = NULL;
1189  if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &size)) size.u.uvalue = 0;
1190  if (!dwarf2_find_attribute(ctx, di, DW_AT_encoding, &encoding)) encoding.u.uvalue = DW_ATE_void;
1191 
1192  switch (encoding.u.uvalue)
1193  {
1194  case DW_ATE_void: bt = btVoid; break;
1195  case DW_ATE_address: bt = btULong; break;
1196  case DW_ATE_boolean: bt = btBool; break;
1197  case DW_ATE_complex_float: bt = btComplex; break;
1198  case DW_ATE_float: bt = btFloat; break;
1199  case DW_ATE_signed: bt = btInt; break;
1200  case DW_ATE_unsigned: bt = btUInt; break;
1201  case DW_ATE_signed_char: bt = btChar; break;
1202  case DW_ATE_unsigned_char: bt = btChar; break;
1203  default: bt = btNoType; break;
1204  }
1205  di->symt = &symt_new_basic(ctx->module, bt, name.u.string, size.u.uvalue)->symt;
1206  switch (bt)
1207  {
1208  case btVoid:
1209  assert(size.u.uvalue == 0);
1210  cache_idx = sc_void;
1211  break;
1212  case btInt:
1213  switch (size.u.uvalue)
1214  {
1215  case 1: cache_idx = sc_int1; break;
1216  case 2: cache_idx = sc_int2; break;
1217  case 4: cache_idx = sc_int4; break;
1218  }
1219  break;
1220  default: break;
1221  }
1222  if (cache_idx != -1 && !ctx->symt_cache[cache_idx])
1223  ctx->symt_cache[cache_idx] = di->symt;
1224 
1225  if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1226  return di->symt;
1227 }
BasicType
Definition: compat.h:1256
#define sc_int4
Definition: dwarf.c:191
struct symt * symt_cache[sc_num]
Definition: dwarf.c:206
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
struct module * module
Definition: dwarf.c:199
#define assert(x)
Definition: debug.h:53
#define sc_void
Definition: dwarf.c:188
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
struct symt * symt
Definition: dwarf.c:164
struct symt_basic * symt_new_basic(struct module *module, enum BasicType, const char *typename, unsigned size) DECLSPEC_HIDDEN
Definition: type.c:193
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
ed encoding
Definition: write.c:2847
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:387
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
Definition: compat.h:1262
Definition: name.c:36
#define sc_int1
Definition: dwarf.c:189
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381
#define sc_int2
Definition: dwarf.c:190

Referenced by dwarf2_load_one_entry().

◆ dwarf2_parse_byte()

static unsigned char dwarf2_parse_byte ( dwarf2_traverse_context_t ctx)
static

Definition at line 230 of file dwarf.c.

231 {
232  unsigned char uvalue = dwarf2_get_byte(ctx->data);
233  ctx->data += 1;
234  return uvalue;
235 }
const unsigned char * data
Definition: dwarf.c:182
static unsigned char dwarf2_get_byte(const unsigned char *ptr)
Definition: dwarf.c:225
unsigned long uvalue
Definition: dwarf.c:153

Referenced by compute_location(), dwarf2_parse_abbrev_set(), dwarf2_parse_compilation_unit(), dwarf2_parse_line_numbers(), dwarf2_swallow_attribute(), eval_expression(), execute_cfa_instructions(), and parse_cie_details().

◆ dwarf2_parse_compilation_unit()

static BOOL dwarf2_parse_compilation_unit ( const dwarf2_section_t sections,
struct module module,
const struct elf_thunk_area *  thunks,
dwarf2_traverse_context_t mod_ctx,
unsigned long  load_offset 
)
static

Definition at line 2385 of file dwarf.c.

2390 {
2392  dwarf2_traverse_context_t abbrev_ctx;
2393  dwarf2_debug_info_t* di;
2395  const unsigned char* comp_unit_start = mod_ctx->data;
2396  unsigned long cu_length;
2397  unsigned short cu_version;
2398  unsigned long cu_abbrev_offset;
2399  BOOL ret = FALSE;
2400 
2401  cu_length = dwarf2_parse_u4(mod_ctx);
2402  cu_ctx.data = mod_ctx->data;
2403  cu_ctx.end_data = mod_ctx->data + cu_length;
2404  mod_ctx->data += cu_length;
2405  cu_version = dwarf2_parse_u2(&cu_ctx);
2406  cu_abbrev_offset = dwarf2_parse_u4(&cu_ctx);
2407  cu_ctx.word_size = dwarf2_parse_byte(&cu_ctx);
2408 
2409  TRACE("Compilation Unit Header found at 0x%x:\n",
2410  (int)(comp_unit_start - sections[section_debug].address));
2411  TRACE("- length: %lu\n", cu_length);
2412  TRACE("- version: %u\n", cu_version);
2413  TRACE("- abbrev_offset: %lu\n", cu_abbrev_offset);
2414  TRACE("- word_size: %u\n", cu_ctx.word_size);
2415 
2416  if (cu_version != 2)
2417  {
2418  WARN("%u DWARF version unsupported. Wine dbghelp only support DWARF 2.\n",
2419  cu_version);
2420  return FALSE;
2421  }
2422 
2423  module->format_info[DFI_DWARF]->u.dwarf2_info->word_size = cu_ctx.word_size;
2424  mod_ctx->word_size = cu_ctx.word_size;
2425 
2426  pool_init(&ctx.pool, 65536);
2427  ctx.sections = sections;
2428  ctx.section = section_debug;
2429  ctx.module = module;
2430  ctx.thunks = thunks;
2431  ctx.load_offset = load_offset;
2432  ctx.ref_offset = comp_unit_start - sections[section_debug].address;
2433  memset(ctx.symt_cache, 0, sizeof(ctx.symt_cache));
2434  ctx.symt_cache[sc_void] = &symt_new_basic(module, btVoid, "void", 0)->symt;
2435  ctx.cpp_name = NULL;
2436 
2437  abbrev_ctx.data = sections[section_abbrev].address + cu_abbrev_offset;
2438  abbrev_ctx.end_data = sections[section_abbrev].address + sections[section_abbrev].size;
2439  abbrev_ctx.word_size = cu_ctx.word_size;
2440  dwarf2_parse_abbrev_set(&abbrev_ctx, &ctx.abbrev_table, &ctx.pool);
2441 
2443  dwarf2_read_one_debug_info(&ctx, &cu_ctx, NULL, &di);
2444 
2445  if (di->abbrev->tag == DW_TAG_compile_unit)
2446  {
2447  struct attribute name;
2448  struct vector* children;
2450  unsigned int i;
2451  struct attribute stmt_list, low_pc;
2452  struct attribute comp_dir;
2453 
2454  if (!dwarf2_find_attribute(&ctx, di, DW_AT_name, &name))
2455  name.u.string = NULL;
2456 
2457  /* get working directory of current compilation unit */
2458  if (!dwarf2_find_attribute(&ctx, di, DW_AT_comp_dir, &comp_dir))
2459  comp_dir.u.string = NULL;
2460 
2461  if (!dwarf2_find_attribute(&ctx, di, DW_AT_low_pc, &low_pc))
2462  low_pc.u.uvalue = 0;
2463  ctx.compiland = symt_new_compiland(module, ctx.load_offset + low_pc.u.uvalue,
2464  source_new(module, comp_dir.u.string, name.u.string));
2465  di->symt = &ctx.compiland->symt;
2466  children = dwarf2_get_di_children(&ctx, di);
2467  if (children) for (i = 0; i < vector_length(children); i++)
2468  {
2469  child = *(dwarf2_debug_info_t**)vector_at(children, i);
2471  }
2472  if (dwarf2_find_attribute(&ctx, di, DW_AT_stmt_list, &stmt_list))
2473  {
2474 #if defined(__REACTOS__) && defined(__clang__)
2475  unsigned long stmt_list_val = stmt_list.u.uvalue;
2476  if (stmt_list_val > module->module.BaseOfImage)
2477  {
2478  /* FIXME: Clang is recording this as an address, not an offset */
2479  stmt_list_val -= module->module.BaseOfImage + sections[section_line].rva;
2480  }
2481  if (dwarf2_parse_line_numbers(sections, &ctx, comp_dir.u.string, stmt_list_val))
2482 #else
2483  if (dwarf2_parse_line_numbers(sections, &ctx, comp_dir.u.string, stmt_list.u.uvalue))
2484 #endif
2486  }
2487  ret = TRUE;
2488  }
2489  else FIXME("Should have a compilation unit here\n");
2490  pool_destroy(&ctx.pool);
2491  return ret;
2492 }
struct symt_compiland * compiland
Definition: dwarf.c:200
struct sparse_array abbrev_table
Definition: dwarf.c:202
#define TRUE
Definition: types.h:120
HMODULE module
Definition: main.cpp:47
struct symt * symt_cache[sc_num]
Definition: dwarf.c:206
const dwarf2_section_t * sections
Definition: dwarf.c:196
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
const unsigned char * data
Definition: dwarf.c:182
DWORD64 BaseOfImage
Definition: compat.h:719
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:163
#define WARN(fmt,...)
Definition: debug.h:111
struct module * module
Definition: dwarf.c:199
const unsigned char * end_data
Definition: dwarf.c:183
struct symt_compiland * symt_new_compiland(struct module *module, unsigned long address, unsigned src_idx) DECLSPEC_HIDDEN
Definition: symbol.c:209
static HWND child
Definition: cursoricon.c:298
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:163
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static unsigned char dwarf2_parse_byte(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:230
unsigned int BOOL
Definition: ntddk_ex.h:94
struct section sections[2]
Definition: diskspace.c:792
static unsigned long dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:254
#define sc_void
Definition: dwarf.c:188
#define FIXME(fmt,...)
Definition: debug.h:110
unsigned long tag
Definition: dwarf.c:135
smooth NULL
Definition: ftsmooth.c:416
static BOOL dwarf2_read_one_debug_info(dwarf2_parse_context_t *ctx, dwarf2_traverse_context_t *traverse, dwarf2_debug_info_t *parent_di, dwarf2_debug_info_t **pdi)
Definition: dwarf.c:1091
struct symt * symt
Definition: dwarf.c:164
struct symt_basic * symt_new_basic(struct module *module, enum BasicType, const char *typename, unsigned size) DECLSPEC_HIDDEN
Definition: type.c:193
#define TRACE(s)
Definition: solgame.cpp:4
static void dwarf2_load_one_entry(dwarf2_parse_context_t *, dwarf2_debug_info_t *)
Definition: dwarf.c:2105
unsigned long ref_offset
Definition: dwarf.c:205
struct sparse_array debug_info_table
Definition: dwarf.c:203
GLuint address
Definition: glext.h:9393
void sparse_array_init(struct sparse_array *sa, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:214
int ret
void pool_init(struct pool *a, size_t arena_size) DECLSPEC_HIDDEN
Definition: storage.c:44
unsigned section
Definition: dwarf.c:197
unsigned long load_offset
Definition: dwarf.c:204
void pool_destroy(struct pool *a) DECLSPEC_HIDDEN
Definition: storage.c:51
static unsigned short dwarf2_parse_u2(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:242
static void dwarf2_parse_abbrev_set(dwarf2_traverse_context_t *abbrev_ctx, struct sparse_array *abbrev_table, struct pool *pool)
Definition: dwarf.c:401
static BOOL dwarf2_parse_line_numbers(const dwarf2_section_t *sections, dwarf2_parse_context_t *ctx, const char *compile_dir, unsigned long offset)
Definition: dwarf.c:2195
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
unsigned source_new(struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
Definition: source.c:67
Definition: name.c:36
const struct elf_thunk_area * thunks
Definition: dwarf.c:201
unsigned char word_size
Definition: dwarf.c:184
struct pool pool
Definition: dwarf.c:198
#define memset(x, y, z)
Definition: compat.h:39
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:158

Referenced by dwarf2_parse().

◆ dwarf2_parse_const_type()

static struct symt* dwarf2_parse_const_type ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di 
)
static

Definition at line 1317 of file dwarf.c.

1319 {
1320  struct symt* ref_type;
1321 
1322  if (di->symt) return di->symt;
1323 
1324  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1325 
1326  if (!(ref_type = dwarf2_lookup_type(ctx, di)))
1327  {
1328  ref_type = ctx->symt_cache[sc_void];
1329  assert(ref_type);
1330  }
1331  if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1332  di->symt = ref_type;
1333 
1334  return ref_type;
1335 }
static struct symt * dwarf2_lookup_type(dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di)
Definition: dwarf.c:961
struct symt * symt_cache[sc_num]
Definition: dwarf.c:206
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
#define assert(x)
Definition: debug.h:53
#define sc_void
Definition: dwarf.c:188
#define FIXME(fmt,...)
Definition: debug.h:110
struct symt * symt
Definition: dwarf.c:164
#define TRACE(s)
Definition: solgame.cpp:4
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:387
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381

Referenced by dwarf2_load_one_entry(), dwarf2_parse_subprogram(), dwarf2_parse_subprogram_block(), and dwarf2_parse_udt_type().

◆ dwarf2_parse_enumeration_type()

static struct symt * dwarf2_parse_enumeration_type ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t entry 
)
static

Definition at line 1542 of file dwarf.c.

1544 {
1545  struct attribute name;
1546  struct attribute size;
1547  struct symt_basic* basetype;
1548  struct vector* children;
1550  unsigned int i;
1551 
1552  if (di->symt) return di->symt;
1553 
1554  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1555 
1556  if (!dwarf2_find_attribute(ctx, di, DW_AT_name, &name)) name.u.string = NULL;
1557  if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &size)) size.u.uvalue = 4;
1558 
1559  switch (size.u.uvalue) /* FIXME: that's wrong */
1560  {
1561  case 1: basetype = symt_new_basic(ctx->module, btInt, "char", 1); break;
1562  case 2: basetype = symt_new_basic(ctx->module, btInt, "short", 2); break;
1563  default:
1564  case 4: basetype = symt_new_basic(ctx->module, btInt, "int", 4); break;
1565  }
1566 
1567  di->symt = &symt_new_enum(ctx->module, name.u.string, &basetype->symt)->symt;
1568 
1569  children = dwarf2_get_di_children(ctx, di);
1570  /* FIXME: should we use the sibling stuff ?? */
1571  if (children) for (i = 0; i < vector_length(children); i++)
1572  {
1573  child = *(dwarf2_debug_info_t**)vector_at(children, i);
1574 
1575  switch (child->abbrev->tag)
1576  {
1577  case DW_TAG_enumerator:
1578  dwarf2_parse_enumerator(ctx, child, (struct symt_enum*)di->symt);
1579  break;
1580  default:
1581  FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
1582  di->abbrev->tag, dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1583  }
1584  }
1585  return di->symt;
1586 }
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:163
static void dwarf2_parse_enumerator(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, struct symt_enum *parent)
Definition: dwarf.c:1526
struct module * module
Definition: dwarf.c:199
static HWND child
Definition: cursoricon.c:298
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
struct symt_basic * symt_new_basic(struct module *module, enum BasicType, const char *typename, unsigned size) DECLSPEC_HIDDEN
Definition: type.c:193
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
struct symt_enum * symt_new_enum(struct module *module, const char *typename, struct symt *basetype) DECLSPEC_HIDDEN
Definition: type.c:305
struct symt symt
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:387
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
Definition: compat.h:1262
Definition: name.c:36
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:158

Referenced by dwarf2_load_one_entry(), and dwarf2_parse_udt_type().

◆ dwarf2_parse_enumerator()

static void dwarf2_parse_enumerator ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di,
struct symt_enum parent 
)
static

Definition at line 1526 of file dwarf.c.

1529 {
1530  struct attribute name;
1531  struct attribute value;
1532 
1533  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1534 
1535  if (!dwarf2_find_attribute(ctx, di, DW_AT_name, &name)) return;
1536  if (!dwarf2_find_attribute(ctx, di, DW_AT_const_value, &value)) value.u.svalue = 0;
1537  symt_add_enum_element(ctx->module, parent, name.u.string, value.u.svalue);
1538 
1539  if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1540 }
BOOL symt_add_enum_element(struct module *module, struct symt_enum *enum_type, const char *name, int value) DECLSPEC_HIDDEN
Definition: type.c:320
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
union value::@475 u
struct module * module
Definition: dwarf.c:199
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
r parent
Definition: btrfs.c:2708
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:387
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
Definition: name.c:36
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381

Referenced by dwarf2_parse_enumeration_type().

◆ dwarf2_parse_inlined_subroutine()

static void dwarf2_parse_inlined_subroutine ( dwarf2_subprogram_t subpgm,
struct symt_block parent_block,
dwarf2_debug_info_t di 
)
static

Definition at line 1768 of file dwarf.c.

1771 {
1772  struct symt_block* block;
1773  unsigned long low_pc, high_pc;
1774  struct vector* children;
1776  unsigned int i;
1777 
1778  TRACE("%s, for %s\n", dwarf2_debug_ctx(subpgm->ctx), dwarf2_debug_di(di));
1779 
1780  if (!dwarf2_read_range(subpgm->ctx, di, &low_pc, &high_pc))
1781  {
1782  FIXME("cannot read range\n");
1783  return;
1784  }
1785 
1786  block = symt_open_func_block(subpgm->ctx->module, subpgm->func, parent_block,
1787  subpgm->ctx->load_offset + low_pc - subpgm->func->address,
1788  high_pc - low_pc);
1789 
1790  children = dwarf2_get_di_children(subpgm->ctx, di);
1791  if (children) for (i = 0; i < vector_length(children); i++)
1792  {
1793  child = *(dwarf2_debug_info_t**)vector_at(children, i);
1794 
1795  switch (child->abbrev->tag)
1796  {
1798  case DW_TAG_variable:
1799  dwarf2_parse_variable(subpgm, block, child);
1800  break;
1801  case DW_TAG_lexical_block:
1803  break;
1806  break;
1807  case DW_TAG_label:
1809  break;
1810  case DW_TAG_GNU_call_site:
1811  /* this isn't properly supported by dbghelp interface. skip it for now */
1812  break;
1813  default:
1814  FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
1815  child->abbrev->tag, dwarf2_debug_ctx(subpgm->ctx),
1816  dwarf2_debug_di(di));
1817  }
1818  }
1819  symt_close_func_block(subpgm->ctx->module, subpgm->func, block, 0);
1820 }
static unsigned int block
Definition: xmlmemory.c:118
struct symt_block * symt_open_func_block(struct module *module, struct symt_function *func, struct symt_block *block, unsigned pc, unsigned len) DECLSPEC_HIDDEN
Definition: symbol.c:415
dwarf2_parse_context_t * ctx
Definition: dwarf.c:1591
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:163
static BOOL dwarf2_read_range(dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned long *plow, unsigned long *phigh)
Definition: dwarf.c:1041
struct module * module
Definition: dwarf.c:199
static void dwarf2_parse_variable(dwarf2_subprogram_t *subpgm, struct symt_block *block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1602
static HWND child
Definition: cursoricon.c:298
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FIXME(fmt,...)
Definition: debug.h:110
static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t *subpgm, struct symt_block *parent_block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1768
#define TRACE(s)
Definition: solgame.cpp:4
static void dwarf2_parse_subprogram_label(dwarf2_subprogram_t *subpgm, const dwarf2_debug_info_t *di)
Definition: dwarf.c:1742
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:387
unsigned long load_offset
Definition: dwarf.c:204
struct symt_function * func
Definition: dwarf.c:1592
static void dwarf2_parse_subprogram_block(dwarf2_subprogram_t *subpgm, struct symt_block *parent_block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1822
struct symt_block * symt_close_func_block(struct module *module, const struct symt_function *func, struct symt_block *block, unsigned pc) DECLSPEC_HIDDEN
Definition: symbol.c:442
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:158

Referenced by dwarf2_parse_subprogram(), and dwarf2_parse_subprogram_block().

◆ dwarf2_parse_line_numbers()

static BOOL dwarf2_parse_line_numbers ( const dwarf2_section_t sections,
dwarf2_parse_context_t ctx,
const char compile_dir,
unsigned long  offset 
)
static

Definition at line 2195 of file dwarf.c.

2199 {
2200  dwarf2_traverse_context_t traverse;
2201  unsigned long length;
2202  unsigned insn_size, default_stmt;
2203  unsigned line_range, opcode_base;
2204  int line_base;
2205  const unsigned char* opcode_len;
2206  struct vector dirs;
2207  struct vector files;
2208  const char** p;
2209 
2210  /* section with line numbers stripped */
2212  return FALSE;
2213 
2214  if (offset + 4 > sections[section_line].size)
2215  {
2216  WARN("out of bounds offset\n");
2217  return FALSE;
2218  }
2219  traverse.data = sections[section_line].address + offset;
2220  traverse.end_data = traverse.data + 4;
2221  traverse.word_size = ctx->module->format_info[DFI_DWARF]->u.dwarf2_info->word_size;
2222 
2223  length = dwarf2_parse_u4(&traverse);
2224  traverse.end_data = sections[section_line].address + offset + length;
2225 
2226  if (offset + 4 + length > sections[section_line].size)
2227  {
2228  WARN("out of bounds header\n");
2229  return FALSE;
2230  }
2231  dwarf2_parse_u2(&traverse); /* version */
2232  dwarf2_parse_u4(&traverse); /* header_len */
2233  insn_size = dwarf2_parse_byte(&traverse);
2234  default_stmt = dwarf2_parse_byte(&traverse);
2235  line_base = (signed char)dwarf2_parse_byte(&traverse);
2236  line_range = dwarf2_parse_byte(&traverse);
2237  opcode_base = dwarf2_parse_byte(&traverse);
2238 
2239  opcode_len = traverse.data;
2240  traverse.data += opcode_base - 1;
2241 
2242  vector_init(&dirs, sizeof(const char*), 4);
2243  p = vector_add(&dirs, &ctx->pool);
2244  *p = compile_dir ? compile_dir : ".";
2245  while (*traverse.data)
2246  {
2247  const char* rel = (const char*)traverse.data;
2248  unsigned rellen = strlen(rel);
2249  TRACE("Got include %s\n", rel);
2250  traverse.data += rellen + 1;
2251  p = vector_add(&dirs, &ctx->pool);
2252 
2253  if (*rel == '/' || !compile_dir)
2254  *p = rel;
2255  else
2256  {
2257  /* include directory relative to compile directory */
2258  unsigned baselen = strlen(compile_dir);
2259  char* tmp = pool_alloc(&ctx->pool, baselen + 1 + rellen + 1);
2260  strcpy(tmp, compile_dir);
2261  if (tmp[baselen - 1] != '/') tmp[baselen++] = '/';
2262  strcpy(&tmp[baselen], rel);
2263  *p = tmp;
2264  }
2265 
2266  }
2267  traverse.data++;
2268 
2269  vector_init(&files, sizeof(unsigned), 16);
2270  while (*traverse.data)
2271  {
2272  unsigned int dir_index, mod_time;
2273  const char* name;
2274  const char* dir;
2275  unsigned* psrc;
2276 
2277  name = (const char*)traverse.data;
2278  traverse.data += strlen(name) + 1;
2279  dir_index = dwarf2_leb128_as_unsigned(&traverse);
2280  mod_time = dwarf2_leb128_as_unsigned(&traverse);
2281  length = dwarf2_leb128_as_unsigned(&traverse);
2282  dir = *(const char**)vector_at(&dirs, dir_index);
2283  TRACE("Got file %s/%s (%u,%lu)\n", dir, name, mod_time, length);
2284  psrc = vector_add(&files, &ctx->pool);
2285  *psrc = source_new(ctx->module, dir, name);
2286  }
2287  traverse.data++;
2288 
2289  while (traverse.data < traverse.end_data)
2290  {
2291  unsigned long address = 0;
2292  unsigned file = 1;
2293  unsigned line = 1;
2294  unsigned is_stmt = default_stmt;
2295  BOOL end_sequence = FALSE;
2296  unsigned opcode, extopcode, i;
2297 
2298  while (!end_sequence)
2299  {
2300  opcode = dwarf2_parse_byte(&traverse);
2301  TRACE("Got opcode %x\n", opcode);
2302 
2303  if (opcode >= opcode_base)
2304  {
2305  unsigned delta = opcode - opcode_base;
2306 
2307  address += (delta / line_range) * insn_size;
2308  line += line_base + (delta % line_range);
2309  dwarf2_set_line_number(ctx->module, address, &files, file, line);
2310  }
2311  else
2312  {
2313  switch (opcode)
2314  {
2315  case DW_LNS_copy:
2316  dwarf2_set_line_number(ctx->module, address, &files, file, line);
2317  break;
2318  case DW_LNS_advance_pc:
2319  address += insn_size * dwarf2_leb128_as_unsigned(&traverse);
2320  break;
2321  case DW_LNS_advance_line:
2322  line += dwarf2_leb128_as_signed(&traverse);
2323  break;
2324  case DW_LNS_set_file:
2325  file = dwarf2_leb128_as_unsigned(&traverse);
2326  break;
2327  case DW_LNS_set_column:
2328  dwarf2_leb128_as_unsigned(&traverse);
2329  break;
2330  case DW_LNS_negate_stmt:
2331  is_stmt = !is_stmt;
2332  break;
2334  break;
2335  case DW_LNS_const_add_pc:
2336  address += ((255 - opcode_base) / line_range) * insn_size;
2337  break;
2339  address += dwarf2_parse_u2(&traverse);
2340  break;
2341  case DW_LNS_extended_op:
2342  dwarf2_leb128_as_unsigned(&traverse);
2343  extopcode = dwarf2_parse_byte(&traverse);
2344  switch (extopcode)
2345  {
2346  case DW_LNE_end_sequence:
2347  dwarf2_set_line_number(ctx->module, address, &files, file, line);
2348  end_sequence = TRUE;
2349  break;
2350  case DW_LNE_set_address:
2351  address = ctx->load_offset + dwarf2_parse_addr(&traverse);
2352  break;
2353  case DW_LNE_define_file:
2354  FIXME("not handled define file %s\n", traverse.data);
2355  traverse.data += strlen((const char *)traverse.data) + 1;
2356  dwarf2_leb128_as_unsigned(&traverse);
2357  dwarf2_leb128_as_unsigned(&traverse);
2358  dwarf2_leb128_as_unsigned(&traverse);
2359  break;
2361  {
2362  unsigned descr;
2363 
2364  descr = dwarf2_leb128_as_unsigned(&traverse);
2365  WARN("not handled discriminator %x\n", descr);
2366  }
2367  break;
2368  default:
2369  FIXME("Unsupported extended opcode %x\n", extopcode);
2370  break;
2371  }
2372  break;
2373  default:
2374  WARN("Unsupported opcode %x\n", opcode);
2375  for (i = 0; i < opcode_len[opcode]; i++)
2376  dwarf2_leb128_as_unsigned(&traverse);
2377  break;
2378  }
2379  }
2380  }
2381  }
2382  return TRUE;
2383 }
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const unsigned char * data
Definition: dwarf.c:182
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:163
#define WARN(fmt,...)
Definition: debug.h:111
GLintptr offset
Definition: glext.h:5920
struct module * module
Definition: dwarf.c:199
static unsigned long dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:290
#define DW_LNE_set_discriminator
Definition: dwarf.h:501
const unsigned char * end_data
Definition: dwarf.c:183
#define IMAGE_NO_MAP
Definition: image_private.h:59
void * pool_alloc(struct pool *a, size_t len) DECLSPEC_HIDDEN
Definition: storage.c:90
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static unsigned char dwarf2_parse_byte(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:230
unsigned int BOOL
Definition: ntddk_ex.h:94
static long dwarf2_leb128_as_signed(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:326
struct section sections[2]
Definition: diskspace.c:792
static unsigned long dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:254
#define FIXME(fmt,...)
Definition: debug.h:110
unsigned char
Definition: typeof.h:29
void vector_init(struct vector *v, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:134
Definition: parser.c:48
unsigned int dir
Definition: maze.c:112
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GLuint address
Definition: glext.h:9393
static unsigned long dwarf2_parse_addr(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:369
static void dwarf2_set_line_number(struct module *module, unsigned long address, const struct vector *v, unsigned file, unsigned line)
Definition: dwarf.c:2178
unsigned long load_offset
Definition: dwarf.c:204
void * vector_add(struct vector *v, struct pool *pool) DECLSPEC_HIDDEN
Definition: storage.c:172
static unsigned short dwarf2_parse_u2(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:242
unsigned source_new(struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
Definition: source.c:67
Definition: name.c:36
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned char word_size
Definition: dwarf.c:184
const char * descr
Definition: boot.c:45
GLfloat GLfloat p
Definition: glext.h:8902
struct pool pool
Definition: dwarf.c:198
Definition: fci.c:126
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by dwarf2_parse_compilation_unit().

◆ dwarf2_parse_namespace()

static void dwarf2_parse_namespace ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di 
)
static

Definition at line 2084 of file dwarf.c.

2086 {
2087  struct vector* children;
2089  unsigned int i;
2090 
2091  if (di->symt) return;
2092 
2093  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
2094 
2095  di->symt = ctx->symt_cache[sc_void];
2096 
2097  children = dwarf2_get_di_children(ctx, di);
2098  if (children) for (i = 0; i < vector_length(children); i++)
2099  {
2100  child = *(dwarf2_debug_info_t**)vector_at(children, i);
2102  }
2103 }
struct symt * symt_cache[sc_num]
Definition: dwarf.c:206
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:163
static HWND child
Definition: cursoricon.c:298
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define sc_void
Definition: dwarf.c:188
struct symt * symt
Definition: dwarf.c:164
#define TRACE(s)
Definition: solgame.cpp:4
static void dwarf2_load_one_entry(dwarf2_parse_context_t *, dwarf2_debug_info_t *)
Definition: dwarf.c:2105
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:387
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:158

Referenced by dwarf2_load_one_entry().

◆ dwarf2_parse_pointer_type()

static struct symt* dwarf2_parse_pointer_type ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di 
)
static

Definition at line 1248 of file dwarf.c.

1250 {
1251  struct symt* ref_type;
1252  struct attribute size;
1253 
1254  if (di->symt) return di->symt;
1255 
1256  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1257 
1258  if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &size)) size.u.uvalue = sizeof(void *);
1259  if (!(ref_type = dwarf2_lookup_type(ctx, di)))
1260  {
1261  ref_type = ctx->symt_cache[sc_void];
1262  assert(ref_type);
1263  }
1264  di->symt = &symt_new_pointer(ctx->module, ref_type, size.u.uvalue)->symt;
1265  if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1266  return di->symt;
1267 }
static struct symt * dwarf2_lookup_type(dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di)
Definition: dwarf.c:961
struct symt * symt_cache[sc_num]
Definition: dwarf.c:206
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
struct module * module
Definition: dwarf.c:199
#define assert(x)
Definition: debug.h:53
#define sc_void
Definition: dwarf.c:188
#define FIXME(fmt,...)
Definition: debug.h:110
struct symt * symt
Definition: dwarf.c:164
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
struct symt_pointer * symt_new_pointer(struct module *module, struct symt *ref_type, unsigned long size) DECLSPEC_HIDDEN
Definition: type.c:415
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:387
static BOOL dwarf2_find_attribute(const dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, unsigned at, struct attribute *attr)
Definition: dwarf.c:614
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381

Referenced by dwarf2_load_one_entry(), dwarf2_parse_subprogram(), and dwarf2_parse_subprogram_block().

◆ dwarf2_parse_reference_type()

static struct symt* dwarf2_parse_reference_type ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di 
)
static

Definition at line 1382 of file dwarf.c.

1384 {
1385  struct symt* ref_type = NULL;
1386 
1387  if (di->symt) return di->symt;
1388 
1389  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1390 
1391  ref_type = dwarf2_lookup_type(ctx, di);
1392  /* FIXME: for now, we hard-wire C++ references to pointers */
1393  di->symt = &symt_new_pointer(ctx->module, ref_type, sizeof(void *))->symt;
1394 
1395  if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1396 
1397  return di->symt;
1398 }
static struct symt * dwarf2_lookup_type(dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di)
Definition: dwarf.c:961
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1159
struct module * module
Definition: dwarf.c:199
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
struct symt * symt
Definition: dwarf.c:164
#define TRACE(s)
Definition: solgame.cpp:4
struct symt_pointer * symt_new_pointer(struct module *module, struct symt *ref_type, unsigned long size) DECLSPEC_HIDDEN
Definition: type.c:415
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:387
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:381

Referenced by dwarf2_load_one_entry().

◆ dwarf2_parse_subprogram()

static struct symt * dwarf2_parse_subprogram ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di 
)
static

Definition at line 1904 of file dwarf.c.

1906 {
1907  struct attribute name;
1908  unsigned long low_pc, high_pc;
1909  struct attribute is_decl;
1910  struct attribute inline_flags;
1911  struct symt* ret_type;
1912  struct symt_function_signature* sig_type;
1913  dwarf2_subprogram_t subpgm;
1914  struct vector* children;
1916  unsigned int i;
1917 
1918  if (di->symt) return di->symt;
1919 
1920  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1921 
1922  if (!dwarf2_find_attribute(ctx, di, DW_AT_name, &name))
1923  {
1924  WARN("No name for function... dropping function\n");
1925  return NULL;
1926  }
1927  /* if it's an abstract representation of an inline function, there should be
1928  * a concrete object that we'll handle
1929  */
1930  if (dwarf2_find_attribute(ctx, di, DW_AT_inline, &inline_flags) &&
1931  inline_flags.u.uvalue != DW_INL_not_inlined)
1932  {
1933  TRACE("Function %s declared as inlined (%ld)... skipping\n",
1934  debugstr_a(name.u.string), inline_flags.u.uvalue);
1935  return NULL;
1936  }
1937 
1938  if (dwarf2_find_attribute(ctx, di, DW_AT_declaration, &is_decl) &&
1939  is_decl.u.uvalue && is_decl.gotten_from == attr_direct)
1940  {
1941  /* it's a real declaration, skip it */
1942  return NULL;
1943  }
1944  if (!dwarf2_read_range(ctx, di, &low_pc, &high_pc))
1945  {
1946  WARN("cannot get range for %s\n", name.u.string);
1947  return NULL;
1948  }
1949  /* As functions (defined as inline assembly) get debug info with dwarf
1950  * (not the case for stabs), we just drop Wine's thunks here...
1951  * Actual thunks will be created in elf_module from the symbol table
1952  */
1953 #ifndef DBGHELP_STATIC_LIB
1954  if (elf_is_in_thunk_area(ctx->load_offset + low_pc, ctx->thunks) >= 0)
1955  return NULL;
1956 #endif
1957  if (!(ret_type = dwarf2_lookup_type(ctx, di)))
1958  {
1959  ret_type = ctx->symt_cache[sc_void];
1960  assert(ret_type);
1961  }
1962  /* FIXME: assuming C source code */
1963  sig_type = symt_new_function_signature(ctx->module, ret_type, CV_CALL_FAR_C);
1964  subpgm.func = symt_new_function(ctx->module, ctx->compiland,
1965  dwarf2_get_cpp_name(ctx, di, name.u.string),
1966  ctx->load_offset + low_pc, high_pc - low_pc,
1967  &sig_type->symt);
1968  di->symt = &subpgm.func->symt;
1969  subpgm.ctx = ctx;
1971  &subpgm.frame, NULL))
1972  {
1973  /* on stack !! */
1974  subpgm.frame.kind = loc_regrel;
1975  subpgm.frame.reg = dbghelp_current_cpu->frame_regno;
1976  subpgm.frame.offset = 0;
1977  }
1978  subpgm.non_computed_variable = FALSE;
1979 
1980  children = dwarf2_get_di_children(ctx, di);
1981  if (children) for (i = 0; i < vector_length(children); i++)
1982  {
1983  child = *(dwarf2_debug_info_t**)vector_at(children, i);
1984 
1985  switch (child->abbrev->tag)
1986  {
1987  case DW_TAG_variable:
1989  dwarf2_parse_variable(&subpgm, NULL, child);
1990  break;
1991  case DW_TAG_lexical_block:
1993  break;
1996  break;
1997  case DW_TAG_pointer_type:
1998  dwarf2_parse_pointer_type(subpgm.ctx, di);
1999  break;
2000  case DW_TAG_const_type:
2001  dwarf2_parse_const_type(subpgm.ctx, di);
2002  break;
2003  case DW_TAG_subprogram:
2004  /* FIXME: likely a declaration (to be checked)
2005  * skip it for now
2006  */
2007  break;
2008  case