ReactOS 0.4.15-dev-7924-g5949c20
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.

@ section_line
Definition: dwarf.c:164
@ section_max
Definition: dwarf.c:164
@ section_string
Definition: dwarf.c:164
@ section_abbrev
Definition: dwarf.c:164
@ section_debug
Definition: dwarf.c:164
@ section_ranges
Definition: dwarf.c:164

◆ 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};
@ RULE_UNSET
Definition: dwarf.c:2558
@ RULE_OTHER_REG
Definition: dwarf.c:2562
@ RULE_SAME
Definition: dwarf.c:2560
@ RULE_EXPRESSION
Definition: dwarf.c:2563
@ RULE_UNDEFINED
Definition: dwarf.c:2559
@ RULE_CFA_OFFSET
Definition: dwarf.c:2561
@ RULE_VAL_EXPRESSION
Definition: dwarf.c:2564

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;
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;
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;
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}
static int state
Definition: maze.c:121
#define WARN(fmt,...)
Definition: debug.h:112
BOOL sw_read_mem(struct cpu_stack_walk *csw, DWORD64 addr, void *ptr, DWORD sz) DECLSPEC_HIDDEN
Definition: stack.c:95
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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
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 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
#define NB_FRAME_REGS
Definition: dwarf.c:2568
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
Definition: http.c:7252
struct cpu * cpu
uint32_t ULONG_PTR
Definition: typedefs.h:65
Definition: pdh_main.c:94

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;
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;
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}
signed int INT32
signed long long INT64
#define FIXME(fmt,...)
Definition: debug.h:111
Definition: _stack.h:55
@ loc_regrel
@ loc_register
@ loc_absolute
@ loc_err_cant_read
@ loc_err_too_complex
@ loc_err_internal
#define NULL
Definition: types.h:112
UINT op
Definition: effect.c:236
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
struct cpu * dbghelp_current_cpu
Definition: dbghelp.c:169
@ DW_OP_regx
Definition: dwarf.h:436
@ DW_OP_skip
Definition: dwarf.h:339
@ DW_OP_bra
Definition: dwarf.h:332
@ DW_OP_breg31
Definition: dwarf.h:435
@ DW_OP_reg0
Definition: dwarf.h:372
@ DW_OP_const4s
Definition: dwarf.h:305
@ DW_OP_minus
Definition: dwarf.h:320
@ DW_OP_bregx
Definition: dwarf.h:438
@ DW_OP_abs
Definition: dwarf.h:317
@ DW_OP_or
Definition: dwarf.h:325
@ DW_OP_const1u
Definition: dwarf.h:300
@ DW_OP_const2s
Definition: dwarf.h:303
@ DW_OP_swap
Definition: dwarf.h:314
@ DW_OP_const4u
Definition: dwarf.h:304
@ DW_OP_rot
Definition: dwarf.h:315
@ DW_OP_drop
Definition: dwarf.h:311
@ DW_OP_nop
Definition: dwarf.h:442
@ DW_OP_plus_uconst
Definition: dwarf.h:327
@ DW_OP_plus
Definition: dwarf.h:326
@ DW_OP_stack_value
Definition: dwarf.h:453
@ DW_OP_ge
Definition: dwarf.h:334
@ DW_OP_shl
Definition: dwarf.h:328
@ DW_OP_xor
Definition: dwarf.h:331
@ DW_OP_addr
Definition: dwarf.h:298
@ DW_OP_and
Definition: dwarf.h:318
@ DW_OP_const8s
Definition: dwarf.h:307
@ DW_OP_ne
Definition: dwarf.h:338
@ DW_OP_pick
Definition: dwarf.h:313
@ DW_OP_lt
Definition: dwarf.h:337
@ DW_OP_deref_size
Definition: dwarf.h:440
@ DW_OP_fbreg
Definition: dwarf.h:437
@ DW_OP_neg
Definition: dwarf.h:323
@ DW_OP_reg31
Definition: dwarf.h:403
@ DW_OP_consts
Definition: dwarf.h:309
@ DW_OP_div
Definition: dwarf.h:319
@ DW_OP_constu
Definition: dwarf.h:308
@ DW_OP_piece
Definition: dwarf.h:439
@ DW_OP_shra
Definition: dwarf.h:330
@ DW_OP_mod
Definition: dwarf.h:321
@ DW_OP_const2u
Definition: dwarf.h:302
@ DW_OP_breg0
Definition: dwarf.h:404
@ DW_OP_shr
Definition: dwarf.h:329
@ DW_OP_gt
Definition: dwarf.h:335
@ DW_OP_lit31
Definition: dwarf.h:371
@ DW_OP_deref
Definition: dwarf.h:299
@ DW_OP_lit0
Definition: dwarf.h:340
@ DW_OP_not
Definition: dwarf.h:324
@ DW_OP_over
Definition: dwarf.h:312
@ DW_OP_const8u
Definition: dwarf.h:306
@ DW_OP_dup
Definition: dwarf.h:310
@ DW_OP_le
Definition: dwarf.h:336
@ DW_OP_const1s
Definition: dwarf.h:301
@ DW_OP_mul
Definition: dwarf.h:322
@ DW_OP_eq
Definition: dwarf.h:333
#define DW_OP_lo_user
Definition: dwarf2.h:535
static ULONG_PTR dwarf2_parse_addr(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:355
#define Wine_DW_no_register
Definition: dwarf.c:642
static ULONG_PTR dwarf2_parse_u4(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:240
static ULONG_PTR dwarf2_leb128_as_unsigned(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:276
static unsigned short dwarf2_parse_u2(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:228
#define loc_dwarf2_block
Definition: dwarf.c:206
static LONG_PTR dwarf2_leb128_as_signed(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:312
static DWORD64 dwarf2_parse_u8(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:252
static unsigned dwarf2_map_register(int regno, const struct module *module)
Definition: dwarf.c:644
static unsigned char dwarf2_parse_byte(dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:216
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum const GLvoid * addr
Definition: glext.h:9621
_Check_return_ long long __cdecl llabs(_In_ long long x)
Definition: stdlib.h:1435
ULONG_PTR offset
unsigned reg
unsigned kind
uint32_t DWORD_PTR
Definition: typedefs.h:65
uint64_t DWORD64
Definition: typedefs.h:67
unsigned char BYTE
Definition: xxhash.c:193

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 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}
void * sparse_array_find(const struct sparse_array *sa, ULONG_PTR idx) DECLSPEC_HIDDEN
Definition: storage.c:271
#define assert(x)
Definition: debug.h:53

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:
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}
void * pool_alloc(struct pool *a, size_t len) DECLSPEC_HIDDEN
Definition: storage.c:89
@ DFI_DWARF
@ loc_error
location_error
@ DW_FORM_data2
Definition: dwarf.h:249
@ DW_FORM_data8
Definition: dwarf.h:251
@ DW_FORM_block1
Definition: dwarf.h:254
@ DW_FORM_udata
Definition: dwarf.h:259
@ DW_FORM_block4
Definition: dwarf.h:248
@ DW_FORM_data4
Definition: dwarf.h:250
@ DW_FORM_block
Definition: dwarf.h:253
@ DW_FORM_data1
Definition: dwarf.h:255
@ DW_FORM_sdata
Definition: dwarf.h:257
@ DW_FORM_block2
Definition: dwarf.h:247
#define ULONG_PTR
Definition: config.h:101
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_location_list
Definition: dwarf.c:205
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
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
static PVOID ptr
Definition: dispmode.c:27
#define err(...)
unsigned char word_size
Definition: dwarf.c:170
const unsigned char * end_data
Definition: dwarf.c:169
const unsigned char * data
Definition: dwarf.c:168

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}

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
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}
@ DW_FORM_ref8
Definition: dwarf.h:264
@ DW_FORM_ref_addr
Definition: dwarf.h:260
@ DW_FORM_string
Definition: dwarf.h:252
@ DW_FORM_addr
Definition: dwarf.h:246
@ DW_FORM_ref1
Definition: dwarf.h:261
@ DW_FORM_ref_udata
Definition: dwarf.h:265
@ DW_FORM_flag_present
Definition: dwarf.h:270
@ DW_FORM_strp
Definition: dwarf.h:258
@ DW_FORM_ref2
Definition: dwarf.h:262
@ DW_FORM_ref4
Definition: dwarf.h:263
@ DW_FORM_flag
Definition: dwarf.h:256
static unsigned short dwarf2_get_u2(const unsigned char *ptr)
Definition: dwarf.c:223
static LONG_PTR dwarf2_get_leb128_as_signed(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:287
static DWORD64 dwarf2_get_u8(const unsigned char *ptr)
Definition: dwarf.c:247
static ULONG_PTR dwarf2_get_addr(const unsigned char *ptr, unsigned word_size)
Definition: dwarf.c:336
static ULONG_PTR dwarf2_get_leb128_as_unsigned(const unsigned char *ptr, const unsigned char **end)
Definition: dwarf.c:259
static ULONG_PTR dwarf2_get_u4(const unsigned char *ptr)
Definition: dwarf.c:235
static unsigned char dwarf2_get_byte(const unsigned char *ptr)
Definition: dwarf.c:211
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLintptr offset
Definition: glext.h:5920
#define debugstr_a
Definition: kernel32.h:31
#define TRACE(s)
Definition: solgame.cpp:4
Definition: cookie.c:202
ULONG_PTR form
Definition: dwarf.c:114

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) ?
628 attr_abstract_origin : attr_specification;
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}
@ DW_AT_sibling
Definition: dwarf.h:106
@ DW_AT_abstract_origin
Definition: dwarf.h:139
@ DW_AT_specification
Definition: dwarf.h:161
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: dwarf.c:112
struct dwarf2_abbrev_entry_attr_s * next
Definition: dwarf.c:115
ULONG_PTR attribute
Definition: dwarf.c:113
dwarf2_abbrev_entry_attr_t * attrs
Definition: dwarf.c:124
const unsigned char ** data
Definition: dwarf.c:151

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}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
Definition: parser.c:56

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{
339
340 switch (word_size)
341 {
342 case 4:
344 break;
345 case 8:
347 break;
348 default:
349 FIXME("Unsupported Word Size %u\n", word_size);
350 ret = 0;
351 }
352 return ret;
353}
int ret

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

◆ dwarf2_get_byte()

static unsigned char dwarf2_get_byte ( const unsigned char ptr)
static

Definition at line 211 of file dwarf.c.

212{
213 return *ptr;
214}

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}
_In_ fcb _In_ chunk _In_ uint64_t start_data
Definition: btrfs_drv.h:1364
#define DW_CIE_ID
Definition: dwarf.h:503
static ULONG_PTR dwarf2_parse_augmentation_ptr(dwarf2_traverse_context_t *ctx, unsigned char encoding)
Definition: dwarf.c:2595
static BOOL parse_cie_details(dwarf2_traverse_context_t *ctx, struct frame_info *info)
Definition: dwarf.c:2640
GLuint start
Definition: gl.h:1545
GLenum GLint * range
Definition: glext.h:7539
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
if(dx< 0)
Definition: linetemp.h:194

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:
1001 case DW_TAG_class_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
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define MAX_SYM_NAME
Definition: compat.h:975
@ DW_TAG_union_type
Definition: dwarf.h:42
@ DW_TAG_namespace
Definition: dwarf.h:77
@ DW_TAG_interface_type
Definition: dwarf.h:76
@ DW_TAG_compile_unit
Definition: dwarf.h:37
@ DW_TAG_class_type
Definition: dwarf.h:27
@ DW_TAG_structure_type
Definition: dwarf.h:39
@ DW_AT_name
Definition: dwarf.h:108
static UINT UINT last
Definition: font.c:45
@ attr_direct
Definition: dwarf.c:136
ULONG_PTR tag
Definition: dwarf.c:121
struct dwarf2_debug_info_s * parent
Definition: dwarf.c:153
Definition: name.c:39

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

