Make GDB wait for events after handling target File-I/O
[deliverable/binutils-gdb.git] / gdb / dwarf2loc.c
index 91cb99a76de99d35203ae4575a705d5c25c30506..3e652f97ac190a6691efa87a0e03ed4936fd5f0a 100644 (file)
@@ -375,16 +375,18 @@ static void
 locexpr_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc,
                                  const gdb_byte **start, size_t *length)
 {
-  struct dwarf2_locexpr_baton *symbaton = SYMBOL_LOCATION_BATON (framefunc);
+  struct dwarf2_locexpr_baton *symbaton
+    = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (framefunc);
 
   *length = symbaton->size;
   *start = symbaton->data;
 }
 
-/* Implement the struct symbol_block_ops::get_frame_base method.  */
+/* Implement the struct symbol_block_ops::get_frame_base method for
+   LOC_BLOCK functions using a DWARF expression as its DW_AT_frame_base.  */
 
 static CORE_ADDR
-block_op_get_frame_base (struct symbol *framefunc, struct frame_info *frame)
+locexpr_get_frame_base (struct symbol *framefunc, struct frame_info *frame)
 {
   struct gdbarch *gdbarch;
   struct type *type;
@@ -400,7 +402,7 @@ block_op_get_frame_base (struct symbol *framefunc, struct frame_info *frame)
 
   gdbarch = get_frame_arch (frame);
   type = builtin_type (gdbarch)->builtin_data_ptr;
-  dlbaton = SYMBOL_LOCATION_BATON (framefunc);
+  dlbaton = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (framefunc);
 
   SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location
     (framefunc, get_frame_pc (frame), &start, &length);
@@ -421,7 +423,7 @@ block_op_get_frame_base (struct symbol *framefunc, struct frame_info *frame)
 const struct symbol_block_ops dwarf2_block_frame_base_locexpr_funcs =
 {
   locexpr_find_frame_base_location,
-  block_op_get_frame_base
+  locexpr_get_frame_base
 };
 
 /* Implement find_frame_base_location method for LOC_BLOCK functions using
@@ -431,18 +433,54 @@ static void
 loclist_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc,
                                  const gdb_byte **start, size_t *length)
 {
-  struct dwarf2_loclist_baton *symbaton = SYMBOL_LOCATION_BATON (framefunc);
+  struct dwarf2_loclist_baton *symbaton
+    = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (framefunc);
 
   *start = dwarf2_find_location_expression (symbaton, length, pc);
 }
 
+/* Implement the struct symbol_block_ops::get_frame_base method for
+   LOC_BLOCK functions using a DWARF location list as its DW_AT_frame_base.  */
+
+static CORE_ADDR
+loclist_get_frame_base (struct symbol *framefunc, struct frame_info *frame)
+{
+  struct gdbarch *gdbarch;
+  struct type *type;
+  struct dwarf2_loclist_baton *dlbaton;
+  const gdb_byte *start;
+  size_t length;
+  struct value *result;
+
+  /* If this method is called, then FRAMEFUNC is supposed to be a DWARF block.
+     Thus, it's supposed to provide the find_frame_base_location method as
+     well.  */
+  gdb_assert (SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location != NULL);
+
+  gdbarch = get_frame_arch (frame);
+  type = builtin_type (gdbarch)->builtin_data_ptr;
+  dlbaton = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (framefunc);
+
+  SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location
+    (framefunc, get_frame_pc (frame), &start, &length);
+  result = dwarf2_evaluate_loc_desc (type, frame, start, length,
+                                    dlbaton->per_cu);
+
+  /* The DW_AT_frame_base attribute contains a location description which
+     computes the base address itself.  However, the call to
+     dwarf2_evaluate_loc_desc returns a value representing a variable at
+     that address.  The frame base address is thus this variable's
+     address.  */
+  return value_address (result);
+}
+
 /* Vector for inferior functions as represented by LOC_BLOCK, if the inferior
    function uses DWARF location list for its DW_AT_frame_base.  */
 
 const struct symbol_block_ops dwarf2_block_frame_base_loclist_funcs =
 {
   loclist_find_frame_base_location,
-  block_op_get_frame_base
+  loclist_get_frame_base
 };
 
 /* See dwarf2loc.h.  */
@@ -523,7 +561,7 @@ per_cu_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset,
 static void
 dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset)
 {
-  struct dwarf_expr_baton *debaton = ctx->baton;
+  struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) ctx->baton;
 
   per_cu_dwarf_call (ctx, die_offset, debaton->per_cu,
                     ctx->funcs->get_frame_pc, ctx->baton);
