ReactOS  0.4.15-dev-1070-ge1a01de
dwarf.c File Reference
#include <sys/types.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 "zlib.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 ULONG_PTR dwarf2_get_u4 (const unsigned char *ptr)
 
static ULONG_PTR 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 ULONG_PTR dwarf2_get_leb128_as_unsigned (const unsigned char *ptr, const unsigned char **end)
 
static ULONG_PTR dwarf2_leb128_as_unsigned (dwarf2_traverse_context_t *ctx)
 
static LONG_PTR dwarf2_get_leb128_as_signed (const unsigned char *ptr, const unsigned char **end)
 
static LONG_PTR dwarf2_leb128_as_signed (dwarf2_traverse_context_t *ctx)
 
static unsigned dwarf2_leb128_length (const dwarf2_traverse_context_t *ctx)
 
static ULONG_PTR dwarf2_get_addr (const unsigned char *ptr, unsigned word_size)
 
static ULONG_PTR 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, ULONG_PTR 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, const struct module *module)
 
static enum location_error compute_location (const struct module *module, 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, ULONG_PTR 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, ULONG_PTR *plow, ULONG_PTR *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, ULONG_PTR 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, ULONG_PTR 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, ULONG_PTR load_offset)
 
static BOOL dwarf2_lookup_loclist (const struct module_format *modfmt, const BYTE *start, ULONG_PTR 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 (ULONG_PTR 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 (struct module *module, dwarf2_traverse_context_t *ctx, ULONG_PTR last_ip, struct frame_info *info)
 
static DWORD64 get_context_reg (const struct module *module, struct cpu_stack_walk *csw, union ctx *context, ULONG_PTR dw_reg)
 
static void set_context_reg (const struct module *module, struct cpu_stack_walk *csw, union ctx *context, ULONG_PTR dw_reg, ULONG_PTR val, BOOL isdebuggee)
 
static void copy_context_reg (const struct module *module, struct cpu_stack_walk *csw, union ctx *dstcontext, ULONG_PTR dwregdst, union ctx *srccontext, ULONG_PTR dwregsrc)
 
static ULONG_PTR eval_expression (const struct module *module, struct cpu_stack_walk *csw, const unsigned char *zp, union ctx *context)
 
static void apply_frame_state (const struct module *module, struct cpu_stack_walk *csw, union ctx *context, struct frame_state *state, DWORD64 *cfa)
 
BOOL dwarf2_virtual_unwind (struct cpu_stack_walk *csw, ULONG_PTR ip, union ctx *context, DWORD64 *cfa)
 
static void dwarf2_location_compute (struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
 
static voidzalloc (void *priv, uInt items, uInt sz)
 
static void zfree (void *priv, void *addr)
 
static BOOL dwarf2_init_zsection (dwarf2_section_t *section, const char *zsectname, struct image_section_map *ism)
 
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, ULONG_PTR 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 206 of file dwarf.c.

◆ loc_dwarf2_location_list

#define loc_dwarf2_location_list   (loc_user + 0)

Definition at line 205 of file dwarf.c.

◆ MAX_SAVED_STATES

#define MAX_SAVED_STATES   16

Definition at line 2569 of file dwarf.c.

◆ NB_FRAME_REGS

#define NB_FRAME_REGS   64

Definition at line 2568 of file dwarf.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 25 of file dwarf.c.

◆ sc_int1

#define sc_int1   1

Definition at line 175 of file dwarf.c.

◆ sc_int2

#define sc_int2   2

Definition at line 176 of file dwarf.c.

◆ sc_int4

#define sc_int4   3

Definition at line 177 of file dwarf.c.

◆ sc_num

#define sc_num   4

Definition at line 178 of file dwarf.c.

◆ sc_void

#define sc_void   0

Definition at line 174 of file dwarf.c.

◆ Wine_DW_no_register

#define Wine_DW_no_register   0x7FFFFFFF

Definition at line 642 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 164 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 2556 of file dwarf.c.

2557 {
2558  RULE_UNSET, /* not set at all */
2559  RULE_UNDEFINED, /* undefined value */
2560  RULE_SAME, /* same value as previous frame */
2561  RULE_CFA_OFFSET, /* stored at cfa offset */
2562  RULE_OTHER_REG, /* stored in other register */
2563  RULE_EXPRESSION, /* address specified by expression */
2564  RULE_VAL_EXPRESSION /* value specified by expression */
2565 };

Function Documentation

◆ apply_frame_state()

static void apply_frame_state ( const struct module module,
struct cpu_stack_walk csw,
union ctx context,
struct frame_state state,
DWORD64 cfa 
)
static

Definition at line 3201 of file dwarf.c.

3203 {
3204  unsigned int i;
3205  ULONG_PTR value;
3206  union ctx new_context = *context;
3207 
3208  switch (state->cfa_rule)
3209  {
3210  case RULE_EXPRESSION:
3211  *cfa = eval_expression(module, csw, (const unsigned char*)state->cfa_offset, context);
3212  if (!sw_read_mem(csw, *cfa, cfa, csw->cpu->word_size))
3213  {
3214  WARN("Couldn't read memory at %s\n", wine_dbgstr_longlong(*cfa));
3215  return;
3216  }
3217  break;
3218  case RULE_VAL_EXPRESSION:
3219  *cfa = eval_expression(module, csw, (const unsigned char*)state->cfa_offset, context);
3220  break;
3221  default:
3222  *cfa = get_context_reg(module, csw, context, state->cfa_reg) + state->cfa_offset;
3223  break;
3224  }
3225  if (!*cfa) return;
3226 
3227  for (i = 0; i < NB_FRAME_REGS; i++)
3228  {
3229  switch (state->rules[i])
3230  {
3231  case RULE_UNSET:
3232  case RULE_UNDEFINED:
3233  case RULE_SAME:
3234  break;
3235  case RULE_CFA_OFFSET:
3236  set_context_reg(module, csw, &new_context, i, *cfa + state->regs[i], TRUE);
3237  break;
3238  case RULE_OTHER_REG:
3239  copy_context_reg(module, csw, &new_context, i, context, state->regs[i]);
3240  break;
3241  case RULE_EXPRESSION:
3242  value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context);
3243  set_context_reg(module, csw, &new_context, i, value, TRUE);
3244  break;
3245  case RULE_VAL_EXPRESSION:
3246  value = eval_expression(module, csw, (const unsigned char*)state->regs[i], context);
3247  set_context_reg(module, csw, &new_context, i, value, FALSE);
3248  break;
3249  }
3250  }
3251  *context = new_context;
3252 }
Definition: http.c:7094
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct cpu * cpu
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 FALSE
Definition: types.h:117
static ULONG_PTR eval_expression(const struct module *module, struct cpu_stack_walk *csw, const unsigned char *zp, union ctx *context)
Definition: dwarf.c:3087
static DWORD64 get_context_reg(const struct module *module, struct cpu_stack_walk *csw, union ctx *context, ULONG_PTR dw_reg)
Definition: dwarf.c:3019
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:95
#define NB_FRAME_REGS
Definition: dwarf.c:2568
static void copy_context_reg(const struct module *module, struct cpu_stack_walk *csw, union ctx *dstcontext, ULONG_PTR dwregdst, union ctx *srccontext, ULONG_PTR dwregsrc)
Definition: dwarf.c:3069
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static void set_context_reg(const struct module *module, struct cpu_stack_walk *csw, union ctx *context, ULONG_PTR dw_reg, ULONG_PTR val, BOOL isdebuggee)
Definition: dwarf.c:3035

Referenced by dwarf2_virtual_unwind().

◆ compute_location()

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

Definition at line 655 of file dwarf.c.

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

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

◆ copy_context_reg()

static void copy_context_reg ( const struct module module,
struct cpu_stack_walk csw,
union ctx dstcontext,
ULONG_PTR  dwregdst,
union ctx srccontext,
ULONG_PTR  dwregsrc 
)
static

Definition at line 3069 of file dwarf.c.

3072 {
3073  unsigned regdstno = csw->cpu->map_dwarf_register(dwregdst, module, TRUE), szdst;
3074  unsigned regsrcno = csw->cpu->map_dwarf_register(dwregsrc, module, TRUE), szsrc;
3075  ULONG_PTR* ptrdst = csw->cpu->fetch_context_reg(dstcontext, regdstno, &szdst);
3076  ULONG_PTR* ptrsrc = csw->cpu->fetch_context_reg(srccontext, regsrcno, &szsrc);
3077 
3078  if (szdst != szsrc)
3079  {
3080  FIXME("Cannot copy register %lu/%u => %lu/%u because of size mismatch (%u => %u)\n",
3081  dwregsrc, regsrcno, dwregdst, regdstno, szsrc, szdst);
3082  return;
3083  }
3084  memcpy(ptrdst, ptrsrc, szdst);
3085 }
#define TRUE
Definition: types.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct cpu * cpu
#define FIXME(fmt,...)
Definition: debug.h:111
#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,
ULONG_PTR  entry_code 
)
static

Definition at line 380 of file dwarf.c.

382 {
383  assert( NULL != abbrev_table );
384  return sparse_array_find(abbrev_table, entry_code);
385 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
void * sparse_array_find(const struct sparse_array *sa, ULONG_PTR idx) DECLSPEC_HIDDEN
Definition: storage.c:271

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,
ULONG_PTR  dw,
struct location loc,
const struct location frame 
)
static

Definition at line 885 of file dwarf.c.

890 {
891  struct attribute xloc;
892 
893  if (!dwarf2_find_attribute(ctx, di, dw, &xloc)) return FALSE;
894 
895  switch (xloc.form)
896  {
897  case DW_FORM_data1: case DW_FORM_data2:
898  case DW_FORM_udata: case DW_FORM_sdata:
899  loc->kind = loc_absolute;
900  loc->reg = 0;
901  loc->offset = xloc.u.uvalue;
902  return TRUE;
903  case DW_FORM_data4: case DW_FORM_data8:
905  loc->reg = Wine_DW_no_register;
906  loc->offset = xloc.u.uvalue;
907  return TRUE;
908  case DW_FORM_block:
909  case DW_FORM_block1:
910  case DW_FORM_block2:
911  case DW_FORM_block4:
912  break;
913  default: FIXME("Unsupported yet form %lx\n", xloc.form);
914  return FALSE;
915  }
916 
917  /* assume we have a block form */
918 
919  if (xloc.u.block.size)
920  {
922  enum location_error err;
923 
924  lctx.data = xloc.u.block.ptr;
925  lctx.end_data = xloc.u.block.ptr + xloc.u.block.size;
926  lctx.word_size = ctx->module->format_info[DFI_DWARF]->u.dwarf2_info->word_size;
927 
928  err = compute_location(ctx->module, &lctx, loc, NULL, frame);
929  if (err < 0)
930  {
931  loc->kind = loc_error;
932  loc->reg = err;
933  }
934  else if (loc->kind == loc_dwarf2_block)
935  {
936  unsigned* ptr = pool_alloc(&ctx->module->pool,
937  sizeof(unsigned) + xloc.u.block.size);
938  *ptr = xloc.u.block.size;
939  memcpy(ptr + 1, xloc.u.block.ptr, xloc.u.block.size);
940  loc->offset = (ULONG_PTR)ptr;
941  compute_location(ctx->module, &lctx, loc, NULL, frame);
942  }
943  }
944  return TRUE;
945 }
const unsigned char * data
Definition: dwarf.c:168
#define TRUE
Definition: types.h:120
const unsigned char * end_data
Definition: dwarf.c:169
#define Wine_DW_no_register
Definition: dwarf.c:642
void * pool_alloc(struct pool *a, size_t len) DECLSPEC_HIDDEN
Definition: storage.c:89
#define FALSE
Definition: types.h:117
location_error
#define FIXME(fmt,...)
Definition: debug.h:111
static PVOID ptr
Definition: dispmode.c:27
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
smooth NULL
Definition: ftsmooth.c:416
ULONG_PTR offset
static enum location_error compute_location(const struct module *module, dwarf2_traverse_context_t *ctx, struct location *loc, HANDLE hproc, const struct location *frame)
Definition: dwarf.c:655
#define loc_dwarf2_block
Definition: dwarf.c:206
unsigned reg
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define err(...)
unsigned kind
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:600
unsigned char word_size
Definition: dwarf.c:170
#define ULONG_PTR
Definition: config.h:101
#define loc_dwarf2_location_list
Definition: dwarf.c:205

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 362 of file dwarf.c.

363 {
364  return wine_dbg_sprintf("ctx(%p)", ctx->data);
365 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296

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 486 of file dwarf.c.

490 {
491  attr->form = abbrev_attr->form;
492  switch (attr->form)
493  {
494  case DW_FORM_ref_addr:
495  case DW_FORM_addr:
496  attr->u.uvalue = dwarf2_get_addr(data,
497  ctx->module->format_info[DFI_DWARF]->u.dwarf2_info->word_size);
498  TRACE("addr<0x%lx>\n", attr->u.uvalue);
499  break;
500 
501  case DW_FORM_flag:
502  attr->u.uvalue = dwarf2_get_byte(data);
503  TRACE("flag<0x%lx>\n", attr->u.uvalue);
504  break;
505 
507  attr->u.uvalue = 1;
508  TRACE("flag_present\n");
509  break;
510 
511  case DW_FORM_data1:
512  attr->u.uvalue = dwarf2_get_byte(data);
513  TRACE("data1<%lu>\n", attr->u.uvalue);
514  break;
515 
516  case DW_FORM_data2:
517  attr->u.uvalue = dwarf2_get_u2(data);
518  TRACE("data2<%lu>\n", attr->u.uvalue);
519  break;
520 
521  case DW_FORM_data4:
522  attr->u.uvalue = dwarf2_get_u4(data);
523  TRACE("data4<%lu>\n", attr->u.uvalue);
524  break;
525 
526  case DW_FORM_data8:
527  attr->u.lluvalue = dwarf2_get_u8(data);
528  TRACE("data8<%s>\n", wine_dbgstr_longlong(attr->u.uvalue));
529  break;
530 
531  case DW_FORM_ref1:
532  attr->u.uvalue = ctx->ref_offset + dwarf2_get_byte(data);
533  TRACE("ref1<0x%lx>\n", attr->u.uvalue);
534  break;
535 
536  case DW_FORM_ref2:
537  attr->u.uvalue = ctx->ref_offset + dwarf2_get_u2(data);
538  TRACE("ref2<0x%lx>\n", attr->u.uvalue);
539  break;
540 
541  case DW_FORM_ref4:
542  attr->u.uvalue = ctx->ref_offset + dwarf2_get_u4(data);
543  TRACE("ref4<0x%lx>\n", attr->u.uvalue);
544  break;
545 
546  case DW_FORM_ref8:
547  FIXME("Unhandled 64-bit support\n");
548  break;
549 
550  case DW_FORM_sdata:
552  break;
553 
554  case DW_FORM_ref_udata:
556  break;
557 
558  case DW_FORM_udata:
560  break;
561 
562  case DW_FORM_string:
563  attr->u.string = (const char *)data;
564  TRACE("string<%s>\n", debugstr_a(attr->u.string));
565  break;
566 
567  case DW_FORM_strp:
568  {
570  attr->u.string = (const char*)ctx->sections[section_string].address + offset;
571  }
572  TRACE("strp<%s>\n", debugstr_a(attr->u.string));
573  break;
574 
575  case DW_FORM_block:
576  attr->u.block.size = dwarf2_get_leb128_as_unsigned(data, &attr->u.block.ptr);
577  break;
578 
579  case DW_FORM_block1:
580  attr->u.block.size = dwarf2_get_byte(data);
581  attr->u.block.ptr = data + 1;
582  break;
583 
584  case DW_FORM_block2:
585  attr->u.block.size = dwarf2_get_u2(data);
586  attr->u.block.ptr = data + 2;
587  break;
588 
589  case DW_FORM_block4:
590  attr->u.block.size = dwarf2_get_u4(data);
591  attr->u.block.ptr = data + 4;
592  break;
593 
594  default:
595  FIXME("Unhandled attribute form %lx\n", abbrev_attr->form);
596  break;
597  }
598 }
static ULONG_PTR dwarf2_get_leb128_as_unsigned(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:259
static unsigned char dwarf2_get_byte(const unsigned char *ptr)
Definition: dwarf.c:211
GLintptr offset
Definition: glext.h:5920
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
static ULONG_PTR dwarf2_get_addr(const unsigned char *ptr, unsigned word_size)
Definition: dwarf.c:336
static DWORD64 dwarf2_get_u8(const unsigned char *ptr)
Definition: dwarf.c:247
ULONG_PTR form
Definition: dwarf.c:114
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
static LONG_PTR dwarf2_get_leb128_as_signed(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:287
Definition: cookie.c:201
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static unsigned short dwarf2_get_u2(const unsigned char *ptr)
Definition: dwarf.c:223
static ULONG_PTR dwarf2_get_u4(const unsigned char *ptr)
Definition: dwarf.c:235
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49

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 600 of file dwarf.c.

603 {
604  unsigned i, refidx = 0;
605  dwarf2_abbrev_entry_attr_t* abbrev_attr;
606  dwarf2_abbrev_entry_attr_t* ref_abbrev_attr = NULL;
607 
608  attr->gotten_from = attr_direct;
609  while (di)
610  {
611  ref_abbrev_attr = NULL;
612  for (i = 0, abbrev_attr = di->abbrev->attrs; abbrev_attr; i++, abbrev_attr = abbrev_attr->next)
613  {
614  if (abbrev_attr->attribute == at)
615  {
616  dwarf2_fill_attr(ctx, abbrev_attr, di->data[i], attr);
617  return TRUE;
618  }
619  if ((abbrev_attr->attribute == DW_AT_abstract_origin ||
620  abbrev_attr->attribute == DW_AT_specification) &&
621  at != DW_AT_sibling)
622  {
623  if (ref_abbrev_attr)
624  FIXME("two references %lx and %lx\n", ref_abbrev_attr->attribute, abbrev_attr->attribute);
625  ref_abbrev_attr = abbrev_attr;
626  refidx = i;
627  attr->gotten_from = (abbrev_attr->attribute == DW_AT_abstract_origin) ?
629  }
630  }
631  /* do we have either an abstract origin or a specification debug entry to look into ? */
632  if (!ref_abbrev_attr) break;
633  dwarf2_fill_attr(ctx, ref_abbrev_attr, di->data[refidx], attr);
634  if (!(di = sparse_array_find(&ctx->debug_info_table, attr->u.uvalue)))
635  FIXME("Should have found the debug info entry\n");
636  }
637  return FALSE;
638 }
ULONG_PTR attribute
Definition: dwarf.c:113
#define TRUE
Definition: types.h:120
const unsigned char ** data
Definition: dwarf.c:151
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:149
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 FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
dwarf2_abbrev_entry_attr_t * attrs
Definition: dwarf.c:124
smooth NULL
Definition: ftsmooth.c:416
struct dwarf2_abbrev_entry_attr_s * next
Definition: dwarf.c:115
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:486
Definition: cookie.c:201
void * sparse_array_find(const struct sparse_array *sa, ULONG_PTR idx) DECLSPEC_HIDDEN
Definition: storage.c:271
Definition: dwarf.c:111

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 3496 of file dwarf.c.

3497 {
3498  if (section->compressed)
3499  HeapFree(GetProcessHeap(), 0, (void*)section->address);
3500 }
Definition: parser.c:55
#define GetProcessHeap()
Definition: compat.h:484
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by dwarf2_module_remove(), and dwarf2_parse().

◆ dwarf2_get_addr()

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

Definition at line 336 of file dwarf.c.

337 {
338  ULONG_PTR ret;
339 
340  switch (word_size)
341  {
342  case 4:
343  ret = dwarf2_get_u4(ptr);
344  break;
345  case 8:
346  ret = dwarf2_get_u8(ptr);
347  break;
348  default:
349  FIXME("Unsupported Word Size %u\n", word_size);
350  ret = 0;
351  }
352  return ret;
353 }
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FIXME(fmt,...)
Definition: debug.h:111
static PVOID ptr
Definition: dispmode.c:27
static DWORD64 dwarf2_get_u8(const unsigned char *ptr)
Definition: dwarf.c:247
int ret
static ULONG_PTR dwarf2_get_u4(const unsigned char *ptr)
Definition: dwarf.c:235

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 211 of file dwarf.c.

212 {
213  return *ptr;
214 }
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 ( ULONG_PTR  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 2715 of file dwarf.c.

2718 {
2719  const unsigned char* ptr_blk;
2720  const unsigned char* cie_ptr;
2721  const unsigned char* last_cie_ptr = (const unsigned char*)~0;
2722  unsigned len, id;
2724  unsigned cie_id;
2725  const BYTE* start_data = fde_ctx->data;
2726 
2727  cie_id = in_eh_frame ? 0 : DW_CIE_ID;
2728  /* skip 0-padding at beginning of section (alignment) */
2729  while (fde_ctx->data + 2 * 4 < fde_ctx->end_data)
2730  {
2731  if (dwarf2_parse_u4(fde_ctx))
2732  {
2733  fde_ctx->data -= 4;
2734  break;
2735  }
2736  }
2737  for (; fde_ctx->data + 2 * 4 < fde_ctx->end_data; fde_ctx->data = ptr_blk)
2738  {
2739  /* find the FDE for address addr (skip CIE) */
2740  len = dwarf2_parse_u4(fde_ctx);
2741  if (len == 0xffffffff) FIXME("Unsupported yet 64-bit CIEs\n");
2742  ptr_blk = fde_ctx->data + len;
2743  id = dwarf2_parse_u4(fde_ctx);
2744  if (id == cie_id)
2745  {
2746  last_cie_ptr = fde_ctx->data - 8;
2747  /* we need some bits out of the CIE in order to parse all contents */
2748  if (!parse_cie_details(fde_ctx, info)) return FALSE;
2749  cie_ctx->data = fde_ctx->data;
2750  cie_ctx->end_data = ptr_blk;
2751  cie_ctx->word_size = fde_ctx->word_size;
2752  continue;
2753  }
2754  cie_ptr = (in_eh_frame) ? fde_ctx->data - id - 4 : start_data + id;
2755  if (cie_ptr != last_cie_ptr)
2756  {
2757  last_cie_ptr = cie_ptr;
2758  cie_ctx->data = cie_ptr;
2759  cie_ctx->word_size = fde_ctx->word_size;
2760  cie_ctx->end_data = cie_ptr + 4;
2761  cie_ctx->end_data = cie_ptr + 4 + dwarf2_parse_u4(cie_ctx);
2762  if (dwarf2_parse_u4(cie_ctx) != cie_id)
2763  {
2764  FIXME("wrong CIE pointer at %x from FDE %x\n",
2765  (unsigned)(cie_ptr - start_data),
2766  (unsigned)(fde_ctx->data - start_data));
2767  return FALSE;
2768  }
2769  if (!parse_cie_details(cie_ctx, info)) return FALSE;
2770  }
2771  start = delta + dwarf2_parse_augmentation_ptr(fde_ctx, info->fde_encoding);
2772  range = dwarf2_parse_augmentation_ptr(fde_ctx, info->fde_encoding & 0x0F);
2773 
2774  if (addr >= start && addr < start + range)
2775  {
2776  /* reset the FDE context */
2777  fde_ctx->end_data = ptr_blk;
2778 
2779  info->ip = start;
2780  return TRUE;
2781  }
2782  }
2783  return FALSE;
2784 }
static ULONG_PTR dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:240
const unsigned char * data
Definition: dwarf.c:168
#define TRUE
Definition: types.h:120
static BOOL parse_cie_details(dwarf2_traverse_context_t *ctx, struct frame_info *info)
Definition: dwarf.c:2640
const unsigned char * end_data
Definition: dwarf.c:169
static ULONG_PTR dwarf2_parse_augmentation_ptr(dwarf2_traverse_context_t *ctx, unsigned char encoding)
Definition: dwarf.c:2595
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ fcb _In_ chunk _In_ uint64_t start_data
Definition: btrfs_drv.h:1357
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
#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: xxhash.c:193
GLenum GLint * range
Definition: glext.h:7539
GLuint start
Definition: gl.h:1545
unsigned char word_size
Definition: dwarf.c:170
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 970 of file dwarf.c.

971 {
972  char* last;
973  struct attribute diname;
974  struct attribute spec;
975 
976  if (di->abbrev->tag == DW_TAG_compile_unit) return name;
977  if (!ctx->cpp_name)
978  ctx->cpp_name = pool_alloc(&ctx->pool, MAX_SYM_NAME);
979  last = ctx->cpp_name + MAX_SYM_NAME - strlen(name) - 1;
980  strcpy(last, name);
981 
982  /* if the di is a definition, but has also a (previous) declaration, then scope must
983  * be gotten from declaration not definition
984  */
985  if (dwarf2_find_attribute(ctx, di, DW_AT_specification, &spec) && spec.gotten_from == attr_direct)
986  {
987  di = sparse_array_find(&ctx->debug_info_table, spec.u.uvalue);
988  if (!di)
989  {
990  FIXME("Should have found the debug info entry\n");
991  return NULL;
992  }
993  }
994 
995  for (di = di->parent; di; di = di->parent)
996  {
997  switch (di->abbrev->tag)
998  {
999  case DW_TAG_namespace:
1000  case DW_TAG_structure_type:
1001  case DW_TAG_class_type:
1002  case DW_TAG_interface_type:
1003  case DW_TAG_union_type:
1004  if (dwarf2_find_attribute(ctx, di, DW_AT_name, &diname))
1005  {
1006  size_t len = strlen(diname.u.string);
1007  last -= 2 + len;
1008  if (last < ctx->cpp_name) return NULL;
1009  memcpy(last, diname.u.string, len);
1010  last[len] = last[len + 1] = ':';
1011  }
1012  break;
1013  default:
1014  break;
1015  }
1016  }
1017  return last;
1018 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
POINT last
Definition: font.c:46
ULONG_PTR tag
Definition: dwarf.c:121
void * pool_alloc(struct pool *a, size_t len) DECLSPEC_HIDDEN
Definition: storage.c:89
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:149
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define MAX_SYM_NAME
Definition: compat.h:723
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
void * sparse_array_find(const struct sparse_array *sa, ULONG_PTR idx) DECLSPEC_HIDDEN
Definition: storage.c:271
struct dwarf2_debug_info_s * parent
Definition: dwarf.c:153
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:600
Definition: name.c:38
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
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 1145 of file dwarf.c.

1147 {
1148  struct attribute spec;
1149 
1150  while (di)
1151  {
1152  if (di->abbrev->have_child)
1153  return &di->children;
1154  if (!dwarf2_find_attribute(ctx, di, DW_AT_specification, &spec)) break;
1155  if (!(di = sparse_array_find(&ctx->debug_info_table, spec.u.uvalue)))
1156  FIXME("Should have found the debug info entry\n");
1157  }
1158  return NULL;
1159 }
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:149
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
unsigned char have_child
Definition: dwarf.c:122
void * sparse_array_find(const struct sparse_array *sa, ULONG_PTR idx) DECLSPEC_HIDDEN
Definition: storage.c:271
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:600
struct vector children
Definition: dwarf.c:152

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_PTR dwarf2_get_leb128_as_signed ( const unsigned char ptr,
const unsigned char **  end 
)
static

Definition at line 287 of file dwarf.c.

288 {
289  LONG_PTR ret = 0;
290  unsigned char byte;
291  unsigned shift = 0;
292  const unsigned size = sizeof(int) * 8;
293 
294  do
295  {
296  byte = dwarf2_get_byte(ptr++);
297  ret |= (byte & 0x7f) << shift;
298  shift += 7;
299  } while (byte & 0x80);
300  if (end) *end = ptr;
301 
302  /* as spec: sign bit of byte is 2nd high order bit (80x40)
303  * -> 0x80 is used as flag.
304  */
305  if ((shift < size) && (byte & 0x40))
306  {
307  ret |= - (1 << shift);
308  }
309  return ret;
310 }
#define shift
Definition: input.c:1756
static unsigned char dwarf2_get_byte(const unsigned char *ptr)
Definition: dwarf.c:211
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
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
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 ULONG_PTR dwarf2_get_leb128_as_unsigned ( const unsigned char ptr,
const unsigned char **  end 
)
static

Definition at line 259 of file dwarf.c.

260 {
261  ULONG_PTR ret = 0;
262  unsigned char byte;
263  unsigned shift = 0;
264 
265  do
266  {
267  byte = dwarf2_get_byte(ptr++);
268  ret |= (byte & 0x7f) << shift;
269  shift += 7;
270  } while (byte & 0x80);
271 
272  if (end) *end = ptr;
273  return ret;
274 }
#define shift
Definition: input.c:1756
static unsigned char dwarf2_get_byte(const unsigned char *ptr)
Definition: dwarf.c:211
GLuint GLuint end
Definition: gl.h:1545
uint32_t ULONG_PTR
Definition: typedefs.h:65
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 223 of file dwarf.c.

224 {
225  return *(const UINT16*)ptr;
226 }
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 ULONG_PTR dwarf2_get_u4 ( const unsigned char ptr)
static

Definition at line 235 of file dwarf.c.

236 {
237  return *(const UINT32*)ptr;
238 }
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 247 of file dwarf.c.

248 {
249  return *(const UINT64*)ptr;
250 }
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 3467 of file dwarf.c.

3470 {
3471  struct image_section_map local_ism;
3472 
3473  if (!ism) ism = &local_ism;
3474 
3475  section->compressed = FALSE;
3476  if (image_find_section(fmap, sectname, ism))
3477  {
3478  section->address = (const BYTE*)image_map_section(ism);
3479  section->size = image_get_map_size(ism);
3480  section->rva = image_get_map_rva(ism);
3481  return TRUE;
3482  }
3483 
3484  section->address = NULL;
3485  section->size = 0;
3486  section->rva = 0;
3487 
3488  if (zsectname && image_find_section(fmap, zsectname, ism))
3489  {
3490  return dwarf2_init_zsection(section, zsectname, ism);
3491  }
3492 
3493  return FALSE;
3494 }
#define TRUE
Definition: types.h:120
struct image_file_map * fmap
Definition: parser.c:55
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
static unsigned image_get_map_size(const struct image_section_map *ism)
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)
unsigned char BYTE
Definition: xxhash.c:193
static DWORD_PTR image_get_map_rva(const struct image_section_map *ism)
static BOOL dwarf2_init_zsection(dwarf2_section_t *section, const char *zsectname, struct image_section_map *ism)
Definition: dwarf.c:3396

Referenced by dwarf2_parse().

◆ dwarf2_init_zsection()

static BOOL dwarf2_init_zsection ( dwarf2_section_t section,
const char zsectname,
struct image_section_map ism 
)
inlinestatic

Definition at line 3396 of file dwarf.c.

3399 {
3400  z_stream z;
3401  LARGE_INTEGER li;
3402  int res;
3403  BOOL ret = FALSE;
3404 
3405  BYTE *addr, *sect = (BYTE *)image_map_section(ism);
3406  size_t sz = image_get_map_size(ism);
3407 
3408  if (sz <= 12 || memcmp(sect, "ZLIB", 4))
3409  {
3410  ERR("invalid compressed section %s\n", debugstr_a(zsectname));
3411  goto out;
3412  }
3413 
3414 #ifdef WORDS_BIGENDIAN
3415  li.u.HighPart = *(DWORD*)&sect[4];
3416  li.u.LowPart = *(DWORD*)&sect[8];
3417 #else
3418  li.u.HighPart = RtlUlongByteSwap(*(DWORD*)&sect[4]);
3419  li.u.LowPart = RtlUlongByteSwap(*(DWORD*)&sect[8]);
3420 #endif
3421 
3422  addr = HeapAlloc(GetProcessHeap(), 0, li.QuadPart);
3423  if (!addr)
3424  goto out;
3425 
3426  z.next_in = &sect[12];
3427  z.avail_in = sz - 12;
3428  z.opaque = NULL;
3429  z.zalloc = zalloc;
3430  z.zfree = zfree;
3431 
3432  res = inflateInit(&z);
3433  if (res != Z_OK)
3434  {
3435  FIXME("inflateInit failed with %i / %s\n", res, debugstr_a(z.msg));
3436  goto out_free;
3437  }
3438 
3439  do {
3440  z.next_out = addr + z.total_out;
3441  z.avail_out = li.QuadPart - z.total_out;
3442  res = inflate(&z, Z_FINISH);
3443  } while (z.avail_in && res == Z_STREAM_END);
3444 
3445  if (res != Z_STREAM_END)
3446  {
3447  FIXME("Decompression failed with %i / %s\n", res, debugstr_a(z.msg));
3448  goto out_end;
3449  }
3450 
3451  ret = TRUE;
3452  section->compressed = TRUE;
3453  section->address = addr;
3454  section->rva = image_get_map_rva(ism);
3455  section->size = z.total_out;
3456 
3457 out_end:
3458  inflateEnd(&z);
3459 out_free:
3460  if (!ret)
3461  HeapFree(GetProcessHeap(), 0, addr);
3462 out:
3463  image_unmap_section(ism);
3464  return ret;
3465 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
#define Z_OK
Definition: zlib.h:114
static void zfree(void *priv, void *addr)
Definition: dwarf.c:3391
Definition: parser.c:55
struct _LARGE_INTEGER::@2260 u
#define Z_STREAM_END
Definition: zlib.h:115
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
GLdouble GLdouble z
Definition: glext.h:5874
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define debugstr_a
Definition: kernel32.h:31
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
static unsigned image_get_map_size(const struct image_section_map *ism)
int ret
int inflateEnd(z_streamp strm)
Definition: inflate.c:1910
GLenum const GLvoid * addr
Definition: glext.h:9621
static void image_unmap_section(struct image_section_map *ism)
#define RtlUlongByteSwap(_x)
Definition: compat.h:563
static const char * image_map_section(struct image_section_map *ism)
unsigned char BYTE
Definition: xxhash.c:193
static void * zalloc(void *priv, uInt items, uInt sz)
Definition: dwarf.c:3386
#define ERR(fmt,...)
Definition: debug.h:110
#define Z_FINISH
Definition: zlib.h:109
static DWORD_PTR image_get_map_rva(const struct image_section_map *ism)
GLuint res
Definition: glext.h:9613
int inflate(z_streamp strm, int flush)
Definition: inflate.c:1257
#define inflateInit(strm)
Definition: zlib.h:1795
#define HeapFree(x, y, z)
Definition: compat.h:483
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by dwarf2_init_section().

◆ dwarf2_leb128_as_signed()

static LONG_PTR dwarf2_leb128_as_signed ( dwarf2_traverse_context_t ctx)
static

Definition at line 312 of file dwarf.c.

313 {
314  LONG_PTR ret = 0;
315 
316  assert(ctx);
317 
318  ret = dwarf2_get_leb128_as_signed(ctx->data, &ctx->data);
319  return ret;
320 }
#define assert(x)
Definition: debug.h:53
static LONG_PTR dwarf2_get_leb128_as_signed(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:287
int ret
__int3264 LONG_PTR
Definition: mstsclib_h.h:276

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 ULONG_PTR dwarf2_leb128_as_unsigned ( dwarf2_traverse_context_t ctx)
static

Definition at line 276 of file dwarf.c.

277 {
278  ULONG_PTR ret;
279 
280  assert(ctx);
281 
282  ret = dwarf2_get_leb128_as_unsigned(ctx->data, &ctx->data);
283 
284  return ret;
285 }
static ULONG_PTR dwarf2_get_leb128_as_unsigned(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:259
#define assert(x)
Definition: debug.h:53
uint32_t ULONG_PTR
Definition: typedefs.h:65
int ret

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 322 of file dwarf.c.

323 {
324  unsigned ret;
325  for (ret = 0; ctx->data[ret] & 0x80; ret++);
326  return ret + 1;
327 }
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 2091 of file dwarf.c.

2093 {
2094  switch (di->abbrev->tag)
2095  {
2096  case DW_TAG_typedef:
2098  break;
2099  case DW_TAG_base_type:
2101  break;
2102  case DW_TAG_pointer_type:
2104  break;
2105  case DW_TAG_class_type:
2107  break;
2108  case DW_TAG_structure_type:
2110  break;
2111  case DW_TAG_union_type:
2113  break;
2114  case DW_TAG_array_type:
2116  break;
2117  case DW_TAG_const_type:
2119  break;
2120  case DW_TAG_volatile_type:
2122  break;
2125  break;
2126  case DW_TAG_reference_type:
2128  break;
2131  break;
2132  case DW_TAG_subprogram:
2134  break;
2137  break;
2138  case DW_TAG_variable:
2139  {
2140  dwarf2_subprogram_t subpgm;
2141 
2142  subpgm.ctx = ctx;
2143  subpgm.func = NULL;
2144  subpgm.frame.kind = loc_absolute;
2145  subpgm.frame.offset = 0;
2146  subpgm.frame.reg = Wine_DW_no_register;
2147  dwarf2_parse_variable(&subpgm, NULL, di);
2148  }
2149  break;
2150  case DW_TAG_namespace:
2152  break;
2153  /* silence a couple of C++ defines */
2157  break;
2158  default:
2159  FIXME("Unhandled Tag type 0x%lx at %s, for %lu\n",
2161  }
2162 }
struct location frame
Definition: dwarf.c:1580
static struct symt * dwarf2_parse_pointer_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1234
dwarf2_parse_context_t * ctx
Definition: dwarf.c:1577
static struct symt * dwarf2_parse_udt_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, enum UdtKind udt)
Definition: dwarf.c:1442
static struct symt * dwarf2_parse_enumeration_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *entry)
Definition: dwarf.c:1528
static void dwarf2_parse_variable(dwarf2_subprogram_t *subpgm, struct symt_block *block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1588
static struct symt * dwarf2_parse_base_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1161
ULONG_PTR tag
Definition: dwarf.c:121
static struct symt * dwarf2_parse_volatile_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1323
#define Wine_DW_no_register
Definition: dwarf.c:642
static struct symt * dwarf2_parse_typedef(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1215
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:149
static struct symt * dwarf2_parse_unspecified_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1343
static void dwarf2_parse_namespace(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:2070
#define FIXME(fmt,...)
Definition: debug.h:111
static struct symt * dwarf2_parse_array_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1255
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:1303
ULONG_PTR entry_code
Definition: dwarf.c:120
static struct symt * dwarf2_parse_subroutine_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:2028
static struct symt * dwarf2_parse_subprogram(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1890
struct symt_function * func
Definition: dwarf.c:1578
static struct symt * dwarf2_parse_reference_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1368
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:367

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 3324 of file dwarf.c.

3328 {
3329  struct location frame;
3330  DWORD_PTR ip;
3331  int err;
3333 
3334  if (!func->container || func->container->tag != SymTagCompiland)
3335  {
3336  WARN("We'd expect function %s's container to exist and be a compiland\n", debugstr_a(func->hash_elt.name));
3338  }
3339  else
3340  {
3341  /* instruction pointer relative to compiland's start */
3342  ip = pcs->ctx_frame.InstructionOffset - ((struct symt_compiland*)func->container)->address;
3343 
3344  if ((err = loc_compute_frame(pcs, modfmt, func, ip, &frame)) == 0)
3345  {
3346  switch (loc->kind)
3347  {
3349  /* Then, if the variable has a location list, find it !! */
3350  if (dwarf2_lookup_loclist(modfmt,
3351  modfmt->u.dwarf2_info->debug_loc.address + loc->offset,
3352  ip, &lctx))
3353  goto do_compute;
3355  break;
3356  case loc_dwarf2_block:
3357  /* or if we have a copy of an existing block, get ready for it */
3358  {
3359  unsigned* ptr = (unsigned*)loc->offset;
3360 
3361  lctx.data = (const BYTE*)(ptr + 1);
3362  lctx.end_data = lctx.data + *ptr;
3363  lctx.word_size = modfmt->u.dwarf2_info->word_size;
3364  }
3365  do_compute:
3366  /* now get the variable */
3367  err = compute_location(modfmt->module, &lctx, loc, pcs->handle, &frame);
3368  break;
3369  case loc_register:
3370  case loc_regrel:
3371  /* nothing to do */
3372  break;
3373  default:
3374  WARN("Unsupported local kind %d\n", loc->kind);
3376  }
3377  }
3378  }
3379  if (err < 0)
3380  {
3381  loc->kind = loc_register;
3382  loc->reg = err;
3383  }
3384 }
GLenum func
Definition: glext.h:6028
const unsigned char * data
Definition: dwarf.c:168
#define WARN(fmt,...)
Definition: debug.h:112
const unsigned char * end_data
Definition: dwarf.c:169
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:2507
static PVOID ptr
Definition: dispmode.c:27
int ip[4]
Definition: rtl.c:1176
ULONG_PTR offset
static BOOL dwarf2_lookup_loclist(const struct module_format *modfmt, const BYTE *start, ULONG_PTR ip, dwarf2_traverse_context_t *lctx)
Definition: dwarf.c:2480
static enum location_error compute_location(const struct module *module, dwarf2_traverse_context_t *ctx, struct location *loc, HANDLE hproc, const struct location *frame)
Definition: dwarf.c:655
Definition: dhcpd.h:61
#define debugstr_a
Definition: kernel32.h:31
#define loc_dwarf2_block
Definition: dwarf.c:206
struct dwarf2_module_info_s * dwarf2_info
unsigned reg
ULONG64 InstructionOffset
Definition: compat.h:1124
#define err(...)
uint32_t DWORD_PTR
Definition: typedefs.h:65
unsigned char BYTE
Definition: xxhash.c:193
unsigned kind
struct module * module
unsigned char word_size
Definition: dwarf.c:170
HANDLE handle
union module_format::@365 u
#define loc_dwarf2_location_list
Definition: dwarf.c:205

Referenced by dwarf2_parse().

◆ dwarf2_lookup_loclist()

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

Definition at line 2480 of file dwarf.c.

2482 {
2483  DWORD_PTR beg, end;
2484  const BYTE* ptr = start;
2485  DWORD len;
2486 
2487  while (ptr < modfmt->u.dwarf2_info->debug_loc.address + modfmt->u.dwarf2_info->debug_loc.size)
2488  {
2489  beg = dwarf2_get_addr(ptr, modfmt->u.dwarf2_info->word_size); ptr += modfmt->u.dwarf2_info->word_size;
2490  end = dwarf2_get_addr(ptr, modfmt->u.dwarf2_info->word_size); ptr += modfmt->u.dwarf2_info->word_size;
2491  if (!beg && !end) break;
2492  len = dwarf2_get_u2(ptr); ptr += 2;
2493 
2494  if (beg <= ip && ip < end)
2495  {
2496  lctx->data = ptr;
2497  lctx->end_data = ptr + len;
2498  lctx->word_size = modfmt->u.dwarf2_info->word_size;
2499  return TRUE;
2500  }
2501  ptr += len;
2502  }
2503  WARN("Couldn't find ip in location list\n");
2504  return FALSE;
2505 }
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
const unsigned char * data
Definition: dwarf.c:168
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
GLuint GLuint end
Definition: gl.h:1545
const unsigned char * end_data
Definition: dwarf.c:169
#define FALSE
Definition: types.h:117
static PVOID ptr
Definition: dispmode.c:27
static ULONG_PTR dwarf2_get_addr(const unsigned char *ptr, unsigned word_size)
Definition: dwarf.c:336
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
static unsigned short dwarf2_get_u2(const unsigned char *ptr)
Definition: dwarf.c:223
uint32_t DWORD_PTR
Definition: typedefs.h:65
unsigned char BYTE
Definition: xxhash.c:193
GLuint start
Definition: gl.h:1545
unsigned char word_size
Definition: dwarf.c:170
union module_format::@365 u

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 947 of file dwarf.c.

949 {
950  struct attribute attr;
952 
954  return NULL;
955  if (!(type = sparse_array_find(&ctx->debug_info_table, attr.u.uvalue)))
956  {
957  FIXME("Unable to find back reference to type %lx\n", attr.u.uvalue);
958  return NULL;
959  }
960  if (!type->symt)
961  {
962  /* load the debug info entity */
964  if (!type->symt)
965  FIXME("Unable to load forward reference for tag %lx\n", type->abbrev->tag);
966  }
967  return type->symt;
968 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
static void dwarf2_load_one_entry(dwarf2_parse_context_t *, dwarf2_debug_info_t *)
Definition: dwarf.c:2091
Definition: cookie.c:201
void * sparse_array_find(const struct sparse_array *sa, ULONG_PTR idx) DECLSPEC_HIDDEN
Definition: storage.c:271
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:600

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,
const struct module module 
)
static

Definition at line 644 of file dwarf.c.

645 {
646  if (regno == Wine_DW_no_register)
647  {
648  FIXME("What the heck map reg 0x%x\n",regno);
649  return 0;
650  }
651  return dbghelp_current_cpu->map_dwarf_register(regno, module, FALSE);
652 }
#define Wine_DW_no_register
Definition: dwarf.c:642
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
struct cpu * dbghelp_current_cpu
Definition: dbghelp.c:169

Referenced by compute_location().

◆ dwarf2_module_remove()

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

Definition at line 3502 of file dwarf.c.

3503 {
3504  dwarf2_fini_section(&modfmt->u.dwarf2_info->debug_loc);
3505  dwarf2_fini_section(&modfmt->u.dwarf2_info->debug_frame);
3506  HeapFree(GetProcessHeap(), 0, modfmt);
3507 }
#define GetProcessHeap()
Definition: compat.h:484
static void dwarf2_fini_section(dwarf2_section_t *section)
Definition: dwarf.c:3496
struct dwarf2_module_info_s * dwarf2_info
union module_format::@365 u
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by dwarf2_parse().

◆ dwarf2_parse()

BOOL dwarf2_parse ( struct module module,
ULONG_PTR  load_offset,
const struct elf_thunk_area thunks,
struct image_file_map fmap 
)

Definition at line 3509 of file dwarf.c.

3512 {
3514  dwarf2_traverse_context_t mod_ctx;
3515  struct image_section_map debug_sect, debug_str_sect, debug_abbrev_sect,
3516  debug_line_sect, debug_ranges_sect, eh_frame_sect;
3517  BOOL ret = TRUE;
3518  struct module_format* dwarf2_modfmt;
3519 
3520  if (!dwarf2_init_section(&eh_frame, fmap, ".eh_frame", NULL, &eh_frame_sect))
3521  /* lld produces .eh_fram to avoid generating a long name */
3522  dwarf2_init_section(&eh_frame, fmap, ".eh_fram", NULL, &eh_frame_sect);
3523  dwarf2_init_section(&section[section_debug], fmap, ".debug_info", ".zdebug_info", &debug_sect);
3524  dwarf2_init_section(&section[section_abbrev], fmap, ".debug_abbrev", ".zdebug_abbrev", &debug_abbrev_sect);
3525  dwarf2_init_section(&section[section_string], fmap, ".debug_str", ".zdebug_str", &debug_str_sect);
3526  dwarf2_init_section(&section[section_line], fmap, ".debug_line", ".zdebug_line", &debug_line_sect);
3527  dwarf2_init_section(&section[section_ranges], fmap, ".debug_ranges", ".zdebug_ranges", &debug_ranges_sect);
3528 
3529  /* to do anything useful we need either .eh_frame or .debug_info */
3530  if ((!eh_frame.address || eh_frame.address == IMAGE_NO_MAP) &&
3531  (!section[section_debug].address || section[section_debug].address == IMAGE_NO_MAP))
3532  {
3533  ret = FALSE;
3534  goto leave;
3535  }
3536 
3537  if (fmap->modtype == DMT_ELF && debug_sect.fmap)
3538  {
3539  /* debug info might have a different base address than .so file
3540  * when elf file is prelinked after splitting off debug info
3541  * adjust symbol base addresses accordingly
3542  */
3543  load_offset += fmap->u.elf.elf_start - debug_sect.fmap->u.elf.elf_start;
3544  }
3545 
3546  TRACE("Loading Dwarf2 information for %s\n", debugstr_w(module->module.ModuleName));
3547 
3548  mod_ctx.data = section[section_debug].address;
3549  mod_ctx.end_data = mod_ctx.data + section[section_debug].size;
3550  mod_ctx.word_size = 0; /* will be correctly set later on */
3551 
3552  dwarf2_modfmt = HeapAlloc(GetProcessHeap(), 0,
3553  sizeof(*dwarf2_modfmt) + sizeof(*dwarf2_modfmt->u.dwarf2_info));
3554  if (!dwarf2_modfmt)
3555  {
3556  ret = FALSE;
3557  goto leave;
3558  }
3559  dwarf2_modfmt->module = module;
3560  dwarf2_modfmt->remove = dwarf2_module_remove;
3561  dwarf2_modfmt->loc_compute = dwarf2_location_compute;
3562  dwarf2_modfmt->u.dwarf2_info = (struct dwarf2_module_info_s*)(dwarf2_modfmt + 1);
3563  dwarf2_modfmt->u.dwarf2_info->word_size = 0; /* will be correctly set later on */
3564  dwarf2_modfmt->module->format_info[DFI_DWARF] = dwarf2_modfmt;
3565 
3566  /* As we'll need later some sections' content, we won't unmap these
3567  * sections upon existing this function
3568  */
3569  dwarf2_init_section(&dwarf2_modfmt->u.dwarf2_info->debug_loc, fmap, ".debug_loc", ".zdebug_loc", NULL);
3570  dwarf2_init_section(&dwarf2_modfmt->u.dwarf2_info->debug_frame, fmap, ".debug_frame", ".zdebug_frame", NULL);
3571  dwarf2_modfmt->u.dwarf2_info->eh_frame = eh_frame;
3572 
3573  while (mod_ctx.data < mod_ctx.end_data)
3574  {
3575  dwarf2_parse_compilation_unit(section, dwarf2_modfmt->module, thunks, &mod_ctx, load_offset);
3576  }
3577  dwarf2_modfmt->module->module.SymType = SymDia;
3578  dwarf2_modfmt->module->module.CVSig = 'D' | ('W' << 8) | ('A' << 16) | ('R' << 24);
3579  /* FIXME: we could have a finer grain here */
3580  dwarf2_modfmt->module->module.GlobalSymbols = TRUE;
3581  dwarf2_modfmt->module->module.TypeInfo = TRUE;
3582  dwarf2_modfmt->module->module.SourceIndexed = TRUE;
3583  dwarf2_modfmt->module->module.Publics = TRUE;
3584 
3585  /* set the word_size for eh_frame parsing */
3586  dwarf2_modfmt->u.dwarf2_info->word_size = fmap->addr_size / 8;
3587 
3588 leave:
3594 
3595  image_unmap_section(&debug_sect);
3596  image_unmap_section(&debug_abbrev_sect);
3597  image_unmap_section(&debug_str_sect);
3598  image_unmap_section(&debug_line_sect);
3599  image_unmap_section(&debug_ranges_sect);
3600  if (!ret) image_unmap_section(&eh_frame_sect);
3601 
3602  return ret;
3603 }
void(* remove)(struct process *pcs, struct module_format *modfmt)
unsigned addr_size
enum module_type modtype
union image_file_map::@376 u
const unsigned char * address
Definition: dwarf.c:159
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:3467
Definition: compat.h:811
WCHAR ModuleName[32]
Definition: compat.h:824
const unsigned char * data
Definition: dwarf.c:168
#define TRUE
Definition: types.h:120
const unsigned char * end_data
Definition: dwarf.c:169
Definition: parser.c:55
#define IMAGE_NO_MAP
Definition: image_private.h:24
static void dwarf2_module_remove(struct process *pcs, struct module_format *modfmt)
Definition: dwarf.c:3502
#define FALSE
Definition: types.h:117
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:484
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 void dwarf2_fini_section(dwarf2_section_t *section)
Definition: dwarf.c:3496
struct dwarf2_module_info_s * dwarf2_info
int ret
static void image_unmap_section(struct image_section_map *ism)
struct image_file_map::@376::elf_file_map elf
dwarf2_section_t eh_frame
Definition: dwarf.c:201
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:3324
unsigned char word_size
Definition: dwarf.c:170
union module_format::@365 u
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, ULONG_PTR load_offset)
Definition: dwarf.c:2371
IMAGEHLP_MODULEW64 module

Referenced by elf_load_debug_info_from_map(), macho_load_debug_info(), and 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 387 of file dwarf.c.

390 {
391  ULONG_PTR entry_code;
392  dwarf2_abbrev_entry_t* abbrev_entry;
396  ULONG_PTR form;
397 
398  assert( NULL != abbrev_ctx );
399 
400  TRACE("%s, end at %p\n",
401  dwarf2_debug_traverse_ctx(abbrev_ctx), abbrev_ctx->end_data);
402 
403  sparse_array_init(abbrev_table, sizeof(dwarf2_abbrev_entry_t), 32);
404  while (abbrev_ctx->data < abbrev_ctx->end_data)
405  {
406  TRACE("now at %s\n", dwarf2_debug_traverse_ctx(abbrev_ctx));
407  entry_code = dwarf2_leb128_as_unsigned(abbrev_ctx);
408  TRACE("found entry_code %lu\n", entry_code);
409  if (!entry_code)
410  {
411  TRACE("NULL entry code at %s\n", dwarf2_debug_traverse_ctx(abbrev_ctx));
412  break;
413  }
414  abbrev_entry = sparse_array_add(abbrev_table, entry_code, pool);
415  assert( NULL != abbrev_entry );
416 
417  abbrev_entry->entry_code = entry_code;
418  abbrev_entry->tag = dwarf2_leb128_as_unsigned(abbrev_ctx);
419  abbrev_entry->have_child = dwarf2_parse_byte(abbrev_ctx);
420  abbrev_entry->attrs = NULL;
421  abbrev_entry->num_attr = 0;
422 
423  TRACE("table:(%p,#%u) entry_code(%lu) tag(0x%lx) have_child(%u) -> %p\n",
424  abbrev_table, sparse_array_length(abbrev_table),
425  entry_code, abbrev_entry->tag, abbrev_entry->have_child, abbrev_entry);
426 
427  last = NULL;
428  while (1)
429  {
430  attribute = dwarf2_leb128_as_unsigned(abbrev_ctx);
431  form = dwarf2_leb128_as_unsigned(abbrev_ctx);
432  if (!attribute) break;
433 
435  assert(new);
436 
437  new->attribute = attribute;
438  new->form = form;
439  new->next = NULL;
440  if (abbrev_entry->attrs) last->next = new;
441  else abbrev_entry->attrs = new;
442  last = new;
443  abbrev_entry->num_attr++;
444  }
445  }
446  TRACE("found %u entries\n", sparse_array_length(abbrev_table));
447 }
unsigned num_attr
Definition: dwarf.c:123
const unsigned char * data
Definition: dwarf.c:168
POINT last
Definition: font.c:46
int form
Definition: main.c:89
#define assert(x)
Definition: debug.h:53
const unsigned char * end_data
Definition: dwarf.c:169
ULONG_PTR tag
Definition: dwarf.c:121
uint32_t ULONG_PTR
Definition: typedefs.h:65
void * pool_alloc(struct pool *a, size_t len) DECLSPEC_HIDDEN
Definition: storage.c:89
static unsigned char dwarf2_parse_byte(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:216
dwarf2_abbrev_entry_attr_t * attrs
Definition: dwarf.c:124
ULONG_PTR form
Definition: dwarf.c:135
smooth NULL
Definition: ftsmooth.c:416
Definition: dwarf.c:118
void * sparse_array_add(struct sparse_array *sa, ULONG_PTR key, struct pool *pool) DECLSPEC_HIDDEN
Definition: storage.c:281
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char have_child
Definition: dwarf.c:122
void sparse_array_init(struct sparse_array *sa, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:213
ULONG_PTR entry_code
Definition: dwarf.c:120
static ULONG_PTR dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:276
unsigned sparse_array_length(const struct sparse_array *sa) DECLSPEC_HIDDEN
Definition: storage.c:314
static const char * dwarf2_debug_traverse_ctx(const dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:362
Definition: dwarf.c:111

Referenced by dwarf2_parse_compilation_unit().

◆ dwarf2_parse_addr()

static ULONG_PTR dwarf2_parse_addr ( dwarf2_traverse_context_t ctx)
static

Definition at line 355 of file dwarf.c.

356 {
357  ULONG_PTR ret = dwarf2_get_addr(ctx->data, ctx->word_size);
358  ctx->data += ctx->word_size;
359  return ret;
360 }
uint32_t ULONG_PTR
Definition: typedefs.h:65
static ULONG_PTR dwarf2_get_addr(const unsigned char *ptr, unsigned word_size)
Definition: dwarf.c:336
int ret

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 1255 of file dwarf.c.

1257 {
1258  struct symt* ref_type;
1259  struct symt* idx_type = NULL;
1260  struct attribute min, max, cnt;
1262  unsigned int i;
1263  const struct vector* children;
1264 
1265  if (di->symt) return di->symt;
1266 
1267  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1268 
1269  ref_type = dwarf2_lookup_type(ctx, di);
1270 
1271  if (!(children = dwarf2_get_di_children(ctx, di)))
1272  {
1273  /* fake an array with unknown size */
1274  /* FIXME: int4 even on 64bit machines??? */
1275  idx_type = ctx->symt_cache[sc_int4];
1276  min.u.uvalue = 0;
1277  max.u.uvalue = -1;
1278  }
1279  else for (i = 0; i < vector_length(children); i++)
1280  {
1281  child = *(dwarf2_debug_info_t**)vector_at(children, i);
1282  switch (child->abbrev->tag)
1283  {
1284  case DW_TAG_subrange_type:
1285  idx_type = dwarf2_lookup_type(ctx, child);
1287  min.u.uvalue = 0;
1289  max.u.uvalue = 0;
1291  max.u.uvalue = min.u.uvalue + cnt.u.uvalue;
1292  break;
1293  default:
1294  FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
1295  child->abbrev->tag, dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1296  break;
1297  }
1298  }
1299  di->symt = &symt_new_array(ctx->module, min.u.uvalue, max.u.uvalue, ref_type, idx_type)->symt;
1300  return di->symt;
1301 }
#define max(a, b)
Definition: svc.c:63
#define sc_int4
Definition: dwarf.c:177
static struct symt * dwarf2_lookup_type(dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di)
Definition: dwarf.c:947
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1145
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:162
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:111
smooth NULL
Definition: ftsmooth.c:416
struct symt * symt
Definition: dwarf.c:150
#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:345
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:373
#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:600
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:367
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:157

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 2595 of file dwarf.c.

2596 {
2597  ULONG_PTR base;
2598 
2599  if (encoding == DW_EH_PE_omit) return 0;
2600 
2601  switch (encoding & 0xf0)
2602  {
2603  case DW_EH_PE_abs:
2604  base = 0;
2605  break;
2606  case DW_EH_PE_pcrel:
2607  base = (ULONG_PTR)ctx->data;
2608  break;
2609  default:
2610  FIXME("unsupported encoding %02x\n", encoding);
2611  return 0;
2612  }
2613 
2614  switch (encoding & 0x0f)
2615  {
2616  case DW_EH_PE_native:
2617  return base + dwarf2_parse_addr(ctx);
2618  case DW_EH_PE_leb128:
2620  case DW_EH_PE_data2:
2621  return base + dwarf2_parse_u2(ctx);
2622  case DW_EH_PE_data4:
2623  return base + dwarf2_parse_u4(ctx);
2624  case DW_EH_PE_data8:
2625  return base + dwarf2_parse_u8(ctx);
2627  return base + dwarf2_leb128_as_signed(ctx);
2629  return base + (signed short)dwarf2_parse_u2(ctx);
2631  return base + (signed int)dwarf2_parse_u4(ctx);
2633  return base + (LONG64)dwarf2_parse_u8(ctx);
2634  default:
2635  FIXME("unsupported encoding %02x\n", encoding);
2636  return 0;
2637  }
2638 }
static ULONG_PTR dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:240
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
GLuint base
Definition: 3dtext.c:35
#define FIXME(fmt,...)
Definition: debug.h:111
#define DW_EH_PE_signed
Definition: dwarf.h:545
int64_t LONG64
Definition: typedefs.h:68
#define DW_EH_PE_data4
Definition: dwarf.h:543
static ULONG_PTR dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:276
#define DW_EH_PE_abs
Definition: dwarf.h:546
#define DW_EH_PE_pcrel
Definition: dwarf.h:547
ed encoding
Definition: write.c:2825
#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:228
#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 ULONG_PTR dwarf2_parse_addr(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:355
static DWORD64 dwarf2_parse_u8(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:252
static LONG_PTR dwarf2_leb128_as_signed(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:312
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 1161 of file dwarf.c.

1163 {
1164  struct attribute name;
1165  struct attribute size;
1166  struct attribute encoding;
1167  enum BasicType bt;
1168  int cache_idx = -1;
1169  if (di->symt) return di->symt;
1170 
1171  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1172 
1174  name.u.string = NULL;
1175  if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &size)) size.u.uvalue = 0;
1177 
1178  switch (encoding.u.uvalue)
1179  {
1180  case DW_ATE_void: bt = btVoid; break;
1181  case DW_ATE_address: bt = btULong; break;
1182  case DW_ATE_boolean: bt = btBool; break;
1183  case DW_ATE_complex_float: bt = btComplex; break;
1184  case DW_ATE_float: bt = btFloat; break;
1185  case DW_ATE_signed: bt = btInt; break;
1186  case DW_ATE_unsigned: bt = btUInt; break;
1187  case DW_ATE_signed_char: bt = btChar; break;
1188  case DW_ATE_unsigned_char: bt = btChar; break;
1189  default: bt = btNoType; break;
1190  }
1191  di->symt = &symt_new_basic(ctx->module, bt, name.u.string, size.u.uvalue)->symt;
1192  switch (bt)
1193  {
1194  case btVoid:
1195  assert(size.u.uvalue == 0);
1196  cache_idx = sc_void;
1197  break;
1198  case btInt:
1199  switch (size.u.uvalue)
1200  {
1201  case 1: cache_idx = sc_int1; break;
1202  case 2: cache_idx = sc_int2; break;
1203  case 4: cache_idx = sc_int4; break;
1204  }
1205  break;
1206  default: break;
1207  }
1208  if (cache_idx != -1 && !ctx->symt_cache[cache_idx])
1209  ctx->symt_cache[cache_idx] = di->symt;
1210 
1211  if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1212  return di->symt;
1213 }
BasicType
Definition: compat.h:1363
#define sc_int4
Definition: dwarf.c:177
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1145
#define assert(x)
Definition: debug.h:53
#define sc_void
Definition: dwarf.c:174
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
struct symt * symt
Definition: dwarf.c:150
struct symt_basic * symt_new_basic(struct module *module, enum BasicType, const char *typename, unsigned size) DECLSPEC_HIDDEN
Definition: type.c:192
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
ed encoding
Definition: write.c:2825
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:373
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:600
Definition: compat.h:1369
Definition: name.c:38
#define sc_int1
Definition: dwarf.c:175
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:367
#define sc_int2
Definition: dwarf.c:176

Referenced by dwarf2_load_one_entry().

◆ dwarf2_parse_byte()

static unsigned char dwarf2_parse_byte ( dwarf2_traverse_context_t ctx)
static

Definition at line 216 of file dwarf.c.

217 {
218  unsigned char uvalue = dwarf2_get_byte(ctx->data);
219  ctx->data += 1;
220  return uvalue;
221 }
static unsigned char dwarf2_get_byte(const unsigned char *ptr)
Definition: dwarf.c:211
ULONG_PTR uvalue
Definition: dwarf.c:139

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,
ULONG_PTR  load_offset 
)
static

Definition at line 2371 of file dwarf.c.

2376 {
2378  dwarf2_traverse_context_t abbrev_ctx;
2379  dwarf2_debug_info_t* di;
2381  const unsigned char* comp_unit_start = mod_ctx->data;
2382  ULONG_PTR cu_length;
2383  unsigned short cu_version;
2384  ULONG_PTR cu_abbrev_offset;
2385  BOOL ret = FALSE;
2386 
2387  cu_length = dwarf2_parse_u4(mod_ctx);
2388  cu_ctx.data = mod_ctx->data;
2389  cu_ctx.end_data = mod_ctx->data + cu_length;
2390  mod_ctx->data += cu_length;
2391  cu_version = dwarf2_parse_u2(&cu_ctx);
2392  cu_abbrev_offset = dwarf2_parse_u4(&cu_ctx);
2393  cu_ctx.word_size = dwarf2_parse_byte(&cu_ctx);
2394 
2395  TRACE("Compilation Unit Header found at 0x%x:\n",
2396  (int)(comp_unit_start - sections[section_debug].address));
2397  TRACE("- length: %lu\n", cu_length);
2398  TRACE("- version: %u\n", cu_version);
2399  TRACE("- abbrev_offset: %lu\n", cu_abbrev_offset);
2400  TRACE("- word_size: %u\n", cu_ctx.word_size);
2401 
2402  if (cu_version != 2)
2403  {
2404  WARN("%u DWARF version unsupported. Wine dbghelp only support DWARF 2.\n",
2405  cu_version);
2406  return FALSE;
2407  }
2408 
2409  module->format_info[DFI_DWARF]->u.dwarf2_info->word_size = cu_ctx.word_size;
2410  mod_ctx->word_size = cu_ctx.word_size;
2411 
2412  pool_init(&ctx.pool, 65536);
2413  ctx.sections = sections;
2414  ctx.section = section_debug;
2415  ctx.module = module;
2416  ctx.thunks = thunks;
2417  ctx.load_offset = load_offset;
2418  ctx.ref_offset = comp_unit_start - sections[section_debug].address;
2419  memset(ctx.symt_cache, 0, sizeof(ctx.symt_cache));
2420  ctx.symt_cache[sc_void] = &symt_new_basic(module, btVoid, "void", 0)->symt;
2421  ctx.cpp_name = NULL;
2422 
2423  abbrev_ctx.data = sections[section_abbrev].address + cu_abbrev_offset;
2424  abbrev_ctx.end_data = sections[section_abbrev].address + sections[section_abbrev].size;
2425  abbrev_ctx.word_size = cu_ctx.word_size;
2426  dwarf2_parse_abbrev_set(&abbrev_ctx, &ctx.abbrev_table, &ctx.pool);
2427 
2428  sparse_array_init(&ctx.debug_info_table, sizeof(dwarf2_debug_info_t), 128);
2429  dwarf2_read_one_debug_info(&ctx, &cu_ctx, NULL, &di);
2430 
2431  if (di->abbrev->tag == DW_TAG_compile_unit)
2432  {
2433  struct attribute name;
2434  struct vector* children;
2436  unsigned int i;
2437  struct attribute stmt_list, low_pc;
2438  struct attribute comp_dir;
2439 
2440  if (!dwarf2_find_attribute(&ctx, di, DW_AT_name, &name))
2441  name.u.string = NULL;
2442 
2443  /* get working directory of current compilation unit */
2444  if (!dwarf2_find_attribute(&ctx, di, DW_AT_comp_dir, &comp_dir))
2445  comp_dir.u.string = NULL;
2446 
2447  if (!dwarf2_find_attribute(&ctx, di, DW_AT_low_pc, &low_pc))
2448  low_pc.u.uvalue = 0;
2449  ctx.compiland = symt_new_compiland(module, ctx.load_offset + low_pc.u.uvalue,
2450  source_new(module, comp_dir.u.string, name.u.string));
2451  di->symt = &ctx.compiland->symt;
2452  children = dwarf2_get_di_children(&ctx, di);
2453  if (children) for (i = 0; i < vector_length(children); i++)
2454  {
2455  child = *(dwarf2_debug_info_t**)vector_at(children, i);
2457  }
2458  if (dwarf2_find_attribute(&ctx, di, DW_AT_stmt_list, &stmt_list))
2459  {
2460 #if defined(__REACTOS__) && defined(__clang__)
2461  unsigned long stmt_list_val = stmt_list.u.uvalue;
2462  if (stmt_list_val > module->module.BaseOfImage)
2463  {
2464  /* FIXME: Clang is recording this as an address, not an offset */
2465  stmt_list_val -= module->module.BaseOfImage + sections[section_line].rva;
2466  }
2467  if (dwarf2_parse_line_numbers(sections, &ctx, comp_dir.u.string, stmt_list_val))
2468 #else
2469  if (dwarf2_parse_line_numbers(sections, &ctx, comp_dir.u.string, stmt_list.u.uvalue))
2470 #endif
2472  }
2473  ret = TRUE;
2474  }
2475  else FIXME("Should have a compilation unit here\n");
2476  pool_destroy(&ctx.pool);
2477  return ret;
2478 }
HMODULE module
Definition: main.cpp:47
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1145
static ULONG_PTR dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:240
const unsigned char * data
Definition: dwarf.c:168
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:818
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:162
#define WARN(fmt,...)
Definition: debug.h:112
const unsigned char * end_data
Definition: dwarf.c:169
static HWND child
Definition: cursoricon.c:298
ULONG_PTR tag
Definition: dwarf.c:121
uint32_t ULONG_PTR
Definition: typedefs.h:65
const dwarf2_abbrev_entry_t * abbrev
Definition: dwarf.c:149
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:216
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
struct section sections[2]
Definition: diskspace.c:792
#define sc_void
Definition: dwarf.c:174
#define FIXME(fmt,...)
Definition: debug.h:111
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:1077
struct symt * symt
Definition: dwarf.c:150
struct symt_basic * symt_new_basic(struct module *module, enum BasicType, const char *typename, unsigned size) DECLSPEC_HIDDEN
Definition: type.c:192
#define TRACE(s)
Definition: solgame.cpp:4
static void dwarf2_load_one_entry(dwarf2_parse_context_t *, dwarf2_debug_info_t *)
Definition: dwarf.c:2091
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:213
int ret
void pool_init(struct pool *a, size_t arena_size) DECLSPEC_HIDDEN
Definition: storage.c:43
void pool_destroy(struct pool *a) DECLSPEC_HIDDEN
Definition: storage.c:50
static unsigned short dwarf2_parse_u2(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:228
static void dwarf2_parse_abbrev_set(dwarf2_traverse_context_t *abbrev_ctx, struct sparse_array *abbrev_table, struct pool *pool)
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:600
unsigned source_new(struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
Definition: source.c:66
Definition: name.c:38
unsigned char word_size
Definition: dwarf.c:170
static BOOL dwarf2_parse_line_numbers(const dwarf2_section_t *sections, dwarf2_parse_context_t *ctx, const char *compile_dir, ULONG_PTR offset)
Definition: dwarf.c:2181
#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:157
struct symt_compiland * symt_new_compiland(struct module *module, ULONG_PTR address, unsigned src_idx) DECLSPEC_HIDDEN
Definition: symbol.c:207

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 1303 of file dwarf.c.

1305 {
1306  struct symt* ref_type;
1307 
1308  if (di->symt) return di->symt;
1309 
1310  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1311 
1312  if (!(ref_type = dwarf2_lookup_type(ctx, di)))
1313  {
1314  ref_type = ctx->symt_cache[sc_void];
1315  assert(ref_type);
1316  }
1317  if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1318  di->symt = ref_type;
1319 
1320  return ref_type;
1321 }
static struct symt * dwarf2_lookup_type(dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di)
Definition: dwarf.c:947
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1145
#define assert(x)
Definition: debug.h:53
#define sc_void
Definition: dwarf.c:174
#define FIXME(fmt,...)
Definition: debug.h:111
struct symt * symt
Definition: dwarf.c:150
#define TRACE(s)
Definition: solgame.cpp:4
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:373
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:367

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 1528 of file dwarf.c.

1530 {
1531  struct attribute name;
1532  struct attribute size;
1533  struct symt_basic* basetype;
1534  struct vector* children;
1536  unsigned int i;
1537 
1538  if (di->symt) return di->symt;
1539 
1540  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1541 
1542  if (!dwarf2_find_attribute(ctx, di, DW_AT_name, &name)) name.u.string = NULL;
1543  if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &size)) size.u.uvalue = 4;
1544 
1545  switch (size.u.uvalue) /* FIXME: that's wrong */
1546  {
1547  case 1: basetype = symt_new_basic(ctx->module, btInt, "char", 1); break;
1548  case 2: basetype = symt_new_basic(ctx->module, btInt, "short", 2); break;
1549  default:
1550  case 4: basetype = symt_new_basic(ctx->module, btInt, "int", 4); break;
1551  }
1552 
1553  di->symt = &symt_new_enum(ctx->module, name.u.string, &basetype->symt)->symt;
1554 
1555  children = dwarf2_get_di_children(ctx, di);
1556  /* FIXME: should we use the sibling stuff ?? */
1557  if (children) for (i = 0; i < vector_length(children); i++)
1558  {
1559  child = *(dwarf2_debug_info_t**)vector_at(children, i);
1560 
1561  switch (child->abbrev->tag)
1562  {
1563  case DW_TAG_enumerator:
1564  dwarf2_parse_enumerator(ctx, child, (struct symt_enum*)di->symt);
1565  break;
1566  default:
1567  FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
1568  di->abbrev->tag, dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1569  }
1570  }
1571  return di->symt;
1572 }
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1145
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:162
static void dwarf2_parse_enumerator(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, struct symt_enum *parent)
Definition: dwarf.c:1512
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:111
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:192
#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:304
struct symt symt
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:373
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:600
Definition: compat.h:1369
Definition: name.c:38
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:367
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:157

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 1512 of file dwarf.c.

1515 {
1516  struct attribute name;
1517  struct attribute value;
1518 
1519  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1520 
1521  if (!dwarf2_find_attribute(ctx, di, DW_AT_name, &name)) return;
1522  if (!dwarf2_find_attribute(ctx, di, DW_AT_const_value, &value)) value.u.svalue = 0;
1523  symt_add_enum_element(ctx->module, parent, name.u.string, value.u.svalue);
1524 
1525  if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1526 }
BOOL symt_add_enum_element(struct module *module, struct symt_enum *enum_type, const char *name, int value) DECLSPEC_HIDDEN
Definition: type.c:319
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1145
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
r parent
Definition: btrfs.c:2944
union value::@490 u
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:373
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:600
Definition: name.c:38
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:367

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 1754 of file dwarf.c.

1757 {
1758  struct symt_block* block;
1759  ULONG_PTR low_pc, high_pc;
1760  struct vector* children;
1762  unsigned int i;
1763 
1764  TRACE("%s, for %s\n", dwarf2_debug_ctx(subpgm->ctx), dwarf2_debug_di(di));
1765 
1766  if (!dwarf2_read_range(subpgm->ctx, di, &low_pc, &high_pc))
1767  {
1768  FIXME("cannot read range\n");
1769  return;
1770  }
1771 
1772  block = symt_open_func_block(subpgm->ctx->module, subpgm->func, parent_block,
1773  subpgm->ctx->load_offset + low_pc - subpgm->func->address,
1774  high_pc - low_pc);
1775 
1776  children = dwarf2_get_di_children(subpgm->ctx, di);
1777  if (children) for (i = 0; i < vector_length(children); i++)
1778  {
1779  child = *(dwarf2_debug_info_t**)vector_at(children, i);
1780 
1781  switch (child->abbrev->tag)
1782  {
1784  case DW_TAG_variable:
1785  dwarf2_parse_variable(subpgm, block, child);
1786  break;
1787  case DW_TAG_lexical_block:
1789  break;
1792  break;
1793  case DW_TAG_label:
1795  break;
1796  case DW_TAG_GNU_call_site:
1797  /* this isn't properly supported by dbghelp interface. skip it for now */
1798  break;
1799  default:
1800  FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
1801  child->abbrev->tag, dwarf2_debug_ctx(subpgm->ctx),
1802  dwarf2_debug_di(di));
1803  }
1804  }
1805  symt_close_func_block(subpgm->ctx->module, subpgm->func, block, 0);
1806 }
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:413
dwarf2_parse_context_t * ctx
Definition: dwarf.c:1577
ULONG_PTR load_offset
Definition: dwarf.c:190
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1145
static BOOL dwarf2_read_range(dwarf2_parse_context_t *ctx, const dwarf2_debug_info_t *di, ULONG_PTR *plow, ULONG_PTR *phigh)
Definition: dwarf.c:1027
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:162
struct module * module
Definition: dwarf.c:185
static void dwarf2_parse_variable(dwarf2_subprogram_t *subpgm, struct symt_block *block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1588
static HWND child
Definition: cursoricon.c:298
uint32_t ULONG_PTR
Definition: typedefs.h:65
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:111
static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t *subpgm, struct symt_block *parent_block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1754
#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:1728
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:373
struct symt_function * func
Definition: dwarf.c:1578
static void dwarf2_parse_subprogram_block(dwarf2_subprogram_t *subpgm, struct symt_block *parent_block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1808
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:440
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:367
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:157

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,
ULONG_PTR  offset 
)
static

Definition at line 2181 of file dwarf.c.

2185 {
2186  dwarf2_traverse_context_t traverse;
2187  ULONG_PTR length;
2188  unsigned insn_size, default_stmt;
2189  unsigned line_range, opcode_base;
2190  int line_base;
2191  const unsigned char* opcode_len;
2192  struct vector dirs;
2193  struct vector files;
2194  const char** p;
2195 
2196  /* section with line numbers stripped */
2198  return FALSE;
2199 
2200  if (offset + 4 > sections[section_line].size)
2201  {
2202  WARN("out of bounds offset\n");
2203  return FALSE;
2204  }
2205  traverse.data = sections[section_line].address + offset;
2206  traverse.end_data = traverse.data + 4;
2207  traverse.word_size = ctx->module->format_info[DFI_DWARF]->u.dwarf2_info->word_size;
2208 
2209  length = dwarf2_parse_u4(&traverse);
2210  traverse.end_data = sections[section_line].address + offset + length;
2211 
2212  if (offset + 4 + length > sections[section_line].size)
2213  {
2214  WARN("out of bounds header\n");
2215  return FALSE;
2216  }
2217  dwarf2_parse_u2(&traverse); /* version */
2218  dwarf2_parse_u4(&traverse); /* header_len */
2219  insn_size = dwarf2_parse_byte(&traverse);
2220  default_stmt = dwarf2_parse_byte(&traverse);
2221  line_base = (signed char)dwarf2_parse_byte(&traverse);
2222  line_range = dwarf2_parse_byte(&traverse);
2223  opcode_base = dwarf2_parse_byte(&traverse);
2224 
2225  opcode_len = traverse.data;
2226  traverse.data += opcode_base - 1;
2227 
2228  vector_init(&dirs, sizeof(const char*), 4);
2229  p = vector_add(&dirs, &ctx->pool);
2230  *p = compile_dir ? compile_dir : ".";
2231  while (*traverse.data)
2232  {
2233  const char* rel = (const char*)traverse.data;
2234  unsigned rellen = strlen(rel);
2235  TRACE("Got include %s\n", debugstr_a(rel));
2236  traverse.data += rellen + 1;
2237  p = vector_add(&dirs, &ctx->pool);
2238 
2239  if (*rel == '/' || !compile_dir)
2240  *p = rel;
2241  else
2242  {
2243  /* include directory relative to compile directory */
2244  unsigned baselen = strlen(compile_dir);
2245  char* tmp = pool_alloc(&ctx->pool, baselen + 1 + rellen + 1);
2246  strcpy(tmp, compile_dir);
2247  if (tmp[baselen - 1] != '/') tmp[baselen++] = '/';
2248  strcpy(&tmp[baselen], rel);
2249  *p = tmp;
2250  }
2251 
2252  }
2253  traverse.data++;
2254 
2255  vector_init(&files, sizeof(unsigned), 16);
2256  while (*traverse.data)
2257  {
2258  unsigned int dir_index, mod_time;
2259  const char* name;
2260  const char* dir;
2261  unsigned* psrc;
2262 
2263  name = (const char*)traverse.data;
2264  traverse.data += strlen(name) + 1;
2265  dir_index = dwarf2_leb128_as_unsigned(&traverse);
2266  mod_time = dwarf2_leb128_as_unsigned(&traverse);
2267  length = dwarf2_leb128_as_unsigned(&traverse);
2268  dir = *(const char**)vector_at(&dirs, dir_index);
2269  TRACE("Got file %s/%s (%u,%lu)\n", debugstr_a(dir), debugstr_a(name), mod_time, length);
2270  psrc = vector_add(&files, &ctx->pool);
2271  *psrc = source_new(ctx->module, dir, name);
2272  }
2273  traverse.data++;
2274 
2275  while (traverse.data < traverse.end_data)
2276  {
2277  ULONG_PTR address = 0;
2278  unsigned file = 1;
2279  unsigned line = 1;
2280  unsigned is_stmt = default_stmt;
2281  BOOL end_sequence = FALSE;
2282  unsigned opcode, extopcode, i;
2283 
2284  while (!end_sequence)
2285  {
2286  opcode = dwarf2_parse_byte(&traverse);
2287  TRACE("Got opcode %x\n", opcode);
2288 
2289  if (opcode >= opcode_base)
2290  {
2291  unsigned delta = opcode - opcode_base;
2292 
2293  address += (delta / line_range) * insn_size;
2294  line += line_base + (delta % line_range);
2295  dwarf2_set_line_number(ctx->module, address, &files, file, line);
2296  }
2297  else
2298  {
2299  switch (opcode)
2300  {
2301  case DW_LNS_copy:
2302  dwarf2_set_line_number(ctx->module, address, &files, file, line);
2303  break;
2304  case DW_LNS_advance_pc:
2305  address += insn_size * dwarf2_leb128_as_unsigned(&traverse);
2306  break;
2307  case DW_LNS_advance_line:
2308  line += dwarf2_leb128_as_signed(&traverse);
2309  break;
2310  case DW_LNS_set_file:
2311  file = dwarf2_leb128_as_unsigned(&traverse);
2312  break;
2313  case DW_LNS_set_column:
2314  dwarf2_leb128_as_unsigned(&traverse);
2315  break;
2316  case DW_LNS_negate_stmt:
2317  is_stmt = !is_stmt;
2318  break;
2320  break;
2321  case DW_LNS_const_add_pc:
2322  address += ((255 - opcode_base) / line_range) * insn_size;
2323  break;
2325  address += dwarf2_parse_u2(&traverse);
2326  break;
2327  case DW_LNS_extended_op:
2328  dwarf2_leb128_as_unsigned(&traverse);
2329  extopcode = dwarf2_parse_byte(&traverse);
2330  switch (extopcode)
2331  {
2332  case DW_LNE_end_sequence:
2333  dwarf2_set_line_number(ctx->module, address, &files, file, line);
2334  end_sequence = TRUE;
2335  break;
2336  case DW_LNE_set_address:
2337  address = ctx->load_offset + dwarf2_parse_addr(&traverse);
2338  break;
2339  case DW_LNE_define_file:
2340  FIXME("not handled define file %s\n", debugstr_a((char *)traverse.data));
2341  traverse.data += strlen((const char *)traverse.data) + 1;
2342  dwarf2_leb128_as_unsigned(&traverse);
2343  dwarf2_leb128_as_unsigned(&traverse);
2344  dwarf2_leb128_as_unsigned(&traverse);
2345  break;
2347  {
2348  unsigned descr;
2349 
2350  descr = dwarf2_leb128_as_unsigned(&traverse);
2351  WARN("not handled discriminator %x\n", descr);
2352  }
2353  break;
2354  default:
2355  FIXME("Unsupported extended opcode %x\n", extopcode);
2356  break;
2357  }
2358  break;
2359  default:
2360  WARN("Unsupported opcode %x\n", opcode);
2361  for (i = 0; i < opcode_len[opcode]; i++)
2362  dwarf2_leb128_as_unsigned(&traverse);
2363  break;
2364  }
2365  }
2366  }
2367  }
2368  return TRUE;
2369 }
static ULONG_PTR dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:240
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const unsigned char * data
Definition: dwarf.c:168
#define TRUE
Definition: types.h:120
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:162
#define WARN(fmt,...)
Definition: debug.h:112
GLintptr offset
Definition: glext.h:5920
#define DW_LNE_set_discriminator
Definition: dwarf.h:501
const unsigned char * end_data
Definition: dwarf.c:169
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IMAGE_NO_MAP
Definition: image_private.h:24
void * pool_alloc(struct pool *a, size_t len) DECLSPEC_HIDDEN
Definition: storage.c:89
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:216
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
struct section sections[2]
Definition: diskspace.c:792
#define FIXME(fmt,...)
Definition: debug.h:111
unsigned char
Definition: typeof.h:29
void vector_init(struct vector *v, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:133
Definition: parser.c:48
unsigned int dir
Definition: maze.c:112
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_a
Definition: kernel32.h:31
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
const char * descr
Definition: boot.c:45
GLuint address
Definition: glext.h:9393
static ULONG_PTR dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:276
void * vector_add(struct vector *v, struct pool *pool) DECLSPEC_HIDDEN
Definition: storage.c:171
static unsigned short dwarf2_parse_u2(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:228
unsigned source_new(struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
Definition: source.c:66
Definition: name.c:38
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned char word_size
Definition: dwarf.c:170
static ULONG_PTR dwarf2_parse_addr(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:355
GLfloat GLfloat p
Definition: glext.h:8902
static LONG_PTR dwarf2_leb128_as_signed(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:312
static void dwarf2_set_line_number(struct module *module, ULONG_PTR address, const struct vector *v, unsigned file, unsigned line)
Definition: dwarf.c:2164
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 2070 of file dwarf.c.

2072 {
2073  struct vector* children;
2075  unsigned int i;
2076 
2077  if (di->symt) return;
2078 
2079  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
2080 
2081  di->symt = ctx->symt_cache[sc_void];
2082 
2083  children = dwarf2_get_di_children(ctx, di);
2084  if (children) for (i = 0; i < vector_length(children); i++)
2085  {
2086  child = *(dwarf2_debug_info_t**)vector_at(children, i);
2088  }
2089 }
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1145
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:162
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:174
struct symt * symt
Definition: dwarf.c:150
#define TRACE(s)
Definition: solgame.cpp:4
static void dwarf2_load_one_entry(dwarf2_parse_context_t *, dwarf2_debug_info_t *)
Definition: dwarf.c:2091
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:373
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:367
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:157

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 1234 of file dwarf.c.

1236 {
1237  struct symt* ref_type;
1238  struct attribute size;
1239 
1240  if (di->symt) return di->symt;
1241 
1242  TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1243 
1244  if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &size)) size.u.uvalue = sizeof(void *);
1245  if (!(ref_type = dwarf2_lookup_type(ctx, di)))