From 36dc683c524086a6ed9b74375d6501a33e875182 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Wed, 18 Mar 2009 16:22:50 +0000 Subject: [PATCH] * printcmd.c (display_uses_solib_p): Redo loop, scan element list backwards. --- gdb/ChangeLog | 5 +++++ gdb/printcmd.c | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d0d562f176c..abaa78a2993 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2009-03-18 Doug Evans + + * printcmd.c (display_uses_solib_p): Redo loop, scan element list + backwards. + 2009-03-18 Nathan Sidwell * Makefile.in: Update license to GPLv3. diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 23a22305d04..5268b1da19c 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1763,18 +1763,23 @@ static int display_uses_solib_p (const struct display *d, const struct so_list *solib) { - int i; + int endpos; struct expression *const exp = d->exp; + const union exp_element *const elts = exp->elts; if (d->block != NULL && solib_contains_address_p (solib, d->block->startaddr)) return 1; - for (i = 0; i < exp->nelts; ) + for (endpos = exp->nelts; endpos > 0; ) { - int args, oplen = 0; - const union exp_element *const elts = exp->elts; + int i, args, oplen = 0; + + exp->language_defn->la_exp_desc->operator_length (exp, endpos, + &oplen, &args); + gdb_assert (oplen > 0); + i = endpos - oplen; if (elts[i].opcode == OP_VAR_VALUE) { const struct block *const block = elts[i + 1].block; @@ -1789,11 +1794,9 @@ display_uses_solib_p (const struct display *d, if (section && section->objfile == solib->objfile) return 1; } - exp->language_defn->la_exp_desc->operator_length (exp, i + 1, - &oplen, &args); - gdb_assert (oplen > 0); - i += oplen; + endpos -= oplen; } + return 0; } -- 2.30.2