public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "tromey at sourceware dot org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug ada/25811] [ada] start attempts to set breakpoint on main of previous exec
Date: Wed, 19 Apr 2023 18:40:07 +0000	[thread overview]
Message-ID: <bug-25811-4717-ZJcJbdrOkp@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-25811-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=25811

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
The bug here is that ada_main_name reads memory to find
the name:

      main_program_name = target_read_string (main_program_name_addr, 1024);

The symbol is correctly found in the new executable:

(top-gdb) p msym.objfile.original_name
$19 = 0x3424020
"/home/tromey/gdb/build/gdb/testsuite/outputs/gdb.ada/exec_changed/./common"

... but the memory comes from the running inferior.

If I "kill" the inferior first, it works:

(gdb) kill
Kill the program being debugged? (y or n) y
[Inferior 1 (process 2209503) killed]
(gdb) file ./common 
Load new symbol table from "./common"? (y or n) y
Reading symbols from ./common...
(gdb) info main
_ada_second


I'm not really sure what we want to do about this case.

Another way to make it work is "set trust-readonly-sections on".
Perhaps ada_main_name could do this temporarily.  I can't tell
if I think that would be a hack or not.  Actually... instead of
modifying the flag, it might be better to just dig through
the BFD section data by hand.  (Not sure.)

A better solution would be to modify the compiler to emit
DW_AT_main_subprogram, but I am not sure how hard that would be.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  reply	other threads:[~2023-04-19 18:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10 16:33 [Bug ada/25811] New: " vries at gcc dot gnu.org
2023-04-19 18:40 ` tromey at sourceware dot org [this message]
2023-08-21 15:41 ` [Bug ada/25811] " tromey at sourceware dot org
2023-08-23 17:12 ` tromey at sourceware dot org
2023-09-05 16:05 ` cvs-commit at gcc dot gnu.org
2023-09-05 16:06 ` tromey at sourceware dot org

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=bug-25811-4717-ZJcJbdrOkp@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).