diff options
Diffstat (limited to 'gdb/dwarf2expr.c')
-rw-r--r-- | gdb/dwarf2expr.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c index 13d318e..bf5f7c9 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c @@ -143,6 +143,14 @@ dwarf_expr_fetch_in_stack_memory (struct dwarf_expr_context *ctx, int n) } +/* Return true if the expression stack is empty. */ + +static int +dwarf_expr_stack_empty_p (struct dwarf_expr_context *ctx) +{ + return ctx->stack_len == 0; +} + /* Add a new piece to CTX's piece list. */ static void add_piece (struct dwarf_expr_context *ctx, ULONGEST size) @@ -167,6 +175,15 @@ add_piece (struct dwarf_expr_context *ctx, ULONGEST size) p->v.literal.data = ctx->data; p->v.literal.length = ctx->len; } + else if (dwarf_expr_stack_empty_p (ctx)) + { + p->location = DWARF_VALUE_OPTIMIZED_OUT; + /* Also reset the context's location, for our callers. This is + a somewhat strange approach, but this lets us avoid setting + the location to DWARF_VALUE_MEMORY in all the individual + cases in the evaluator. */ + ctx->location = DWARF_VALUE_OPTIMIZED_OUT; + } else { p->v.expr.value = dwarf_expr_fetch (ctx, 0); @@ -859,7 +876,8 @@ execute_stack_op (struct dwarf_expr_context *ctx, /* Pop off the address/regnum, and reset the location type. */ - if (ctx->location != DWARF_VALUE_LITERAL) + if (ctx->location != DWARF_VALUE_LITERAL + && ctx->location != DWARF_VALUE_OPTIMIZED_OUT) dwarf_expr_pop (ctx); ctx->location = DWARF_VALUE_MEMORY; } |