◆ dwarf2_get_di_children()

◆ 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 byte(x, n)
Definition: tomcrypt.h:118
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLuint GLuint end
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
#define shift
Definition: input.c:1755
__int3264 LONG_PTR
Definition: mstsclib_h.h:276

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}

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}
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

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}
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}
static BOOL dwarf2_init_zsection(dwarf2_section_t *section, const char *zsectname, struct image_section_map *ism)
Definition: dwarf.c:3396
static BOOL image_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism)
static const char * image_map_section(struct image_section_map *ism)
static DWORD_PTR image_get_map_rva(const struct image_section_map *ism)
static unsigned image_get_map_size(const struct image_section_map *ism)
struct image_file_map * fmap

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;
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
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
3457out_end:
3458 inflateEnd(&z);
3459out_free:
3460 if (!ret)
3462out:
3464 return ret;
3465}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERR(fmt,...)
Definition: debug.h:110
#define RtlUlongByteSwap(_x)
Definition: compat.h:815
#define HeapAlloc
Definition: compat.h:733
int inflate(z_streamp strm, int flush)
Definition: inflate.c:1257
int inflateEnd(z_streamp strm)
Definition: inflate.c:1910
#define Z_STREAM_END
Definition: zlib.h:115
#define Z_FINISH
Definition: zlib.h:109
#define Z_OK
Definition: zlib.h:114
static void * zalloc(void *priv, uInt items, uInt sz)
Definition: dwarf.c:3386
static void zfree(void *priv, void *addr)
Definition: dwarf.c:3391
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
GLuint res
Definition: glext.h:9613
GLdouble GLdouble z
Definition: glext.h:5874
static void image_unmap_section(struct image_section_map *ism)
static FILE * out
Definition: regtests2xml.c:44
#define inflateInit(strm)
Definition: zlib.h:1812
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2295 u

Referenced by dwarf2_init_section().

◆ dwarf2_leb128_as_signed()

static LONG_PTR dwarf2_leb128_as_signed ( dwarf2_traverse_context_t ctx)
static

◆ dwarf2_leb128_as_unsigned()

◆ 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}

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;
2104 break;
2105 case DW_TAG_class_type:
2107 break;
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;
2122 break;
2125 break;
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}
@ UdtStruct
Definition: compat.h:1640
@ UdtClass
Definition: compat.h:1641
@ UdtUnion
Definition: compat.h:1642
@ DW_TAG_pointer_type
Definition: dwarf.h:35
@ DW_TAG_enumeration_type
Definition: dwarf.h:29
@ DW_TAG_array_type
Definition: dwarf.h:26
@ DW_TAG_volatile_type
Definition: dwarf.h:72
@ DW_TAG_subprogram
Definition: dwarf.h:65
@ DW_TAG_imported_module
Definition: dwarf.h:78
@ DW_TAG_imported_declaration
Definition: dwarf.h:31
@ DW_TAG_variable
Definition: dwarf.h:71
@ DW_TAG_ptr_to_member_type
Definition: dwarf.h:50
@ DW_TAG_base_type
Definition: dwarf.h:55
@ DW_TAG_subroutine_type
Definition: dwarf.h:40
@ DW_TAG_reference_type
Definition: dwarf.h:36
@ DW_TAG_unspecified_type
Definition: dwarf.h:79
@ DW_TAG_const_type
Definition: dwarf.h:57
@ DW_TAG_typedef
Definition: dwarf.h:41
static struct symt * dwarf2_parse_reference_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1368
static struct symt * dwarf2_parse_pointer_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1234
static const char * dwarf2_debug_ctx(const dwarf2_parse_context_t *ctx)
Definition: dwarf.c:367
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_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
static struct symt * dwarf2_parse_array_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1255
static struct symt * dwarf2_parse_typedef(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1215
static struct symt * dwarf2_parse_volatile_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1323
static struct symt * dwarf2_parse_subprogram(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1890
static struct symt * dwarf2_parse_const_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1303
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_subroutine_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:2028
static struct symt * dwarf2_parse_base_type(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1161
ULONG_PTR entry_code
Definition: dwarf.c:120
struct location frame
Definition: dwarf.c:1580
dwarf2_parse_context_t * ctx
Definition: dwarf.c:1577
struct symt_function * func
Definition: dwarf.c:1578

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}
@ loc_err_out_of_scope
@ SymTagCompiland
Definition: compat.h:1583
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 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
GLenum func
Definition: glext.h:6028
ULONG64 InstructionOffset
Definition: compat.h:1376
Definition: dhcpd.h:62
struct module * module
struct dwarf2_module_info_s * dwarf2_info
union module_format::@374 u
IMAGEHLP_STACK_FRAME ctx_frame
HANDLE handle

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

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}
@ DW_AT_type
Definition: dwarf.h:163
static void dwarf2_load_one_entry(dwarf2_parse_context_t *, dwarf2_debug_info_t *)
Definition: dwarf.c:2091
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

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}

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}
static void dwarf2_fini_section(dwarf2_section_t *section)
Definition: dwarf.c:3496

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{
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
3588leave:
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}
#define leave
Definition: btrfs_drv.h:138
@ DMT_ELF
@ SymDia
Definition: compat.h:1063
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
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
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
static void dwarf2_module_remove(struct process *pcs, struct module_format *modfmt)
Definition: dwarf.c:3502
#define IMAGE_NO_MAP
Definition: image_private.h:24
WCHAR ModuleName[32]
Definition: compat.h:1076
dwarf2_section_t eh_frame
Definition: dwarf.c:201
const unsigned char * address
Definition: dwarf.c:159
enum module_type modtype
union image_file_map::@385 u
struct image_file_map::@385::elf_file_map elf
unsigned addr_size
void(* loc_compute)(struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
void(* remove)(struct process *pcs, struct module_format *modfmt)
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;
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 {
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}
void sparse_array_init(struct sparse_array *sa, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:213
unsigned sparse_array_length(const struct sparse_array *sa) DECLSPEC_HIDDEN
Definition: storage.c:314
void * sparse_array_add(struct sparse_array *sa, ULONG_PTR key, struct pool *pool) DECLSPEC_HIDDEN
Definition: storage.c:281
static const char * dwarf2_debug_traverse_ctx(const dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:362
int form
Definition: main.c:89
ULONG_PTR form
Definition: dwarf.c:135
Definition: dwarf.c:119
unsigned num_attr
Definition: dwarf.c:123

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}

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 {
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}
unsigned vector_length(const struct vector *v) DECLSPEC_HIDDEN
Definition: storage.c:157
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
void * vector_at(const struct vector *v, unsigned pos) DECLSPEC_HIDDEN
Definition: storage.c:162
@ DW_TAG_subrange_type
Definition: dwarf.h:52
@ DW_AT_count
Definition: dwarf.h:145
@ DW_AT_lower_bound
Definition: dwarf.h:132
@ DW_AT_upper_bound
Definition: dwarf.h:138
static const char * dwarf2_debug_di(const dwarf2_debug_info_t *di)
Definition: dwarf.c:373
static struct vector * dwarf2_get_di_children(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di)
Definition: dwarf.c:1145
#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 HWND child
Definition: cursoricon.c:298
#define min(a, b)
Definition: monoChain.cc:55
#define max(a, b)
Definition: svc.c:63

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{
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);
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}
#define DW_EH_PE_pcrel
Definition: dwarf.h:547
#define DW_EH_PE_omit
Definition: dwarf.h:553
#define DW_EH_PE_data4
Definition: dwarf.h:543
#define DW_EH_PE_native
Definition: dwarf.h:540
#define DW_EH_PE_data2
Definition: dwarf.h:542
#define DW_EH_PE_abs
Definition: dwarf.h:546
#define DW_EH_PE_data8
Definition: dwarf.h:544
#define DW_EH_PE_signed
Definition: dwarf.h:545
#define DW_EH_PE_leb128
Definition: dwarf.h:541
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
int64_t LONG64
Definition: typedefs.h:68
static char * encoding
Definition: xmllint.c:155

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}
struct symt_basic * symt_new_basic(struct module *module, enum BasicType, const char *typename, unsigned size) DECLSPEC_HIDDEN
Definition: type.c:192
BasicType
Definition: compat.h:1616
@ btVoid
Definition: compat.h:1618
@ btUInt
Definition: compat.h:1622
@ btULong
Definition: compat.h:1627
@ btChar
Definition: compat.h:1619
@ btNoType
Definition: compat.h:1617
@ btComplex
Definition: compat.h:1631
@ btBool
Definition: compat.h:1625
@ btInt
Definition: compat.h:1621
@ btFloat
Definition: compat.h:1623
@ DW_ATE_signed
Definition: dwarf.h:282
@ DW_ATE_signed_char
Definition: dwarf.h:283
@ DW_ATE_address
Definition: dwarf.h:278
@ DW_ATE_unsigned_char
Definition: dwarf.h:285
@ DW_ATE_float
Definition: dwarf.h:281
@ DW_ATE_complex_float
Definition: dwarf.h:280
@ DW_ATE_void
Definition: dwarf.h:277
@ DW_ATE_unsigned
Definition: dwarf.h:284
@ DW_ATE_boolean
Definition: dwarf.h:279
@ DW_AT_byte_size
Definition: dwarf.h:111
@ DW_AT_encoding
Definition: dwarf.h:152
#define sc_int1
Definition: dwarf.c:175
#define sc_void
Definition: dwarf.c:174
#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}

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;
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
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}
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
unsigned source_new(struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
Definition: source.c:66
struct symt_compiland * symt_new_compiland(struct module *module, ULONG_PTR address, unsigned src_idx) DECLSPEC_HIDDEN
Definition: symbol.c:207
@ DW_AT_low_pc
Definition: dwarf.h:116
@ DW_AT_comp_dir
Definition: dwarf.h:126
@ DW_AT_stmt_list
Definition: dwarf.h:115
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
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
static void dwarf2_parse_abbrev_set(dwarf2_traverse_context_t *abbrev_ctx, struct sparse_array *abbrev_table, struct pool *pool)
Definition: dwarf.c:387
GLuint address
Definition: glext.h:9393
struct section sections[2]
Definition: diskspace.c:792
#define memset(x, y, z)
Definition: compat.h:39
DWORD64 BaseOfImage
Definition: compat.h:1070
struct module_format * format_info[DFI_LAST]

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}

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}
struct symt_enum * symt_new_enum(struct module *module, const char *typename, struct symt *basetype) DECLSPEC_HIDDEN
Definition: type.c:304
@ DW_TAG_enumerator
Definition: dwarf.h:59
static void dwarf2_parse_enumerator(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, struct symt_enum *parent)
Definition: dwarf.c:1512
struct symt symt

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
@ DW_AT_const_value
Definition: dwarf.h:127
r parent
Definition: btrfs.c:3010

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:
1786 break;
1789 break;
1792 break;
1793 case DW_TAG_label:
1795 break;
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}
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
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
@ DW_TAG_lexical_block
Definition: dwarf.h:33
@ DW_TAG_formal_parameter
Definition: dwarf.h:30
@ DW_TAG_GNU_call_site
Definition: dwarf.h:100
@ DW_TAG_label
Definition: dwarf.h:32
@ DW_TAG_inlined_subroutine
Definition: dwarf.h:48
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
static void dwarf2_parse_subprogram_block(dwarf2_subprogram_t *subpgm, struct symt_block *parent_block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1808
static void dwarf2_parse_subprogram_label(dwarf2_subprogram_t *subpgm, const dwarf2_debug_info_t *di)
Definition: dwarf.c:1728
static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t *subpgm, struct symt_block *parent_block, dwarf2_debug_info_t *di)
Definition: dwarf.c:1754
ULONG_PTR load_offset
Definition: dwarf.c:190
struct module * module
Definition: dwarf.c:185
static unsigned int block
Definition: xmlmemory.c:101

