Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@mvista.com>
To: gdb@sources.redhat.com, jimb@redhat.com
Subject: Macro code crasher on re-run
Date: Mon, 03 Nov 2003 04:07:00 -0000	[thread overview]
Message-ID: <20031103040751.GA30979@nevyn.them.org> (raw)

There's a bug in default_macro_scope.  I was in the middle of working on
something else when GDB crashed, so I can't fix it now, and Jim probably can
think of a better fix than I can - hence this message :) Or I'll get to it
in a few days.

Here's the problem.  I've just typed "run".

82      struct macro_scope *
83      default_macro_scope (void)
84      {
85        struct symtab_and_line sal;
86        struct macro_source_file *main;
87        struct macro_scope *ms;
88
89        /* If there's a selected frame, use its PC.  */
90        if (deprecated_selected_frame)
91          sal = find_pc_line (get_frame_pc (deprecated_selected_frame), 0);

So deprecated_selected_frame is NULL...

92
93        /* If the target has any registers at all, then use its PC.  Why we
94           would have registers but no stack, I'm not sure.  */
95        else if (target_has_registers)
96          sal = find_pc_line (read_pc (), 0);

And target_has_registers is false.

97
98        /* If all else fails, fall back to the current listing position.  */
99        else
100         {
101           /* Don't call select_source_symtab here.  That can raise an
102              error if symbols aren't loaded, but GDB calls the expression
103              evaluator in all sorts of contexts.
104
105              For example, commands like `set width' call the expression
106              evaluator to evaluate their numeric arguments.  If the
107              current language is C, then that may call this function to
108              choose a scope for macro expansion.  If you don't have any
109              symbol files loaded, then get_current_or_default would raise an
110              error.  But `set width' shouldn't raise an error just because
111              it can't decide which scope to macro-expand its argument in.  */
112           struct symtab_and_line cursal = 
113                             get_current_source_symtab_and_line ();
114           
115           sal.symtab = cursal.symtab;
116           sal.line = cursal.line;
117         }

So we initialize just the symtab and line pointers.
118
119       return sal_macro_scope (sal);
120     }


39        if (! sal.symtab
40            || ! sal.symtab->macro_table)
41          return 0;

Oops, uninitialized memory read.  That else case can't work; Jim, should we
just return 0 from default_macro_scope if the target isn't running, or
is there a function I don't see somewhere to find the macrotab and
initialize the rest of the symtab?  Should it be "sal = cursal"?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


             reply	other threads:[~2003-11-03  4:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-03  4:07 Daniel Jacobowitz [this message]
2003-11-03  4:48 ` Jim Blandy
2003-11-03  4:56   ` Daniel Jacobowitz
2003-11-03 21:00     ` Jim Blandy
2003-11-03 21:04       ` Daniel Jacobowitz
2003-11-03 21:34         ` Jim Blandy
2003-11-03 21:37           ` Daniel Jacobowitz
2003-11-03 23:51             ` Jim Blandy
2003-11-07 16:29               ` Daniel Jacobowitz
2003-11-10 23:38                 ` Jim Blandy
2003-11-03 21:46           ` David Carlton
2003-11-03 22:01           ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031103040751.GA30979@nevyn.them.org \
    --to=drow@mvista.com \
    --cc=gdb@sources.redhat.com \
    --cc=jimb@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox