*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / parse.c
index 8841e598a0e3b20474737b791f4e2224aef82005..9c0edf52a22847fccb49d2b41e867bb51a0761d5 100644 (file)
@@ -1,7 +1,8 @@
 /* Parse expressions for GDB.
 
    Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2004, 2005, 2007 Free Software Foundation, Inc.
+   1998, 1999, 2000, 2001, 2004, 2005, 2007, 2008
+   Free Software Foundation, Inc.
 
    Modified from expread.y by the Department of Computer Science at the
    State University of New York at Buffalo, 1991.
@@ -399,39 +400,46 @@ write_exp_msymbol (struct minimal_symbol *msymbol,
                   struct type *text_symbol_type, 
                   struct type *data_symbol_type)
 {
-  struct gdbarch *gdbarch = current_gdbarch;
-  CORE_ADDR addr;
+  struct objfile *objfile = msymbol_objfile (msymbol);
+  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+
+  CORE_ADDR addr = SYMBOL_VALUE_ADDRESS (msymbol);
+  asection *bfd_section = SYMBOL_BFD_SECTION (msymbol);
+  enum minimal_symbol_type type = msymbol->type;
+  CORE_ADDR pc;
+
+  /* The minimal symbol might point to a function descriptor;
+     resolve it to the actual code address instead.  */
+  pc = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, &current_target);
+  if (pc != addr)
+    {
+      /* In this case, assume we have a code symbol instead of
+        a data symbol.  */
+      type = mst_text;
+      bfd_section = NULL;
+      addr = pc;
+    }
+
+  if (overlay_debugging)
+    addr = symbol_overlayed_address (addr, bfd_section);
 
   write_exp_elt_opcode (OP_LONG);
   /* Let's make the type big enough to hold a 64-bit address.  */
   write_exp_elt_type (builtin_type_CORE_ADDR);
-
-  addr = SYMBOL_VALUE_ADDRESS (msymbol);
-  if (overlay_debugging)
-    addr = symbol_overlayed_address (addr, SYMBOL_BFD_SECTION (msymbol));
   write_exp_elt_longcst ((LONGEST) addr);
-
   write_exp_elt_opcode (OP_LONG);
 
-  if (SYMBOL_BFD_SECTION (msymbol)
-      && SYMBOL_BFD_SECTION (msymbol)->flags & SEC_THREAD_LOCAL)
+  if (bfd_section && bfd_section->flags & SEC_THREAD_LOCAL)
     {
-      bfd *bfd = SYMBOL_BFD_SECTION (msymbol)->owner;
-      struct objfile *ofp;
-
-      ALL_OBJFILES (ofp)
-       if (ofp->obfd == bfd)
-         break;
-
       write_exp_elt_opcode (UNOP_MEMVAL_TLS);
-      write_exp_elt_objfile (ofp);
+      write_exp_elt_objfile (objfile);
       write_exp_elt_type (builtin_type (gdbarch)->nodebug_tls_symbol);
       write_exp_elt_opcode (UNOP_MEMVAL_TLS);
       return;
     }
 
   write_exp_elt_opcode (UNOP_MEMVAL);
-  switch (msymbol->type)
+  switch (type)
     {
     case mst_text:
     case mst_file_text:
@@ -661,8 +669,7 @@ copy_name (struct stoken token)
 static void
 prefixify_expression (struct expression *expr)
 {
-  int len =
-  sizeof (struct expression) + EXP_ELEM_TO_BYTES (expr->nelts);
+  int len = sizeof (struct expression) + EXP_ELEM_TO_BYTES (expr->nelts);
   struct expression *temp;
   int inpos = expr->nelts, outpos = 0;
 
@@ -954,26 +961,24 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma,
   old_chain = make_cleanup (free_funcalls, 0 /*ignore*/);
   funcall_chain = 0;
 
-  /* If no context specified, try using the current frame, if any. */
+  expression_context_block = block;
 
-  if (!block)
-    block = get_selected_block (&expression_context_pc);
+  /* If no context specified, try using the current frame, if any.  */
+  if (!expression_context_block)
+    expression_context_block = get_selected_block (&expression_context_pc);
+  else
+    expression_context_pc = BLOCK_START (expression_context_block);
 
-  /* Fall back to using the current source static context, if any. */
+  /* Fall back to using the current source static context, if any.  */
 
-  if (!block)
+  if (!expression_context_block)
     {
       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
       if (cursal.symtab)
-       block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK);
-    }
-
-  /* Save the context, if specified by caller, or found above. */
-
-  if (block)
-    {
-      expression_context_block = block;
-      expression_context_pc = BLOCK_START (block);
+       expression_context_block
+         = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK);
+      if (expression_context_block)
+       expression_context_pc = BLOCK_START (expression_context_block);
     }
 
   expout_size = 10;
@@ -1028,20 +1033,6 @@ parse_expression (char *string)
   return exp;
 }
 
-
-/* As for parse_expression, except that if VOID_CONTEXT_P, then
-   no value is expected from the expression.  */
-
-struct expression *
-parse_expression_in_context (char *string, int void_context_p)
-{
-  struct expression *exp;
-  exp = parse_exp_in_context (&string, 0, 0, void_context_p);
-  if (*string != '\000')
-    error (_("Junk after end of expression."));
-  return exp;
-}
-
 /* A post-parser that does nothing */
 
 void
This page took 0.028291 seconds and 4 git commands to generate.