Referenced by dwarf2_parse_inlined_subroutine(), 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{
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;
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;
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 {
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}
unsigned int dir
Definition: maze.c:112
void vector_init(struct vector *v, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:133
void * vector_add(struct vector *v, struct pool *pool) DECLSPEC_HIDDEN
Definition: storage.c:171
#define DW_LNE_set_address
Definition: dwarf.h:498
#define DW_LNS_set_column
Definition: dwarf.h:487
#define DW_LNS_advance_pc
Definition: dwarf.h:484
#define DW_LNS_advance_line
Definition: dwarf.h:485
#define DW_LNS_set_file
Definition: dwarf.h:486
#define DW_LNS_copy
Definition: dwarf.h:483
#define DW_LNS_negate_stmt
Definition: dwarf.h:488
#define DW_LNE_set_discriminator
Definition: dwarf.h:501
#define DW_LNS_extended_op
Definition: dwarf.h:482
#define DW_LNS_fixed_advance_pc
Definition: dwarf.h:491
#define DW_LNE_define_file
Definition: dwarf.h:499
#define DW_LNS_set_basic_block
Definition: dwarf.h:489
#define DW_LNE_end_sequence
Definition: dwarf.h:497
#define DW_LNS_const_add_pc
Definition: dwarf.h:490
unsigned char
Definition: typeof.h:29
static void dwarf2_set_line_number(struct module *module, ULONG_PTR address, const struct vector *v, unsigned file, unsigned line)
Definition: dwarf.c:2164
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLfloat GLfloat p
Definition: glext.h:8902
const char * descr
Definition: boot.c:45
Definition: fci.c:127
Definition: parser.c:49

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}

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)))
1246 {
1247 ref_type = ctx->symt_cache[sc_void];
1248 assert(ref_type);
1249 }
1250 di->symt = &symt_new_pointer(ctx->module, ref_type, size.u.uvalue)->symt;
1251 if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1252 return di->symt;
1253}
struct symt_pointer * symt_new_pointer(struct module *module, struct symt *ref_type, ULONG_PTR size) DECLSPEC_HIDDEN
Definition: type.c:414

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

◆ dwarf2_parse_reference_type()

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

Definition at line 1368 of file dwarf.c.

1370{
1371 struct symt* ref_type = NULL;
1372
1373 if (di->symt) return di->symt;
1374
1375 TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1376
1377 ref_type = dwarf2_lookup_type(ctx, di);
1378 /* FIXME: for now, we hard-wire C++ references to pointers */
1379 di->symt = &symt_new_pointer(ctx->module, ref_type, sizeof(void *))->symt;
1380
1381 if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1382
1383 return di->symt;
1384}

Referenced by dwarf2_load_one_entry().

◆ dwarf2_parse_subprogram()

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

Definition at line 1890 of file dwarf.c.

1892{
1893 struct attribute name;
1894 ULONG_PTR low_pc, high_pc;
1895 struct attribute is_decl;
1896 struct attribute inline_flags;
1897 struct symt* ret_type;
1898 struct symt_function_signature* sig_type;
1899 dwarf2_subprogram_t subpgm;
1900 struct vector* children;
1902 unsigned int i;
1903
1904 if (di->symt) return di->symt;
1905
1906 TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1907
1909 {
1910 WARN("No name for function... dropping function\n");
1911 return NULL;
1912 }
1913 /* if it's an abstract representation of an inline function, there should be
1914 * a concrete object that we'll handle
1915 */
1916 if (dwarf2_find_attribute(ctx, di, DW_AT_inline, &inline_flags) &&
1917 inline_flags.u.uvalue != DW_INL_not_inlined)
1918 {
1919 TRACE("Function %s declared as inlined (%ld)... skipping\n",
1920 debugstr_a(name.u.string), inline_flags.u.uvalue);
1921 return NULL;
1922 }
1923
1924 if (dwarf2_find_attribute(ctx, di, DW_AT_declaration, &is_decl) &&
1925 is_decl.u.uvalue && is_decl.gotten_from == attr_direct)
1926 {
1927 /* it's a real declaration, skip it */
1928 return NULL;
1929 }
1930 if (!dwarf2_read_range(ctx, di, &low_pc, &high_pc))
1931 {
1932 WARN("cannot get range for %s\n", debugstr_a(name.u.string));
1933 return NULL;
1934 }
1935 /* As functions (defined as inline assembly) get debug info with dwarf
1936 * (not the case for stabs), we just drop Wine's thunks here...
1937 * Actual thunks will be created in elf_module from the symbol table
1938 */
1939#ifndef __REACTOS__
1940 if (elf_is_in_thunk_area(ctx->load_offset + low_pc, ctx->thunks) >= 0)
1941 return NULL;
1942#endif
1943 if (!(ret_type = dwarf2_lookup_type(ctx, di)))
1944 {
1945 ret_type = ctx->symt_cache[sc_void];
1946 assert(ret_type);
1947 }
1948 /* FIXME: assuming C source code */
1949 sig_type = symt_new_function_signature(ctx->module, ret_type, CV_CALL_FAR_C);
1950 subpgm.func = symt_new_function(ctx->module, ctx->compiland,
1951 dwarf2_get_cpp_name(ctx, di, name.u.string),
1952 ctx->load_offset + low_pc, high_pc - low_pc,
1953 &sig_type->symt);
1954 di->symt = &subpgm.func->symt;
1955 subpgm.ctx = ctx;
1957 &subpgm.frame, NULL))
1958 {
1959 /* on stack !! */
1960 subpgm.frame.kind = loc_regrel;
1961 subpgm.frame.reg = dbghelp_current_cpu->frame_regno;
1962 subpgm.frame.offset = 0;
1963 }
1965
1966 children = dwarf2_get_di_children(ctx, di);
1967 if (children) for (i = 0; i < vector_length(children); i++)
1968 {
1969 child = *(dwarf2_debug_info_t**)vector_at(children, i);
1970
1971 switch (child->abbrev->tag)
1972 {
1973 case DW_TAG_variable:
1975 dwarf2_parse_variable(&subpgm, NULL, child);
1976 break;
1979 break;
1982 break;
1984 dwarf2_parse_pointer_type(subpgm.ctx, di);
1985 break;
1986 case DW_TAG_const_type:
1987 dwarf2_parse_const_type(subpgm.ctx, di);
1988 break;
1989 case DW_TAG_subprogram:
1990 /* FIXME: likely a declaration (to be checked)
1991 * skip it for now
1992 */
1993 break;
1994 case DW_TAG_label:
1996 break;
1997 case DW_TAG_class_type:
1999 case DW_TAG_union_type:
2001 case DW_TAG_typedef:
2002 /* the type referred to will be loaded when we need it, so skip it */
2003 break;
2010 /* FIXME: no support in dbghelp's internals so far */
2011 break;
2012 default:
2013 FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
2014 child->abbrev->tag, dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
2015 }
2016 }
2017
2018 if (subpgm.non_computed_variable || subpgm.frame.kind >= loc_user)
2019 {
2021 &subpgm.frame, NULL);
2022 }
2023 if (subpgm.func) symt_normalize_function(subpgm.ctx->module, subpgm.func);
2024
2025 return di->symt;
2026}
struct symt_hierarchy_point * symt_add_function_point(struct module *module, struct symt_function *func, enum SymTagEnum point, const struct location *loc, const char *name) DECLSPEC_HIDDEN
Definition: symbol.c:452
struct symt_function * symt_new_function(struct module *module, struct symt_compiland *parent, const char *name, ULONG_PTR addr, ULONG_PTR size, struct symt *type) DECLSPEC_HIDDEN
Definition: symbol.c:293
int elf_is_in_thunk_area(ULONG_PTR addr, const struct elf_thunk_area *thunks) DECLSPEC_HIDDEN
Definition: elf_module.c:602
struct symt_function_signature * symt_new_function_signature(struct module *module, struct symt *ret_type, enum CV_call_e call_conv) DECLSPEC_HIDDEN
Definition: type.c:377
@ loc_user
BOOL symt_normalize_function(struct module *module, const struct symt_function *func) DECLSPEC_HIDDEN
Definition: symbol.c:473
@ SymTagCustom
Definition: compat.h:1607
#define DW_INL_not_inlined
Definition: dwarf.h:555
@ DW_TAG_GNU_formal_parameter_pack
Definition: dwarf.h:99
@ DW_TAG_template_value_param
Definition: dwarf.h:67
@ DW_TAG_GNU_template_parameter_pack
Definition: dwarf.h:98
@ DW_TAG_template_type_param
Definition: dwarf.h:66
@ DW_TAG_unspecified_parameters
Definition: dwarf.h:43
@ DW_AT_inline
Definition: dwarf.h:130
@ DW_AT_frame_base
Definition: dwarf.h:154
@ DW_AT_declaration
Definition: dwarf.h:150
static const char * dwarf2_get_cpp_name(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, const char *name)
Definition: dwarf.c:970
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)
Definition: dwarf.c:885
BOOL non_computed_variable
Definition: dwarf.c:1579
#define CV_CALL_FAR_C
Definition: symdump.c:30

Referenced by dwarf2_load_one_entry(), and dwarf2_parse_udt_type().

◆ dwarf2_parse_subprogram_block()

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

Definition at line 1808 of file dwarf.c.

