Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] re-read symbols before "start"-ing...
@ 2005-03-08  6:45 Joel Brobecker
  2005-03-08 13:48 ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2005-03-08  6:45 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1994 bytes --]

Humpf,

I thought I checked that this scenario was working:

        - build first (Ada program, main program name is "first")
        - build second (Ada program, main program name is "second")
        - mv first common
        - gdb
          (gdb) file common
          (gdb) start
          --> lands in "first"
        - mv common first
        - mv second common
        - (gdb) start
          --> lands in "second"

I thought I checked that this was working because I added an
executable-changed notification just for that. In reality, it
doesn't work. When I tried a new testcase that I am currently
writing, here is what I actually get:

    (gdb) start^M
    Breakpoint 2 at 0x804980b: file /home/no-backup/brobecke/testing/gdb-public/gdb/testsuite/gdb.ada/exec_changed/first.adb, line 4.^M
    `/home/no-backup/brobecke/testing/gdb-public/gdb/testsuite/gdb.ada/exec_changed/common' has changed; re-reading symbols.^M
    Error in re-setting breakpoint 2:^M
    Function "_ada_first" not defined.^M
    Error in re-setting breakpoint 2:^M
    Function "_ada_first" not defined.^M
    Error in re-setting breakpoint 2:^M
    Function "_ada_first" not defined.^M
    Error in re-setting breakpoint 2:^M
    Function "_ada_first" not defined.^M
    ^M
    Program exited normally.^M
    (gdb) FAIL: gdb.ada/exec_changed.exp: start second

What happens here is that we insert the breakpoint *before* the
notification is received. So we end up using the cached value
for the main procedure name, which is out of date. The answer
is to make sure the symbols are re-read if the executable has
changed.

Bad point for me, sorry... Fortunatly, only Ada is affected for now.
Attached is a patch.

2005-03-07  Joel Brobecker  <brobecker@adacore.com>

        * infcmd.c (start_command): Make sure the symbols are up to date
        before setting the temporary breakpoint.

Tested on x86-linux.  This fixes the FAIL above. Otherwise, the results
are identical.

OK to commit?

Thanks,
-- 
Joel

[-- Attachment #2: start-reread.diff --]
[-- Type: text/plain, Size: 853 bytes --]

Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.134
diff -p -r1.134 infcmd.c
*** infcmd.c	21 Feb 2005 03:25:56 -0000	1.134
--- infcmd.c	8 Mar 2005 06:43:05 -0000
*************** start_command (char *args, int from_tty)
*** 512,517 ****
--- 512,523 ----
       the user changes its mind.  */
    kill_if_already_running (from_tty);
  
+   /* Make sure that the symbols are up to date.  Otherwise, we might
+      end up inserting the temporary breakpoint before we receive the
+      executable-changed notification, potentially causing us to use
+      the wrong function name as the main procedure.  */
+   reread_symbols ();
+ 
    /* Insert the temporary breakpoint, and run...  */
    tbreak_command (main_name (), 0);
    run_command (args, from_tty);

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-03-08 22:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-08  6:45 [RFA] re-read symbols before "start"-ing Joel Brobecker
2005-03-08 13:48 ` Daniel Jacobowitz
2005-03-08 21:28   ` Joel Brobecker
2005-03-08 21:45     ` Daniel Jacobowitz
2005-03-08 22:12       ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox