2009-12-23 Stan Shebs <stan@codesourcery.com>
authorStan Shebs <shebs@codesourcery.com>
Thu, 24 Dec 2009 01:42:03 +0000 (01:42 +0000)
committerStan Shebs <shebs@codesourcery.com>
Thu, 24 Dec 2009 01:42:03 +0000 (01:42 +0000)
* ax-gdb.c (gen_expr): Handle OP_THIS.

gdb/ChangeLog
gdb/ax-gdb.c

index f32d287..e1115bc 100644 (file)
@@ -1,5 +1,7 @@
 2009-12-23  Stan Shebs  <stan@codesourcery.com>
 
+       * ax-gdb.c (gen_expr): Handle OP_THIS.
+
        * ax-gdb.h (gen_trace_for_var): Declare.
        * ax-gdb.c (gen_trace_for_var): New function.
        * dwarf2loc.c (dwarf_expr_frame_base_1): New function, split from...
index 4d3f3ac..a1c3d6e 100644 (file)
@@ -35,6 +35,7 @@
 #include "regcache.h"
 #include "user-regs.h"
 #include "language.h"
+#include "dictionary.h"
 
 /* To make sense of this file, you should read doc/agentexpr.texi.
    Then look at the types and enums in ax-gdb.h.  For the code itself,
@@ -1759,6 +1760,38 @@ gen_expr (struct expression *exp, union exp_element **pc,
       }
       break;
 
+    case OP_THIS:
+      {
+       char *name;
+       struct frame_info *frame;
+       struct symbol *func, *sym;
+       struct block *b;
+
+       name = current_language->la_name_of_this;
+       if (!name)
+         error (_("no `this' in current language"));
+
+       frame = get_selected_frame (_("no frame selected"));
+
+       func = get_frame_function (frame);
+       if (!func)
+         error (_("no `%s' in nameless context"), name);
+
+       b = SYMBOL_BLOCK_VALUE (func);
+       if (dict_empty (BLOCK_DICT (b)))
+         error (_("no args, no `%s' in block"), name);
+
+       /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
+          symbol instead of the LOC_ARG one (if both exist).  */
+       sym = lookup_block_symbol (b, name, NULL, VAR_DOMAIN);
+       if (!sym)
+         error (_("no `%s' found"), name);
+
+       gen_var_ref (exp->gdbarch, ax, value, sym);
+       (*pc) += 2;
+      }
+      break;
+
     case OP_TYPE:
       error (_("Attempt to use a type name as an expression."));