1811{
1812 struct symt_block* block;
1813 ULONG_PTR low_pc, high_pc;
1814 struct vector* children;
1816 unsigned int i;
1817
1818 TRACE("%s, for %s\n", dwarf2_debug_ctx(subpgm->ctx), dwarf2_debug_di(di));
1819
1820 if (!dwarf2_read_range(subpgm->ctx, di, &low_pc, &high_pc))
1821 {
1822 WARN("no range\n");
1823 return;
1824 }
1825
1826 block = symt_open_func_block(subpgm->ctx->module, subpgm->func, parent_block,
1827 subpgm->ctx->load_offset + low_pc - subpgm->func->address,
1828 high_pc - low_pc);
1829
1830 children = dwarf2_get_di_children(subpgm->ctx, di);
1831 if (children) for (i = 0; i < vector_length(children); i++)
1832 {
1833 child = *(dwarf2_debug_info_t**)vector_at(children, i);
1834
1835 switch (child->abbrev->tag)
1836 {
1839 break;
1840 case DW_TAG_variable:
1842 break;
1844 dwarf2_parse_pointer_type(subpgm->ctx, di);
1845 break;
1847 dwarf2_parse_subroutine_type(subpgm->ctx, di);
1848 break;
1849 case DW_TAG_const_type:
1850 dwarf2_parse_const_type(subpgm->ctx, di);
1851 break;
1854 break;
1855 case DW_TAG_subprogram:
1856 /* FIXME: likely a declaration (to be checked)
1857 * skip it for now
1858 */
1859 break;
1861 /* FIXME: likely elements for exception handling (GCC flavor)
1862 * Skip it for now
1863 */
1864 break;
1866 /* C++ stuff to be silenced (for now) */
1867 break;
1869 /* this isn't properly supported by dbghelp interface. skip it for now */
1870 break;
1871 case DW_TAG_label:
1873 break;
1874 case DW_TAG_class_type:
1876 case DW_TAG_union_type:
1878 case DW_TAG_typedef:
1879 /* the type referred to will be loaded when we need it, so skip it */
1880 break;
1881 default:
1882 FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
1883 child->abbrev->tag, dwarf2_debug_ctx(subpgm->ctx), dwarf2_debug_di(di));
1884 }
1885 }
1886
1887 symt_close_func_block(subpgm->ctx->module, subpgm->func, block, 0);
1888}

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

◆ dwarf2_parse_subprogram_label()

static void dwarf2_parse_subprogram_label ( dwarf2_subprogram_t subpgm,
const dwarf2_debug_info_t di 
)
static

Definition at line 1728 of file dwarf.c.

1730{
1731 struct attribute name;
1732 struct attribute low_pc;
1733 struct location loc;
1734
1735 TRACE("%s, for %s\n", dwarf2_debug_ctx(subpgm->ctx), dwarf2_debug_di(di));
1736
1737 if (!dwarf2_find_attribute(subpgm->ctx, di, DW_AT_low_pc, &low_pc)) low_pc.u.uvalue = 0;
1738 if (!dwarf2_find_attribute(subpgm->ctx, di, DW_AT_name, &name))
1739 name.u.string = NULL;
1740
1741 loc.kind = loc_absolute;
1742 loc.offset = subpgm->ctx->load_offset + low_pc.u.uvalue;
1744 &loc, name.u.string);
1745}
@ SymTagLabel
Definition: compat.h:1590

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

◆ dwarf2_parse_subroutine_type()

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

Definition at line 2028 of file dwarf.c.

2030{
2031 struct symt* ret_type;
2032 struct symt_function_signature* sig_type;
2033 struct vector* children;
2035 unsigned int i;
2036
2037 if (di->symt) return di->symt;
2038
2039 TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
2040
2041 if (!(ret_type = dwarf2_lookup_type(ctx, di)))
2042 {
2043 ret_type = ctx->symt_cache[sc_void];
2044 assert(ret_type);
2045 }
2046
2047 /* FIXME: assuming C source code */
2048 sig_type = symt_new_function_signature(ctx->module, ret_type, CV_CALL_FAR_C);
2049
2050 children = dwarf2_get_di_children(ctx, di);
2051 if (children) for (i = 0; i < vector_length(children); i++)
2052 {
2053 child = *(dwarf2_debug_info_t**)vector_at(children, i);
2054
2055 switch (child->abbrev->tag)
2056 {
2060 break;
2062 WARN("Unsupported unspecified parameters\n");
2063 break;
2064 }
2065 }
2066
2067 return di->symt = &sig_type->symt;
2068}
BOOL symt_add_function_signature_parameter(struct module *module, struct symt_function_signature *sig, struct symt *param) DECLSPEC_HIDDEN
Definition: type.c:394

Referenced by dwarf2_load_one_entry(), and dwarf2_parse_subprogram_block().

◆ dwarf2_parse_typedef()

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

Definition at line 1215 of file dwarf.c.

1217{
1218 struct symt* ref_type;
1219 struct attribute name;
1220
1221 if (di->symt) return di->symt;
1222
1223 TRACE("%s, for %lu\n", dwarf2_debug_ctx(ctx), di->abbrev->entry_code);
1224
1225 if (!dwarf2_find_attribute(ctx, di, DW_AT_name, &name)) name.u.string = NULL;
1226 ref_type = dwarf2_lookup_type(ctx, di);
1227
1228 if (name.u.string)
1229 di->symt = &symt_new_typedef(ctx->module, ref_type, name.u.string)->symt;
1230 if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1231 return di->symt;
1232}
struct symt_typedef * symt_new_typedef(struct module *module, struct symt *ref, const char *name) DECLSPEC_HIDDEN
Definition: type.c:428

Referenced by dwarf2_load_one_entry().

◆ dwarf2_parse_u2()

static unsigned short dwarf2_parse_u2 ( dwarf2_traverse_context_t ctx)
static

Definition at line 228 of file dwarf.c.

229{
230 unsigned short uvalue = dwarf2_get_u2(ctx->data);
231 ctx->data += 2;
232 return uvalue;
233}

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

◆ dwarf2_parse_u4()

static ULONG_PTR dwarf2_parse_u4 ( dwarf2_traverse_context_t ctx)
static

◆ dwarf2_parse_u8()

static DWORD64 dwarf2_parse_u8 ( dwarf2_traverse_context_t ctx)
static

Definition at line 252 of file dwarf.c.

253{
254 DWORD64 uvalue = dwarf2_get_u8(ctx->data);
255 ctx->data += 8;
256 return uvalue;
257}

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

◆ dwarf2_parse_udt_member()

static void dwarf2_parse_udt_member ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di,
struct symt_udt parent 
)
static

Definition at line 1386 of file dwarf.c.

1389{
1390 struct symt* elt_type;
1391 struct attribute name;
1392 struct attribute bit_size;
1393 struct attribute bit_offset;
1394 struct location loc;
1395
1396 assert(parent);
1397
1398 TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1399
1400 if (!dwarf2_find_attribute(ctx, di, DW_AT_name, &name)) name.u.string = NULL;
1401 elt_type = dwarf2_lookup_type(ctx, di);
1403 {
1404 if (loc.kind != loc_absolute)
1405 {
1406 FIXME("Found register, while not expecting it\n");
1407 loc.offset = 0;
1408 }
1409 else
1410 TRACE("found member_location at %s -> %lu\n",
1411 dwarf2_debug_ctx(ctx), loc.offset);
1412 }
1413 else
1414 loc.offset = 0;
1415 if (!dwarf2_find_attribute(ctx, di, DW_AT_bit_size, &bit_size))
1416 bit_size.u.uvalue = 0;
1417 if (dwarf2_find_attribute(ctx, di, DW_AT_bit_offset, &bit_offset))
1418 {
1419 /* FIXME: we should only do this when implementation is LSB (which is
1420 * the case on i386 processors)
1421 */
1422 struct attribute nbytes;
1423 if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &nbytes))
1424 {
1425 DWORD64 size;
1426 nbytes.u.uvalue = symt_get_info(ctx->module, elt_type, TI_GET_LENGTH, &size) ?
1427 (ULONG_PTR)size : 0;
1428 }
1429 bit_offset.u.uvalue = nbytes.u.uvalue * 8 - bit_offset.u.uvalue - bit_size.u.uvalue;
1430 }
1431 else bit_offset.u.uvalue = 0;
1432 symt_add_udt_element(ctx->module, parent, name.u.string, elt_type,
1433 (loc.offset << 3) + bit_offset.u.uvalue,
1434 bit_size.u.uvalue);
1435
1436 if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1437}
BOOL symt_get_info(struct module *module, const struct symt *type, IMAGEHLP_SYMBOL_TYPE_INFO req, void *pInfo) DECLSPEC_HIDDEN
Definition: type.c:536
BOOL symt_add_udt_element(struct module *module, struct symt_udt *udt_type, const char *name, struct symt *elt_type, unsigned offset, unsigned size) DECLSPEC_HIDDEN
Definition: type.c:264
@ TI_GET_LENGTH
Definition: compat.h:1417
@ DW_AT_bit_size
Definition: dwarf.h:113
@ DW_AT_bit_offset
Definition: dwarf.h:112
@ DW_AT_data_member_location
Definition: dwarf.h:146

Referenced by dwarf2_parse_udt_type().

◆ dwarf2_parse_udt_type()

static struct symt * dwarf2_parse_udt_type ( dwarf2_parse_context_t ctx,
dwarf2_debug_info_t di,
enum UdtKind  udt 
)
static

Definition at line 1442 of file dwarf.c.

1445{
1446 struct attribute name;
1447 struct attribute size;
1448 struct vector* children;
1450 unsigned int i;
1451
1452 if (di->symt) return di->symt;
1453
1454 TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1455
1456 /* quirk... FIXME provide real support for anonymous UDTs */
1458 name.u.string = "zz_anon_zz";
1459 if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &size)) size.u.uvalue = 0;
1460
1461 di->symt = &symt_new_udt(ctx->module, dwarf2_get_cpp_name(ctx, di, name.u.string),
1462 size.u.uvalue, udt)->symt;
1463
1464 children = dwarf2_get_di_children(ctx, di);
1465 if (children) for (i = 0; i < vector_length(children); i++)
1466 {
1467 child = *(dwarf2_debug_info_t**)vector_at(children, i);
1468
1469 switch (child->abbrev->tag)
1470 {
1471 case DW_TAG_array_type:
1473 break;
1474 case DW_TAG_member:
1475 /* FIXME: should I follow the sibling stuff ?? */
1477 break;
1480 break;
1481 case DW_TAG_subprogram:
1483 break;
1484 case DW_TAG_const_type:
1486 break;
1488 case DW_TAG_class_type:
1489 case DW_TAG_union_type:
1490 case DW_TAG_typedef:
1491 /* FIXME: we need to handle nested udt definitions */
1492 case DW_TAG_inheritance:
1495 case DW_TAG_variable:
1500 /* FIXME: some C++ related stuff */
1501 break;
1502 default:
1503 FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
1504 child->abbrev->tag, dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1505 break;
1506 }
1507 }
1508
1509 return di->symt;
1510}
struct symt_udt * symt_new_udt(struct module *module, const char *typename, unsigned size, enum UdtKind kind) DECLSPEC_HIDDEN
Definition: type.c:219
@ DW_TAG_inheritance
Definition: dwarf.h:47
@ DW_TAG_member
Definition: dwarf.h:34
static void dwarf2_parse_udt_member(dwarf2_parse_context_t *ctx, dwarf2_debug_info_t *di, struct symt_udt *parent)
Definition: dwarf.c:1386

Referenced by dwarf2_load_one_entry().

◆ dwarf2_parse_unspecified_type()

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

Definition at line 1343 of file dwarf.c.

1345{
1346 struct attribute name;
1347 struct attribute size;
1348 struct symt_basic *basic;
1349
1350 TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1351
1352 if (di->symt) return di->symt;
1353
1355 name.u.string = "void";
1356 size.u.uvalue = sizeof(void *);
1357
1358 basic = symt_new_basic(ctx->module, btVoid, name.u.string, size.u.uvalue);
1359 di->symt = &basic->symt;
1360
1361 if (!ctx->symt_cache[sc_void])
1362 ctx->symt_cache[sc_void] = di->symt;
1363
1364 if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1365 return di->symt;
1366}

Referenced by dwarf2_load_one_entry().

◆ dwarf2_parse_variable()

static void dwarf2_parse_variable ( dwarf2_subprogram_t subpgm,
struct symt_block block,
dwarf2_debug_info_t di 
)
static

Definition at line 1588 of file dwarf.c.

1591{
1592 struct symt* param_type;
1593 struct attribute name, value;
1594 struct location loc;
1595 BOOL is_pmt;
1596
1597 TRACE("%s, for %s\n", dwarf2_debug_ctx(subpgm->ctx), dwarf2_debug_di(di));
1598
1599 is_pmt = !block && di->abbrev->tag == DW_TAG_formal_parameter;
1600 param_type = dwarf2_lookup_type(subpgm->ctx, di);
1601
1602 if (!dwarf2_find_attribute(subpgm->ctx, di, DW_AT_name, &name)) {
1603 /* cannot do much without the name, the functions below won't like it. */
1604 return;
1605 }
1607 &loc, &subpgm->frame))
1608 {
1609 struct attribute ext;
1610
1611 TRACE("found parameter %s (kind=%d, offset=%ld, reg=%d) at %s\n",
1612 debugstr_a(name.u.string), loc.kind, loc.offset, loc.reg,
1613 dwarf2_debug_ctx(subpgm->ctx));
1614
1615 switch (loc.kind)
1616 {
1617 case loc_error:
1618 break;
1619 case loc_absolute:
1620 /* it's a global variable */
1621 /* FIXME: we don't handle its scope yet */
1622 if (!dwarf2_find_attribute(subpgm->ctx, di, DW_AT_external, &ext))
1623 ext.u.uvalue = 0;
1624 loc.offset += subpgm->ctx->load_offset;
1625 symt_new_global_variable(subpgm->ctx->module, subpgm->ctx->compiland,
1626 dwarf2_get_cpp_name(subpgm->ctx, di, name.u.string), !ext.u.uvalue,
1627 loc, 0, param_type);
1628 break;
1629 default:
1630 subpgm->non_computed_variable = TRUE;
1631 /* fall through */
1632 case loc_register:
1633 case loc_regrel:
1634 /* either a pmt/variable relative to frame pointer or
1635 * pmt/variable in a register
1636 */
1637 assert(subpgm->func);
1638 symt_add_func_local(subpgm->ctx->module, subpgm->func,
1639 is_pmt ? DataIsParam : DataIsLocal,
1640 &loc, block, param_type, name.u.string);
1641 break;
1642 }
1643 }
1644 else if (dwarf2_find_attribute(subpgm->ctx, di, DW_AT_const_value, &value))
1645 {
1646 VARIANT v;
1647 if (subpgm->func) WARN("Unsupported constant %s in function\n", debugstr_a(name.u.string));
1648 if (is_pmt) FIXME("Unsupported constant (parameter) %s in function\n", debugstr_a(name.u.string));
1649 switch (value.form)
1650 {
1651 case DW_FORM_data1:
1652 case DW_FORM_data2:
1653 case DW_FORM_data4:
1654 case DW_FORM_udata:
1655 case DW_FORM_addr:
1656 v.n1.n2.vt = VT_UI4;
1657 v.n1.n2.n3.lVal = value.u.uvalue;
1658 break;
1659
1660 case DW_FORM_data8:
1661 v.n1.n2.vt = VT_UI8;
1662 v.n1.n2.n3.llVal = value.u.lluvalue;
1663 break;
1664
1665 case DW_FORM_sdata:
1666 v.n1.n2.vt = VT_I4;
1667 v.n1.n2.n3.lVal = value.u.svalue;
1668 break;
1669
1670 case DW_FORM_strp:
1671 case DW_FORM_string:
1672 /* FIXME: native doesn't report const strings from here !!
1673 * however, the value of the string is in the code somewhere
1674 */
1675 v.n1.n2.vt = VT_I1 | VT_BYREF;
1676 v.n1.n2.n3.byref = pool_strdup(&subpgm->ctx->module->pool, value.u.string);
1677 break;
1678
1679 case DW_FORM_block:
1680 case DW_FORM_block1:
1681 case DW_FORM_block2:
1682 case DW_FORM_block4:
1683 v.n1.n2.vt = VT_I4;
1684 switch (value.u.block.size)
1685 {
1686 case 1: v.n1.n2.n3.lVal = *(BYTE*)value.u.block.ptr; break;
1687 case 2: v.n1.n2.n3.lVal = *(USHORT*)value.u.block.ptr; break;
1688 case 4: v.n1.n2.n3.lVal = *(DWORD*)value.u.block.ptr; break;
1689 default:
1690 v.n1.n2.vt = VT_I1 | VT_BYREF;
1691 v.n1.n2.n3.byref = pool_alloc(&subpgm->ctx->module->pool, value.u.block.size);
1692 memcpy(v.n1.n2.n3.byref, value.u.block.ptr, value.u.block.size);
1693 }
1694 break;
1695
1696 default:
1697 FIXME("Unsupported form for const value %s (%lx)\n",
1698 debugstr_a(name.u.string), value.form);
1699 v.n1.n2.vt = VT_EMPTY;
1700 }
1701 di->symt = &symt_new_constant(subpgm->ctx->module, subpgm->ctx->compiland,
1702 name.u.string, param_type, &v)->symt;
1703 }
1704 else
1705 {
1706 /* variable has been optimized away... report anyway */
1707 loc.kind = loc_error;
1708 loc.reg = loc_err_no_location;
1709 if (subpgm->func)
1710 {
1711 symt_add_func_local(subpgm->ctx->module, subpgm->func,
1712 is_pmt ? DataIsParam : DataIsLocal,
1713 &loc, block, param_type, name.u.string);
1714 }
1715 else
1716 {
1717 WARN("dropping global variable %s which has been optimized away\n", debugstr_a(name.u.string));
1718 }
1719 }
1720 if (is_pmt && subpgm->func && subpgm->func->type)
1722 (struct symt_function_signature*)subpgm->func->type,
1723 param_type);
1724
1725 if (dwarf2_get_di_children(subpgm->ctx, di)) FIXME("Unsupported children\n");
1726}
struct symt_data * symt_new_constant(struct module *module, struct symt_compiland *parent, const char *name, struct symt *type, const VARIANT *v) DECLSPEC_HIDDEN
Definition: symbol.c:525
struct symt_data * symt_add_func_local(struct module *module, struct symt_function *func, enum DataKind dt, const struct location *loc, struct symt_block *block, struct symt *type, const char *name) DECLSPEC_HIDDEN
Definition: symbol.c:378
struct symt_data * symt_new_global_variable(struct module *module, struct symt_compiland *parent, const char *name, unsigned is_static, struct location loc, ULONG_PTR size, struct symt *type) DECLSPEC_HIDDEN
Definition: symbol.c:256
char * pool_strdup(struct pool *a, const char *str) DECLSPEC_HIDDEN
Definition: storage.c:126
@ loc_err_no_location
@ DataIsLocal
Definition: compat.h:1649
@ DataIsParam
Definition: compat.h:1651
@ VT_UI8
Definition: compat.h:2315
@ VT_BYREF
Definition: compat.h:2342
@ VT_I1
Definition: compat.h:2310
@ VT_I4
Definition: compat.h:2298
@ VT_UI4
Definition: compat.h:2313
@ VT_EMPTY
Definition: compat.h:2295
@ DW_AT_location
Definition: dwarf.h:107
@ DW_AT_external
Definition: dwarf.h:153
static const WCHAR *const ext[]
Definition: module.c:53
const GLdouble * v
Definition: gl.h:2040
unsigned short USHORT
Definition: pedump.c:61
struct symt_compiland * compiland
Definition: dwarf.c:186

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

◆ dwarf2_parse_volatile_type()

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

Definition at line 1323 of file dwarf.c.

1325{
1326 struct symt* ref_type;
1327
1328 if (di->symt) return di->symt;
1329
1330 TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
1331
1332 if (!(ref_type = dwarf2_lookup_type(ctx, di)))
1333 {
1334 ref_type = ctx->symt_cache[sc_void];
1335 assert(ref_type);
1336 }
1337 if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n");
1338 di->symt = ref_type;
1339
1340 return ref_type;
1341}

Referenced by dwarf2_load_one_entry().

◆ dwarf2_read_one_debug_info()

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

Definition at line 1077 of file dwarf.c.

1081{
1082 const dwarf2_abbrev_entry_t*abbrev;
1083 ULONG_PTR entry_code;
1087 dwarf2_debug_info_t** where;
1089 unsigned i;
1090 struct attribute sibling;
1091
1092 offset = traverse->data - ctx->sections[ctx->section].address;
1093 entry_code = dwarf2_leb128_as_unsigned(traverse);
1094 TRACE("found entry_code %lu at 0x%lx\n", entry_code, offset);
1095 if (!entry_code)
1096 {
1097 *pdi = NULL;
1098 return TRUE;
1099 }
1100 abbrev = dwarf2_abbrev_table_find_entry(&ctx->abbrev_table, entry_code);
1101 if (!abbrev)
1102 {
1103 WARN("Cannot find abbrev entry for %lu at 0x%lx\n", entry_code, offset);
1104 return FALSE;
1105 }
1106 di = sparse_array_add(&ctx->debug_info_table, offset, &ctx->pool);
1107 if (!di) return FALSE;
1108 di->abbrev = abbrev;
1109 di->symt = NULL;
1110 di->parent = parent_di;
1111
1112 if (abbrev->num_attr)
1113 {
1114 di->data = pool_alloc(&ctx->pool, abbrev->num_attr * sizeof(const char*));
1115 for (i = 0, attr = abbrev->attrs; attr; i++, attr = attr->next)
1116 {
1117 di->data[i] = traverse->data;
1118 dwarf2_swallow_attribute(traverse, attr);
1119 }
1120 }
1121 else di->data = NULL;
1122 if (abbrev->have_child)
1123 {
1124 vector_init(&di->children, sizeof(dwarf2_debug_info_t*), 16);
1125 while (traverse->data < traverse->end_data)
1126 {
1127 if (!dwarf2_read_one_debug_info(ctx, traverse, di, &child)) return FALSE;
1128 if (!child) break;
1129 where = vector_add(&di->children, &ctx->pool);
1130 if (!where) return FALSE;
1131 *where = child;
1132 }
1133 }
1134 if (dwarf2_find_attribute(ctx, di, DW_AT_sibling, &sibling) &&
1135 traverse->data != ctx->sections[ctx->section].address + sibling.u.uvalue)
1136 {
1137 WARN("setting cursor for %s to next sibling <0x%lx>\n",
1138 dwarf2_debug_traverse_ctx(traverse), sibling.u.uvalue);
1139 traverse->data = ctx->sections[ctx->section].address + sibling.u.uvalue;
1140 }
1141 *pdi = di;
1142 return TRUE;
1143}
static void dwarf2_swallow_attribute(dwarf2_traverse_context_t *ctx, const dwarf2_abbrev_entry_attr_t *abbrev_attr)
Definition: dwarf.c:449
static dwarf2_abbrev_entry_t * dwarf2_abbrev_table_find_entry(const struct sparse_array *abbrev_table, ULONG_PTR entry_code)
Definition: dwarf.c:380
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3554

Referenced by dwarf2_parse_compilation_unit(), and dwarf2_read_one_debug_info().

◆ dwarf2_read_range()

