2004-08-13 Michael Chastain <mec.gnu@mindspring.com>
[deliverable/binutils-gdb.git] / gdb / dwarf2loc.c
index 01a2ddac940879f41eda3a2d2c1c6e80edec3f82..cdbeb10acf43eef6557822c49be23169406e1a54 100644 (file)
@@ -53,11 +53,14 @@ static char *
 find_location_expression (struct dwarf2_loclist_baton *baton,
                          size_t *locexpr_length, CORE_ADDR pc)
 {
-  CORE_ADDR base_address = baton->base_address;
   CORE_ADDR low, high;
   char *loc_ptr, *buf_end;
   unsigned int addr_size = TARGET_ADDR_BIT / TARGET_CHAR_BIT, length;
   CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
+  /* Adjust base_address for relocatable objects.  */
+  CORE_ADDR base_offset = ANOFFSET (baton->objfile->section_offsets,
+                                   SECT_OFF_TEXT (baton->objfile));
+  CORE_ADDR base_address = baton->base_address + base_offset;
 
   loc_ptr = baton->data;
   buf_end = baton->data + baton->size;
@@ -154,7 +157,7 @@ dwarf_expr_frame_base (void *baton, unsigned char **start, size_t * length)
 
   framefunc = get_frame_function (debaton->frame);
 
-  if (SYMBOL_LOCATION_FUNCS (framefunc) == &dwarf2_loclist_funcs)
+  if (SYMBOL_OPS (framefunc) == &dwarf2_loclist_funcs)
     {
       struct dwarf2_loclist_baton *symbaton;
       symbaton = SYMBOL_LOCATION_BATON (framefunc);
@@ -304,6 +307,7 @@ dwarf2_loc_desc_needs_frame (unsigned char *data, unsigned short size)
 {
   struct needs_frame_baton baton;
   struct dwarf_expr_context *ctx;
+  int in_reg;
 
   baton.needs_frame = 0;
 
@@ -316,9 +320,11 @@ dwarf2_loc_desc_needs_frame (unsigned char *data, unsigned short size)
 
   dwarf_expr_eval (ctx, data, size);
 
+  in_reg = ctx->in_reg;
+
   free_dwarf_expr_context (ctx);
 
-  return baton.needs_frame;
+  return baton.needs_frame || in_reg;
 }
 
 static void
@@ -427,10 +433,10 @@ locexpr_describe_location (struct symbol *symbol, struct ui_file *stream)
       {
        int bytes_read;
        CORE_ADDR offset = dwarf2_read_address (&dlbaton->data[1],
-                                               &dlbaton->data[dlbaton->size - 2],
+                                               &dlbaton->data[dlbaton->size - 1],
                                                &bytes_read);
        fprintf_filtered (stream, 
-                         "a thread-local variable at offset %s in the"
+                         "a thread-local variable at offset %s in the "
                          "thread-local storage for `%s'",
                          paddr_nz (offset), dlbaton->objfile->name);
        return 1;
@@ -462,7 +468,7 @@ locexpr_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax,
 
 /* The set of location functions used with the DWARF-2 expression
    evaluator.  */
-struct location_funcs dwarf2_locexpr_funcs = {
+const struct symbol_ops dwarf2_locexpr_funcs = {
   locexpr_read_variable,
   locexpr_read_needs_frame,
   locexpr_describe_location,
@@ -534,7 +540,7 @@ loclist_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax,
 
 /* The set of location functions used with the DWARF-2 expression
    evaluator and location lists.  */
-struct location_funcs dwarf2_loclist_funcs = {
+const struct symbol_ops dwarf2_loclist_funcs = {
   loclist_read_variable,
   loclist_read_needs_frame,
   loclist_describe_location,
This page took 0.024615 seconds and 4 git commands to generate.