@@ -535,7 +573,7 @@ static struct type *
 dwarf_expr_get_base_type (struct dwarf_expr_context *ctx,
                          cu_offset die_offset)
 {
-  struct dwarf_expr_baton *debaton = ctx->baton;
+  struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) ctx->baton;
 
   return dwarf2_get_die_type (die_offset, debaton->per_cu);
 }
@@ -787,8 +825,9 @@ chain_candidate (struct gdbarch *gdbarch, struct call_site_chain **resultp,
     {
       /* Create the initial chain containing all the passed PCs.  */
 
-      result = xmalloc (sizeof (*result) + sizeof (*result->call_site)
-                                          * (length - 1));
+      result = ((struct call_site_chain *)
+               xmalloc (sizeof (*result)
+                        + sizeof (*result->call_site) * (length - 1)));
       result->length = length;
       result->callers = result->callees = length;
       if (!VEC_empty (call_sitep, chain))
@@ -1196,7 +1235,7 @@ dwarf_entry_parameter_to_value (struct call_site_parameter *parameter,
   /* DW_AT_GNU_call_site_value is a DWARF expression, not a DWARF
      location.  Postprocessing of DWARF_VALUE_MEMORY would lose the type from
      DWARF block.  */
-  data = alloca (size + 1);
+  data = (gdb_byte *) alloca (size + 1);
   memcpy (data, data_src, size);
   data[size] = DW_OP_stack_value;
 
@@ -1226,7 +1265,7 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx,
   size_t size;
 
   gdb_assert (ctx->funcs == &dwarf_expr_ctx_funcs);
-  debaton = ctx->baton;
+  debaton = (struct dwarf_expr_baton *) ctx->baton;
   frame = debaton->frame;
   caller_frame = get_prev_frame (frame);
 
@@ -1278,7 +1317,7 @@ dwarf_expr_get_addr_index (void *baton, unsigned int index)
 static CORE_ADDR
 dwarf_expr_get_obj_addr (void *baton)
 {
-  struct dwarf_expr_baton *debaton = baton;
+  struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
 
   gdb_assert (debaton != NULL);
 
@@ -1301,7 +1340,7 @@ entry_data_value_coerce_ref (const struct value *value)
   if (TYPE_CODE (checked_type) != TYPE_CODE_REF)
     return NULL;
 
-  target_val = value_computed_closure (value);
+  target_val = (struct value *) value_computed_closure (value);
   value_incref (target_val);
   return target_val;
 }
@@ -1311,7 +1350,7 @@ entry_data_value_coerce_ref (const struct value *value)
 static void *
 entry_data_value_copy_closure (const struct value *v)
 {
-  struct value *target_val = value_computed_closure (v);
+  struct value *target_val = (struct value *) value_computed_closure (v);
 
   value_incref (target_val);
   return target_val;
@@ -1322,7 +1361,7 @@ entry_data_value_copy_closure (const struct value *v)
 static void
 entry_data_value_free_closure (struct value *v)
 {
-  struct value *target_val = value_computed_closure (v);
+  struct value *target_val = (struct value *) value_computed_closure (v);
 
   value_free (target_val);
 }
@@ -1708,7 +1747,7 @@ read_pieced_value (struct value *v)
       if (buffer_size < this_size)
        {
          buffer_size = this_size;
-         buffer = xrealloc (buffer, buffer_size);
+         buffer = (gdb_byte *) xrealloc (buffer, buffer_size);
        }
       intermediate_buffer = buffer;
 
@@ -1899,7 +1938,7 @@ write_pieced_value (struct value *to, struct value *from)
          if (buffer_size < this_size)
            {
              buffer_size = this_size;
-             buffer = xrealloc (buffer, buffer_size);
+             buffer = (gdb_byte *) xrealloc (buffer, buffer_size);
            }
          source_buffer = buffer;
          need_bitwise = 1;
@@ -2031,7 +2070,7 @@ check_pieced_synthetic_pointer (const struct value *value, int bit_offset,
 static CORE_ADDR
 get_frame_address_in_block_wrapper (void *baton)
 {
-  return get_frame_address_in_block (baton);
+  return get_frame_address_in_block ((struct frame_info *) baton);
 }
 
 /* An implementation of an lval_funcs method to indirect through a
@@ -2512,7 +2551,8 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
     {
     case PROP_LOCEXPR:
       {
-       const struct dwarf2_property_baton *baton = prop->data.baton;
+       const struct dwarf2_property_baton *baton
+         = (const struct dwarf2_property_baton *) prop->data.baton;
 
        if (dwarf2_locexpr_baton_eval (&baton->locexpr, frame,
                                       addr_stack ? addr_stack->addr : 0,
@@ -2531,7 +2571,8 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
 
     case PROP_LOCLIST:
       {
-       struct dwarf2_property_baton *baton = prop->data.baton;
+       struct dwarf2_property_baton *baton
+         = (struct dwarf2_property_baton *) prop->data.baton;
        CORE_ADDR pc = get_frame_address_in_block (frame);
        const gdb_byte *data;
        struct value *val;
@@ -2557,7 +2598,8 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
 
     case PROP_ADDR_OFFSET:
       {
-       struct dwarf2_property_baton *baton = prop->data.baton;
+       struct dwarf2_property_baton *baton
+         = (struct dwarf2_property_baton *) prop->data.baton;
        struct property_addr_info *pinfo;
        struct value *val;
 
@@ -2592,7 +2634,8 @@ dwarf2_compile_property_to_c (struct ui_file *stream,
                              CORE_ADDR pc,
                              struct symbol *sym)
 {
-  struct dwarf2_property_baton *baton = prop->data.baton;
+  struct dwarf2_property_baton *baton
+    = (struct dwarf2_property_baton *) prop->data.baton;
   const gdb_byte *data;
   size_t size;
   struct dwarf2_per_cu_data *per_cu;
@@ -2630,7 +2673,7 @@ struct needs_frame_baton
 static CORE_ADDR
 needs_frame_read_addr_from_reg (void *baton, int regnum)
 {
-  struct needs_frame_baton *nf_baton = baton;
+  struct needs_frame_baton *nf_baton = (struct needs_frame_baton *) baton;
 
   nf_baton->needs_frame = 1;
   return 1;
@@ -2642,7 +2685,7 @@ needs_frame_read_addr_from_reg (void *baton, int regnum)
 static struct value *
 needs_frame_get_reg_value (void *baton, struct type *type, int regnum)
 {
-  struct needs_frame_baton *nf_baton = baton;
+  struct needs_frame_baton *nf_baton = (struct needs_frame_baton *) baton;
 
   nf_baton->needs_frame = 1;
   return value_zero (type, not_lval);
@@ -2660,7 +2703,7 @@ static void
 needs_frame_frame_base (void *baton, const gdb_byte **start, size_t * length)
 {
   static gdb_byte lit0 = DW_OP_lit0;
-  struct needs_frame_baton *nf_baton = baton;
+  struct needs_frame_baton *nf_baton = (struct needs_frame_baton *) baton;
 
   *start = &lit0;
   *length = 1;
@@ -2673,7 +2716,7 @@ needs_frame_frame_base (void *baton, const gdb_byte **start, size_t * length)
 static CORE_ADDR
 needs_frame_frame_cfa (void *baton)
 {
-  struct needs_frame_baton *nf_baton = baton;
+  struct needs_frame_baton *nf_baton = (struct needs_frame_baton *) baton;
 
   nf_baton->needs_frame = 1;
   return 1;
@@ -2683,7 +2726,7 @@ needs_frame_frame_cfa (void *baton)
 static CORE_ADDR
 needs_frame_tls_address (void *baton, CORE_ADDR offset)
 {
-  struct needs_frame_baton *nf_baton = baton;
+  struct needs_frame_baton *nf_baton = (struct needs_frame_baton *) baton;
 
   nf_baton->needs_frame = 1;
   return 1;
@@ -2694,7 +2737,7 @@ needs_frame_tls_address (void *baton, CORE_ADDR offset)
 static void
 needs_frame_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset)
 {
-  struct needs_frame_baton *nf_baton = ctx->baton;
+  struct needs_frame_baton *nf_baton = (struct needs_frame_baton *) ctx->baton;
 
   per_cu_dwarf_call (ctx, die_offset, nf_baton->per_cu,
                     ctx->funcs->get_frame_pc, ctx->baton);
@@ -2707,7 +2750,7 @@ needs_dwarf_reg_entry_value (struct dwarf_expr_context *ctx,
                             enum call_site_parameter_kind kind,
                             union call_site_parameter_u kind_u, int deref_size)
 {
-  struct needs_frame_baton *nf_baton = ctx->baton;
+  struct needs_frame_baton *nf_baton = (struct needs_frame_baton *) ctx->baton;
 
   nf_baton->needs_frame = 1;
 
@@ -2874,7 +2917,7 @@ access_memory (struct gdbarch *arch, struct agent_expr *expr, ULONGEST nbits)
 static CORE_ADDR
 get_ax_pc (void *baton)
 {
-  struct agent_expr *expr = baton;
+  struct agent_expr *expr = (struct agent_expr *) baton;
 
   return expr->scope;
 }
@@ -3564,7 +3607,8 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
 static struct value *
 locexpr_read_variable (struct symbol *symbol, struct frame_info *frame)
 {
-  struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+  struct dwarf2_locexpr_baton *dlbaton
+    = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
   struct value *val;
 
   val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, dlbaton->data,
@@ -3580,7 +3624,8 @@ locexpr_read_variable (struct symbol *symbol, struct frame_info *frame)
 static struct value *
 locexpr_read_variable_at_entry (struct symbol *symbol, struct frame_info *frame)
 {
-  struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+  struct dwarf2_locexpr_baton *dlbaton
+    = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
 
   return value_of_dwarf_block_entry (SYMBOL_TYPE (symbol), frame, dlbaton->data,
                                     dlbaton->size);
@@ -3590,7 +3635,8 @@ locexpr_read_variable_at_entry (struct symbol *symbol, struct frame_info *frame)
 static int
 locexpr_read_needs_frame (struct symbol *symbol)
 {
-  struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+  struct dwarf2_locexpr_baton *dlbaton
+    = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
 
   return dwarf2_loc_desc_needs_frame (dlbaton->data, dlbaton->size,
                                      dlbaton->per_cu);
@@ -4255,7 +4301,8 @@ static void
 locexpr_describe_location (struct symbol *symbol, CORE_ADDR addr,
                           struct ui_file *stream)
 {
-  struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+  struct dwarf2_locexpr_baton *dlbaton
+    = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
   struct objfile *objfile = dwarf2_per_cu_objfile (dlbaton->per_cu);
   unsigned int addr_size = dwarf2_per_cu_addr_size (dlbaton->per_cu);
   int offset_size = dwarf2_per_cu_offset_size (dlbaton->per_cu);
@@ -4273,7 +4320,8 @@ static void
 locexpr_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
                            struct agent_expr *ax, struct axs_value *value)
 {
-  struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+  struct dwarf2_locexpr_baton *dlbaton
+    = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
   unsigned int addr_size = dwarf2_per_cu_addr_size (dlbaton->per_cu);
 
   if (dlbaton->size == 0)
@@ -4292,7 +4340,8 @@ locexpr_generate_c_location (struct symbol *sym, struct ui_file *stream,
                             unsigned char *registers_used,
                             CORE_ADDR pc, const char *result_name)
 {
-  struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (sym);
+  struct dwarf2_locexpr_baton *dlbaton
+    = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (sym);
   unsigned int addr_size = dwarf2_per_cu_addr_size (dlbaton->per_cu);
 
   if (dlbaton->size == 0)
@@ -4325,7 +4374,8 @@ const struct symbol_computed_ops dwarf2_locexpr_funcs = {
 static struct value *
 loclist_read_variable (struct symbol *symbol, struct frame_info *frame)
 {
-  struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+  struct dwarf2_loclist_baton *dlbaton
+    = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol);
   struct value *val;
   const gdb_byte *data;
   size_t size;
@@ -4349,7 +4399,8 @@ loclist_read_variable (struct symbol *symbol, struct frame_info *frame)
 static struct value *
 loclist_read_variable_at_entry (struct symbol *symbol, struct frame_info *frame)
 {
-  struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+  struct dwarf2_loclist_baton *dlbaton
+    = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol);
   const gdb_byte *data;
   size_t size;
   CORE_ADDR pc;
@@ -4385,7 +4436,8 @@ static void
 loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
                           struct ui_file *stream)
 {
-  struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+  struct dwarf2_loclist_baton *dlbaton
+    = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol);
   const gdb_byte *loc_ptr, *buf_end;
   struct objfile *objfile = dwarf2_per_cu_objfile (dlbaton->per_cu);
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
@@ -4474,7 +4526,8 @@ static void
 loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
                            struct agent_expr *ax, struct axs_value *value)
 {
-  struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+  struct dwarf2_loclist_baton *dlbaton
+    = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol);
   const gdb_byte *data;
   size_t size;
   unsigned int addr_size = dwarf2_per_cu_addr_size (dlbaton->per_cu);
@@ -4495,7 +4548,8 @@ loclist_generate_c_location (struct symbol *sym, struct ui_file *stream,
                             unsigned char *registers_used,
                             CORE_ADDR pc, const char *result_name)
 {
-  struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (sym);
+  struct dwarf2_loclist_baton *dlbaton
+    = (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (sym);
   unsigned int addr_size = dwarf2_per_cu_addr_size (dlbaton->per_cu);
   const gdb_byte *data;
   size_t size;
This page took 0.042031 seconds and 4 git commands to generate.