static BOOL dwarf2_read_range ( dwarf2_parse_context_t ctx,
const dwarf2_debug_info_t di,
ULONG_PTR plow,
ULONG_PTR phigh 
)
static

Definition at line 1027 of file dwarf.c.

1029{
1030 struct attribute range;
1031
1033 {
1035 ULONG_PTR low, high;
1036
1037 traverse.data = ctx->sections[section_ranges].address + range.u.uvalue;
1038 traverse.end_data = ctx->sections[section_ranges].address +
1039 ctx->sections[section_ranges].size;
1040 traverse.word_size = ctx->module->format_info[DFI_DWARF]->u.dwarf2_info->word_size;
1041
1042 *plow = ULONG_MAX;
1043 *phigh = 0;
1044 while (traverse.data + 2 * traverse.word_size < traverse.end_data)
1045 {
1046 low = dwarf2_parse_addr(&traverse);
1047 high = dwarf2_parse_addr(&traverse);
1048 if (low == 0 && high == 0) break;
1049 if (low == ULONG_MAX) FIXME("unsupported yet (base address selection)\n");
1050 if (low < *plow) *plow = low;
1051 if (high > *phigh) *phigh = high;
1052 }
1053 if (*plow == ULONG_MAX || *phigh == 0) {FIXME("no entry found\n"); return FALSE;}
1054 if (*plow == *phigh) {FIXME("entry found, but low=high\n"); return FALSE;}
1055
1056 return TRUE;
1057 }
1058 else
1059 {
1060 struct attribute low_pc;
1061 struct attribute high_pc;
1062
1063 if (!dwarf2_find_attribute(ctx, di, DW_AT_low_pc, &low_pc) ||
1064 !dwarf2_find_attribute(ctx, di, DW_AT_high_pc, &high_pc))
1065 return FALSE;
1066 *plow = low_pc.u.uvalue;
1067 *phigh = high_pc.u.uvalue;
1068 return TRUE;
1069 }
1070}
@ DW_AT_high_pc
Definition: dwarf.h:117
@ DW_AT_ranges
Definition: dwarf.h:177
#define ULONG_MAX
Definition: limits.h:44

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

◆ dwarf2_set_line_number()

static void dwarf2_set_line_number ( struct module module,
ULONG_PTR  address,
const struct vector v,
unsigned  file,
unsigned  line 
)
static

Definition at line 2164 of file dwarf.c.

2166{
2167 struct symt_function* func;
2168 struct symt_ht* symt;
2169 unsigned* psrc;
2170
2171 if (!file || !(psrc = vector_at(v, file - 1))) return;
2172
2173 TRACE("%s %lx %s %u\n",
2175 if (!(symt = symt_find_nearest(module, address)) ||
2176 symt->symt.tag != SymTagFunction) return;
2177 func = (struct symt_function*)symt;
2178 symt_add_func_line(module, func, *psrc, line, address - func->address);
2179}
const char * source_get(const struct module *module, unsigned idx) DECLSPEC_HIDDEN
Definition: source.c:130
void symt_add_func_line(struct module *module, struct symt_function *func, unsigned source_idx, int line_num, ULONG_PTR offset) DECLSPEC_HIDDEN
Definition: symbol.c:326
struct symt_ht * symt_find_nearest(struct module *module, DWORD_PTR addr) DECLSPEC_HIDDEN
Definition: symbol.c:903
@ SymTagFunction
Definition: compat.h:1586
struct symt symt
enum SymTagEnum tag

Referenced by dwarf2_parse_line_numbers().

◆ dwarf2_swallow_attribute()

static void dwarf2_swallow_attribute ( dwarf2_traverse_context_t ctx,
const dwarf2_abbrev_entry_attr_t abbrev_attr 
)
static

Definition at line 449 of file dwarf.c.

451{
452 unsigned step;
453
454 TRACE("(attr:0x%lx,form:0x%lx)\n", abbrev_attr->attribute, abbrev_attr->form);
455
456 switch (abbrev_attr->form)
457 {
458 case DW_FORM_flag_present: step = 0; break;
459 case DW_FORM_ref_addr:
460 case DW_FORM_addr: step = ctx->word_size; break;
461 case DW_FORM_flag:
462 case DW_FORM_data1:
463 case DW_FORM_ref1: step = 1; break;
464 case DW_FORM_data2:
465 case DW_FORM_ref2: step = 2; break;
466 case DW_FORM_data4:
467 case DW_FORM_ref4:
468 case DW_FORM_strp: step = 4; break;
469 case DW_FORM_data8:
470 case DW_FORM_ref8: step = 8; break;
471 case DW_FORM_sdata:
473 case DW_FORM_udata: step = dwarf2_leb128_length(ctx); break;
474 case DW_FORM_string: step = strlen((const char*)ctx->data) + 1; break;
475 case DW_FORM_block: step = dwarf2_leb128_as_unsigned(ctx); break;
476 case DW_FORM_block1: step = dwarf2_parse_byte(ctx); break;
477 case DW_FORM_block2: step = dwarf2_parse_u2(ctx); break;
478 case DW_FORM_block4: step = dwarf2_parse_u4(ctx); break;
479 default:
480 FIXME("Unhandled attribute form %lx\n", abbrev_attr->form);
481 return;
482 }
483 ctx->data += step;
484}
static unsigned dwarf2_leb128_length(const dwarf2_traverse_context_t *ctx)
Definition: dwarf.c:322

Referenced by dwarf2_read_one_debug_info().

◆ dwarf2_virtual_unwind()

BOOL dwarf2_virtual_unwind ( struct cpu_stack_walk csw,
ULONG_PTR  ip,
union ctx context,
DWORD64 cfa 
)

Definition at line 3258 of file dwarf.c.

3260{
3261 struct module_pair pair;
3262 struct frame_info info;
3263 dwarf2_traverse_context_t cie_ctx, fde_ctx;
3264 struct module_format* modfmt;
3265 const unsigned char* end;
3266 DWORD_PTR delta;
3267
3268 if (!(pair.pcs = process_find_by_handle(csw->hProcess)) ||
3269 !(pair.requested = module_find_by_addr(pair.pcs, ip, DMT_UNKNOWN)) ||
3271 return FALSE;
3272 modfmt = pair.effective->format_info[DFI_DWARF];
3273 if (!modfmt) return FALSE;
3274 memset(&info, 0, sizeof(info));
3275 fde_ctx.data = modfmt->u.dwarf2_info->eh_frame.address;
3276 fde_ctx.end_data = fde_ctx.data + modfmt->u.dwarf2_info->eh_frame.size;
3277 fde_ctx.word_size = modfmt->u.dwarf2_info->word_size;
3278 /* let offsets relative to the eh_frame sections be correctly computed, as we'll map
3279 * in this process the IMAGE section at a different address as the one expected by
3280 * the image
3281 */
3282 delta = pair.effective->module.BaseOfImage + modfmt->u.dwarf2_info->eh_frame.rva -
3283 (DWORD_PTR)modfmt->u.dwarf2_info->eh_frame.address;
3284 if (!dwarf2_get_cie(ip, pair.effective, delta, &fde_ctx, &cie_ctx, &info, TRUE))
3285 {
3286 fde_ctx.data = modfmt->u.dwarf2_info->debug_frame.address;
3287 fde_ctx.end_data = fde_ctx.data + modfmt->u.dwarf2_info->debug_frame.size;
3288 fde_ctx.word_size = modfmt->u.dwarf2_info->word_size;
3289 delta = pair.effective->reloc_delta;
3290 if (!dwarf2_get_cie(ip, pair.effective, delta, &fde_ctx, &cie_ctx, &info, FALSE))
3291 {
3292 TRACE("Couldn't find information for %lx\n", ip);
3293 return FALSE;
3294 }
3295 }
3296
3297 TRACE("function %lx/%lx code_align %lu data_align %ld retaddr %s\n",
3298 ip, info.ip, info.code_align, info.data_align,
3299 csw->cpu->fetch_regname(csw->cpu->map_dwarf_register(info.retaddr_reg, pair.effective, TRUE)));
3300
3301 /* if at very beginning of function, return and use default unwinder */
3302 if (ip == info.ip) return FALSE;
3303 execute_cfa_instructions(pair.effective, &cie_ctx, ip, &info);
3304
3305 if (info.aug_z_format) /* get length of augmentation data */
3306 {
3308 end = fde_ctx.data + len;
3309 }
3310 else end = NULL;
3311 dwarf2_parse_augmentation_ptr(&fde_ctx, info.lsda_encoding); /* handler_data */
3312 if (end) fde_ctx.data = end;
3313
3314 execute_cfa_instructions(pair.effective, &fde_ctx, ip, &info);
3315
3316 /* if there is no information about retaddr, use default unwinder */
3317 if (info.state.rules[info.retaddr_reg] == RULE_UNSET) return FALSE;
3318
3319 apply_frame_state(pair.effective, csw, context, &info.state, cfa);
3320
3321 return TRUE;
3322}
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type) DECLSPEC_HIDDEN
Definition: module.c:420
BOOL module_get_debug(struct module_pair *) DECLSPEC_HIDDEN
Definition: module.c:374
@ DMT_UNKNOWN
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:99
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)
Definition: dwarf.c:2715
static void apply_frame_state(const struct module *module, struct cpu_stack_walk *csw, union ctx *context, struct frame_state *state, DWORD64 *cfa)
Definition: dwarf.c:3201
static void execute_cfa_instructions(struct module *module, dwarf2_traverse_context_t *ctx, ULONG_PTR last_ip, struct frame_info *info)
Definition: dwarf.c:2792
Definition: _pair.h:47
#define DWORD_PTR
Definition: treelist.c:76

Referenced by fetch_next_frame32().

◆ eval_expression()

static ULONG_PTR eval_expression ( const struct module module,
struct cpu_stack_walk csw,
const unsigned char zp,
union ctx context 
)
static

Definition at line 3087 of file dwarf.c.

3089{
3091 ULONG_PTR reg, sz, tmp;
3092 DWORD64 stack[64];
3093 int sp = -1;
3094 ULONG_PTR len;
3095
3096 ctx.data = zp;
3097 ctx.end_data = zp + 4;
3099 ctx.end_data = ctx.data + len;
3100 ctx.word_size = module->format_info[DFI_DWARF]->u.dwarf2_info->word_size;
3101
3102 while (ctx.data < ctx.end_data)
3103 {
3104 unsigned char opcode = dwarf2_parse_byte(&ctx);
3105
3106 if (opcode >= DW_OP_lit0 && opcode <= DW_OP_lit31)
3107 stack[++sp] = opcode - DW_OP_lit0;
3108 else if (opcode >= DW_OP_reg0 && opcode <= DW_OP_reg31)
3109 stack[++sp] = get_context_reg(module, csw, context, opcode - DW_OP_reg0);
3110 else if (opcode >= DW_OP_breg0 && opcode <= DW_OP_breg31)
3111 stack[++sp] = get_context_reg(module, csw, context, opcode - DW_OP_breg0)
3113 else switch (opcode)
3114 {
3115 case DW_OP_nop: break;
3116 case DW_OP_addr: stack[++sp] = dwarf2_parse_addr(&ctx); break;
3117 case DW_OP_const1u: stack[++sp] = dwarf2_parse_byte(&ctx); break;
3118 case DW_OP_const1s: stack[++sp] = (signed char)dwarf2_parse_byte(&ctx); break;
3119 case DW_OP_const2u: stack[++sp] = dwarf2_parse_u2(&ctx); break;
3120 case DW_OP_const2s: stack[++sp] = (short)dwarf2_parse_u2(&ctx); break;
3121 case DW_OP_const4u: stack[++sp] = dwarf2_parse_u4(&ctx); break;
3122 case DW_OP_const4s: stack[++sp] = (signed int)dwarf2_parse_u4(&ctx); break;
3123 case DW_OP_const8u: stack[++sp] = dwarf2_parse_u8(&ctx); break;
3124 case DW_OP_const8s: stack[++sp] = (LONG_PTR)dwarf2_parse_u8(&ctx); break;
3126 case DW_OP_consts: stack[++sp] = dwarf2_leb128_as_signed(&ctx); break;
3127 case DW_OP_deref:
3128 tmp = 0;
3129 if (!sw_read_mem(csw, stack[sp], &tmp, ctx.word_size))
3130 {
3131 ERR("Couldn't read memory at %s\n", wine_dbgstr_longlong(stack[sp]));
3132 tmp = 0;
3133 }
3134 stack[sp] = tmp;
3135 break;
3136 case DW_OP_dup: stack[sp + 1] = stack[sp]; sp++; break;
3137 case DW_OP_drop: sp--; break;
3138 case DW_OP_over: stack[sp + 1] = stack[sp - 1]; sp++; break;
3139 case DW_OP_pick: stack[sp + 1] = stack[sp - dwarf2_parse_byte(&ctx)]; sp++; break;
3140 case DW_OP_swap: tmp = stack[sp]; stack[sp] = stack[sp-1]; stack[sp-1] = tmp; break;
3141 case DW_OP_rot: tmp = stack[sp]; stack[sp] = stack[sp-1]; stack[sp-1] = stack[sp-2]; stack[sp-2] = tmp; break;
3142 case DW_OP_abs: stack[sp] = sizeof(stack[sp]) == 8 ? llabs((INT64)stack[sp]) : abs((INT32)stack[sp]); break;
3143 case DW_OP_neg: stack[sp] = -stack[sp]; break;
3144 case DW_OP_not: stack[sp] = ~stack[sp]; break;
3145 case DW_OP_and: stack[sp-1] &= stack[sp]; sp--; break;
3146 case DW_OP_or: stack[sp-1] |= stack[sp]; sp--; break;
3147 case DW_OP_minus: stack[sp-1] -= stack[sp]; sp--; break;
3148 case DW_OP_mul: stack[sp-1] *= stack[sp]; sp--; break;
3149 case DW_OP_plus: stack[sp-1] += stack[sp]; sp--; break;
3150 case DW_OP_xor: stack[sp-1] ^= stack[sp]; sp--; break;
3151 case DW_OP_shl: stack[sp-1] <<= stack[sp]; sp--; break;
3152 case DW_OP_shr: stack[sp-1] >>= stack[sp]; sp--; break;
3154 case DW_OP_shra: stack[sp-1] = (LONG_PTR)stack[sp-1] / (1 << stack[sp]); sp--; break;
3155 case DW_OP_div: stack[sp-1] = (LONG_PTR)stack[sp-1] / (LONG_PTR)stack[sp]; sp--; break;
3156 case DW_OP_mod: stack[sp-1] = (LONG_PTR)stack[sp-1] % (LONG_PTR)stack[sp]; sp--; break;
3157 case DW_OP_ge: stack[sp-1] = ((LONG_PTR)stack[sp-1] >= (LONG_PTR)stack[sp]); sp--; break;
3158 case DW_OP_gt: stack[sp-1] = ((LONG_PTR)stack[sp-1] > (LONG_PTR)stack[sp]); sp--; break;
3159 case DW_OP_le: stack[sp-1] = ((LONG_PTR)stack[sp-1] <= (LONG_PTR)stack[sp]); sp--; break;
3160 case DW_OP_lt: stack[sp-1] = ((LONG_PTR)stack[sp-1] < (LONG_PTR)stack[sp]); sp--; break;
3161 case DW_OP_eq: stack[sp-1] = (stack[sp-1] == stack[sp]); sp--; break;
3162 case DW_OP_ne: stack[sp-1] = (stack[sp-1] != stack[sp]); sp--; break;
3163 case DW_OP_skip: tmp = (short)dwarf2_parse_u2(&ctx); ctx.data += tmp; break;
3164 case DW_OP_bra: tmp = (short)dwarf2_parse_u2(&ctx); if (!stack[sp--]) ctx.data += tmp; break;
3166 tmp = dwarf2_parse_byte(&ctx);
3168 break;
3169 case DW_OP_regx:
3171 break;
3172 case DW_OP_bregx:
3175 stack[++sp] = get_context_reg(module, csw, context, reg) + tmp;
3176 break;
3177 case DW_OP_deref_size:
3178 sz = dwarf2_parse_byte(&ctx);
3179 if (!sw_read_mem(csw, stack[sp], &tmp, sz))
3180 {
3181 ERR("Couldn't read memory at %s\n", wine_dbgstr_longlong(stack[sp]));
3182 tmp = 0;
3183 }
3184 /* do integral promotion */
3185 switch (sz)
3186 {
3187 case 1: stack[sp] = *(unsigned char*)&tmp; break;
3188 case 2: stack[sp] = *(unsigned short*)&tmp; break;
3189 case 4: stack[sp] = *(unsigned int*)&tmp; break;
3190 case 8: stack[sp] = *(ULONG_PTR*)&tmp; break; /* FIXME: won't work on 32bit platform */
3191 default: FIXME("Unknown size for deref 0x%lx\n", sz);
3192 }
3193 break;
3194 default:
3195 FIXME("unhandled opcode %02x\n", opcode);
3196 }
3197 }
3198 return stack[sp];
3199}
@ DW_OP_GNU_encoded_addr
Definition: dwarf.h:462
static int reg
Definition: i386-dis.c:1290
static const WCHAR sp[]
Definition: suminfo.c:287
#define LONG_PTR
Definition: treelist.c:79

Referenced by apply_frame_state().

◆ execute_cfa_instructions()

static void execute_cfa_instructions ( struct module module,
dwarf2_traverse_context_t ctx,
ULONG_PTR  last_ip,
struct frame_info info 
)
static

Definition at line 2792 of file dwarf.c.

2794{
2795 while (ctx->data < ctx->end_data && info->ip <= last_ip + info->signal_frame)
2796 {
2798
2799 if (op & 0xc0)
2800 {
2801 switch (op & 0xc0)
2802 {
2803 case DW_CFA_advance_loc:
2804 {
2805 ULONG_PTR offset = (op & 0x3f) * info->code_align;
2806 TRACE("%lx: DW_CFA_advance_loc %lu\n", info->ip, offset);
2807 info->ip += offset;
2808 break;
2809 }
2810 case DW_CFA_offset:
2811 {
2812 ULONG_PTR reg = op & 0x3f;
2814 if (!valid_reg(reg)) break;
2815 TRACE("%lx: DW_CFA_offset %s, %ld\n",
2816 info->ip,
2817 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)),
2818 offset);
2819 info->state.regs[reg] = offset;
2820 info->state.rules[reg] = RULE_CFA_OFFSET;
2821 break;
2822 }
2823 case DW_CFA_restore:
2824 {
2825 ULONG_PTR reg = op & 0x3f;
2826 if (!valid_reg(reg)) break;
2827 TRACE("%lx: DW_CFA_restore %s\n",
2828 info->ip,
2829 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)));
2830 info->state.rules[reg] = RULE_UNSET;
2831 break;
2832 }
2833 }
2834 }
2835 else switch (op)
2836 {
2837 case DW_CFA_nop:
2838 break;
2839 case DW_CFA_set_loc:
2840 {
2841 ULONG_PTR loc = dwarf2_parse_augmentation_ptr(ctx, info->fde_encoding);
2842 TRACE("%lx: DW_CFA_set_loc %lx\n", info->ip, loc);
2843 info->ip = loc;
2844 break;
2845 }
2847 {
2848 ULONG_PTR offset = dwarf2_parse_byte(ctx) * info->code_align;
2849 TRACE("%lx: DW_CFA_advance_loc1 %lu\n", info->ip, offset);
2850 info->ip += offset;
2851 break;
2852 }
2854 {
2855 ULONG_PTR offset = dwarf2_parse_u2(ctx) * info->code_align;
2856 TRACE("%lx: DW_CFA_advance_loc2 %lu\n", info->ip, offset);
2857 info->ip += offset;
2858 break;
2859 }
2861 {
2862 ULONG_PTR offset = dwarf2_parse_u4(ctx) * info->code_align;
2863 TRACE("%lx: DW_CFA_advance_loc4 %lu\n", info->ip, offset);
2864 info->ip += offset;
2865 break;
2866 }
2869 {
2872 : dwarf2_leb128_as_signed(ctx) * info->data_align;
2873 if (!valid_reg(reg)) break;
2874 TRACE("%lx: DW_CFA_offset_extended %s, %ld\n",
2875 info->ip,
2876 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)),
2877 offset);
2878 info->state.regs[reg] = offset;
2879 info->state.rules[reg] = RULE_CFA_OFFSET;
2880 break;
2881 }
2883 {
2885 if (!valid_reg(reg)) break;
2886 TRACE("%lx: DW_CFA_restore_extended %s\n",
2887 info->ip,
2888 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)));
2889 info->state.rules[reg] = RULE_UNSET;
2890 break;
2891 }
2892 case DW_CFA_undefined:
2893 {
2895 if (!valid_reg(reg)) break;
2896 TRACE("%lx: DW_CFA_undefined %s\n",
2897 info->ip,
2898 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)));
2899 info->state.rules[reg] = RULE_UNDEFINED;
2900 break;
2901 }
2902 case DW_CFA_same_value:
2903 {
2905 if (!valid_reg(reg)) break;
2906 TRACE("%lx: DW_CFA_same_value %s\n",
2907 info->ip,
2908 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)));
2909 info->state.regs[reg] = reg;
2910 info->state.rules[reg] = RULE_SAME;
2911 break;
2912 }
2913 case DW_CFA_register:
2914 {
2917 if (!valid_reg(reg) || !valid_reg(reg2)) break;
2918 TRACE("%lx: DW_CFA_register %s == %s\n",
2919 info->ip,
2920 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)),
2921 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg2, module, TRUE)));
2922 info->state.regs[reg] = reg2;
2923 info->state.rules[reg] = RULE_OTHER_REG;
2924 break;
2925 }
2927 TRACE("%lx: DW_CFA_remember_state\n", info->ip);
2928 if (info->state_sp >= MAX_SAVED_STATES)
2929 FIXME("%lx: DW_CFA_remember_state too many nested saves\n", info->ip);
2930 else
2931 info->state_stack[info->state_sp++] = info->state;
2932 break;
2934 TRACE("%lx: DW_CFA_restore_state\n", info->ip);
2935 if (!info->state_sp)
2936 FIXME("%lx: DW_CFA_restore_state without corresponding save\n", info->ip);
2937 else
2938 info->state = info->state_stack[--info->state_sp];
2939 break;
2940 case DW_CFA_def_cfa:
2941 case DW_CFA_def_cfa_sf:
2942 {
2945 : dwarf2_leb128_as_signed(ctx) * info->data_align;
2946 if (!valid_reg(reg)) break;
2947 TRACE("%lx: DW_CFA_def_cfa %s, %ld\n",
2948 info->ip,
2949 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)),
2950 offset);
2951 info->state.cfa_reg = reg;
2952 info->state.cfa_offset = offset;
2953 info->state.cfa_rule = RULE_CFA_OFFSET;
2954 break;
2955 }
2957 {
2959 if (!valid_reg(reg)) break;
2960 TRACE("%lx: DW_CFA_def_cfa_register %s\n",
2961 info->ip,
2962 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)));
2963 info->state.cfa_reg = reg;
2964 info->state.cfa_rule = RULE_CFA_OFFSET;
2965 break;
2966 }
2969 {
2971 : dwarf2_leb128_as_signed(ctx) * info->data_align;
2972 TRACE("%lx: DW_CFA_def_cfa_offset %ld\n", info->ip, offset);
2973 info->state.cfa_offset = offset;
2974 info->state.cfa_rule = RULE_CFA_OFFSET;
2975 break;
2976 }
2978 {
2979 ULONG_PTR expr = (ULONG_PTR)ctx->data;
2981 TRACE("%lx: DW_CFA_def_cfa_expression %lx-%lx\n", info->ip, expr, expr+len);
2982 info->state.cfa_offset = expr;
2983 info->state.cfa_rule = RULE_VAL_EXPRESSION;
2984 ctx->data += len;
2985 break;
2986 }
2987 case DW_CFA_expression:
2989 {
2991 ULONG_PTR expr = (ULONG_PTR)ctx->data;
2993 if (!valid_reg(reg)) break;
2994 TRACE("%lx: DW_CFA_%sexpression %s %lx-%lx\n",
2995 info->ip, (op == DW_CFA_expression) ? "" : "val_",
2996 dbghelp_current_cpu->fetch_regname(dbghelp_current_cpu->map_dwarf_register(reg, module, TRUE)),
2997 expr, expr + len);
2998 info->state.regs[reg] = expr;
3000 ctx->data += len;
3001 break;
3002 }
3004 /* FIXME: should check that GCC is the compiler for this CU */
3005 {
3007 TRACE("%lx: DW_CFA_GNU_args_size %lu\n", info->ip, args);
3008 /* ignored */
3009 break;
3010 }
3011 default:
3012 FIXME("%lx: unknown CFA opcode %02x\n", info->ip, op);
3013 break;
3014 }
3015 }
3016}
dwarf_call_frame_info
Definition: dwarf.h:506
@ DW_CFA_offset_extended
Definition: dwarf.h:515
@ DW_CFA_restore
Definition: dwarf.h:509
@ DW_CFA_def_cfa_sf
Definition: dwarf.h:528
@ DW_CFA_def_cfa_expression
Definition: dwarf.h:525
@ DW_CFA_remember_state
Definition: dwarf.h:520
@ DW_CFA_offset_extended_sf
Definition: dwarf.h:527
@ DW_CFA_nop
Definition: dwarf.h:510
@ DW_CFA_register
Definition: dwarf.h:519
@ DW_CFA_expression
Definition: dwarf.h:526
@ DW_CFA_advance_loc1
Definition: dwarf.h:512
@ DW_CFA_restore_state
Definition: dwarf.h:521
@ DW_CFA_def_cfa
Definition: dwarf.h:522
@ DW_CFA_undefined
Definition: dwarf.h:517
@ DW_CFA_val_expression
Definition: dwarf.h:532
@ DW_CFA_offset
Definition: dwarf.h:508
@ DW_CFA_def_cfa_register
Definition: dwarf.h:523
@ DW_CFA_GNU_args_size
Definition: dwarf.h:535
@ DW_CFA_restore_extended
Definition: dwarf.h:516
@ DW_CFA_def_cfa_offset_sf
Definition: dwarf.h:529
@ DW_CFA_set_loc
Definition: dwarf.h:511
@ DW_CFA_def_cfa_offset
Definition: dwarf.h:524
@ DW_CFA_advance_loc2
Definition: dwarf.h:513
@ DW_CFA_same_value
Definition: dwarf.h:518
@ DW_CFA_advance_loc4
Definition: dwarf.h:514
@ DW_CFA_advance_loc
Definition: dwarf.h:507
static int valid_reg(ULONG_PTR reg)
Definition: dwarf.c:2786
#define MAX_SAVED_STATES
Definition: dwarf.c:2569
Definition: match.c:390
Definition: query.h:87

Referenced by dwarf2_virtual_unwind().

◆ get_context_reg()

static DWORD64 get_context_reg ( const struct module module,
struct cpu_stack_walk csw,
union ctx context,
ULONG_PTR  dw_reg 
)
static

Definition at line 3019 of file dwarf.c.

3021{
3022 unsigned regno = csw->cpu->map_dwarf_register(dw_reg, module, TRUE), sz;
3023 void* ptr = csw->cpu->fetch_context_reg(context, regno, &sz);
3024
3025 if (sz == 8)
3026 return *(DWORD64 *)ptr;
3027 else if (sz == 4)
3028 return *(DWORD *)ptr;
3029
3030 FIXME("unhandled size %d\n", sz);
3031 return 0;
3032}

Referenced by apply_frame_state(), and eval_expression().

◆ loc_compute_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 
)
static

Definition at line 2507 of file dwarf.c.

2511{
2512 struct symt** psym = NULL;
2513 struct location* pframe;
2515 enum location_error err;
2516 unsigned int i;
2517
2518 for (i=0; i<vector_length(&func->vchildren); i++)
2519 {
2520 psym = vector_at(&func->vchildren, i);
2521 if ((*psym)->tag == SymTagCustom)
2522 {
2523 pframe = &((struct symt_hierarchy_point*)*psym)->loc;
2524
2525 /* First, recompute the frame information, if needed */
2526 switch (pframe->kind)
2527 {
2528 case loc_regrel:
2529 case loc_register:
2530 *frame = *pframe;
2531 break;
2533 WARN("Searching loclist for %s\n", debugstr_a(func->hash_elt.name));
2534 if (!dwarf2_lookup_loclist(modfmt,
2535 modfmt->u.dwarf2_info->debug_loc.address + pframe->offset,
2536 ip, &lctx))
2537 return loc_err_out_of_scope;
2538 if ((err = compute_location(modfmt->module, &lctx, frame, pcs->handle, NULL)) < 0) return err;
2539 if (frame->kind >= loc_user)
2540 {
2541 WARN("Couldn't compute runtime frame location\n");
2542 return loc_err_too_complex;
2543 }
2544 break;
2545 default:
2546 WARN("Unsupported frame kind %d\n", pframe->kind);
2547 return loc_err_internal;
2548 }
2549 return 0;
2550 }
2551 }
2552 WARN("Couldn't find Custom function point, whilst location list offset is searched\n");
2553 return loc_err_internal;
2554}

Referenced by dwarf2_location_compute().

◆ parse_cie_details()

static BOOL parse_cie_details ( dwarf2_traverse_context_t ctx,
struct frame_info info 
)
static

Definition at line 2640 of file dwarf.c.

2641{
2642 unsigned char version;
2643 const char* augmentation;
2644 const unsigned char* end;
2645 ULONG_PTR len;
2646
2647 memset(info, 0, sizeof(*info));
2648 info->lsda_encoding = DW_EH_PE_omit;
2649 info->aug_z_format = 0;
2650
2651 /* parse the CIE first */
2653 if (version != 1 && version != 3 && version != 4)
2654 {
2655 FIXME("unknown CIE version %u at %p\n", version, ctx->data - 1);
2656 return FALSE;
2657 }
2658 augmentation = (const char*)ctx->data;
2659 ctx->data += strlen(augmentation) + 1;
2660
2661 switch (version)
2662 {
2663 case 4:
2664 /* skip 'address_size' and 'segment_size' */
2665 ctx->data += 2;
2666 /* fallthrough */
2667 case 1:
2668 case 3:
2669 info->code_align = dwarf2_leb128_as_unsigned(ctx);
2670 info->data_align = dwarf2_leb128_as_signed(ctx);
2672 break;
2673 default:
2674 ;
2675 }
2676 info->state.cfa_rule = RULE_CFA_OFFSET;
2677
2678 end = NULL;
2679 TRACE("\tparsing augmentation %s\n", debugstr_a(augmentation));
2680 if (*augmentation) do
2681 {
2682 switch (*augmentation)
2683 {
2684 case 'z':
2686 end = ctx->data + len;
2687 info->aug_z_format = 1;
2688 continue;
2689 case 'L':
2690 info->lsda_encoding = dwarf2_parse_byte(ctx);
2691 continue;
2692 case 'P':
2693 {
2694 unsigned char encoding = dwarf2_parse_byte(ctx);
2695 /* throw away the indirect bit, as we don't care for the result */
2696 encoding &= ~DW_EH_PE_indirect;
2698 continue;
2699 }
2700 case 'R':
2701 info->fde_encoding = dwarf2_parse_byte(ctx);
2702 continue;
2703 case 'S':
2704 info->signal_frame = 1;
2705 continue;
2706 }
2707 FIXME("unknown augmentation '%c'\n", *augmentation);
2708 if (!end) return FALSE;
2709 break;
2710 } while (*++augmentation);
2711 if (end) ctx->data = end;
2712 return TRUE;
2713}
static const WCHAR version[]
Definition: asmname.c:66

Referenced by dwarf2_get_cie().

◆ set_context_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

Definition at line 3035 of file dwarf.c.

3037{
3038 unsigned regno = csw->cpu->map_dwarf_register(dw_reg, module, TRUE), sz;
3039 ULONG_PTR* ptr = csw->cpu->fetch_context_reg(context, regno, &sz);
3040
3041 if (isdebuggee)
3042 {
3043 char tmp[16];
3044
3045 if (sz > sizeof(tmp))
3046 {
3047 FIXME("register %lu/%u size is too wide: %u\n", dw_reg, regno, sz);
3048 return;
3049 }
3050 if (!sw_read_mem(csw, val, tmp, sz))
3051 {
3052 WARN("Couldn't read memory at %p\n", (void*)val);
3053 return;
3054 }
3055 memcpy(ptr, tmp, sz);
3056 }
3057 else
3058 {
3059 if (sz != sizeof(ULONG_PTR))
3060 {
3061 FIXME("assigning to register %lu/%u of wrong size %u\n", dw_reg, regno, sz);
3062 return;
3063 }
3064 *ptr = val;
3065 }
3066}
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by apply_frame_state().

◆ valid_reg()

static int valid_reg ( ULONG_PTR  reg)
static

Definition at line 2786 of file dwarf.c.

2787{
2788 if (reg >= NB_FRAME_REGS) FIXME("unsupported reg %lx\n", reg);
2789 return (reg < NB_FRAME_REGS);
2790}

Referenced by execute_cfa_instructions().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dbghelp_dwarf  )

◆ zalloc()

static void * zalloc ( void priv,
uInt  items,
uInt  sz 
)
static

Definition at line 3386 of file dwarf.c.

3387{
3388 return HeapAlloc(GetProcessHeap(), 0, items * sz);
3389}
static TCHAR * items[]
Definition: page1.c:45

Referenced by dwarf2_init_zsection().

◆ zfree()

static void zfree ( void priv,
void addr 
)
static

Definition at line 3391 of file dwarf.c.

3392{
3394}

Referenced by dwarf2_init_zsection().