From: Pedro Alves <palves@redhat.com>
To: lgustavo@codesourcery.com
Cc: "'gdb-patches@sourceware.org'" <gdb-patches@sourceware.org>
Subject: Re: [PATCH, gdbsim] Avoid silly crash when no binary is loaded
Date: Wed, 19 Jun 2013 11:43:00 -0000 [thread overview]
Message-ID: <51C193AE.7010608@redhat.com> (raw)
In-Reply-To: <51C0C7E3.1030603@codesourcery.com>
On 06/18/2013 09:49 PM, Luis Machado wrote:
> Hi,
>
> This patch prevents the long-standing crash scenario where we start
> gdbsim and "run" without any binaries. Warnings are issued, but those
> don't prevent the simulator from proceeding with garbage data.
Which sim and backtrace? I suspect this to be sim/arch dependent.
>
> Replacing those warnings with error calls seems to be the most
> appropriate here.
Well, the code seems to have been written like that for a reason.
Real boards can be powered on with no real program in memory
too...
> if (exec_file == 0 || exec_bfd == 0)
> - warning (_("No executable file specified."));
> + error (_("No executable file specified."));
> if (!sim_data->program_loaded)
> - warning (_("No program loaded."));
> + error (_("No program loaded."));
>
There's code just below that does:
> if (remote_debug)
> printf_filtered ("gdbsim_create_inferior: exec_file \"%s\", args \"%s\"\n",
...
> if (exec_file != NULL)
> {
> len = strlen (exec_file) + 1 + strlen (args) + 1 + /*slop */ 10;
> arg_buf = (char *) alloca (len);
> arg_buf[0] = '\0';
> strcat (arg_buf, exec_file);
> strcat (arg_buf, " ");
> strcat (arg_buf, args);
> argv = gdb_buildargv (arg_buf);
> make_cleanup_freeargv (argv);
> }
> else
> argv = NULL;
So if we error out, then these NULL checks are now dead.
And e.g., the bfin sim, at sim/bfin/interp.c:sim_create_inferior
allows NULL exec_bfd:
SIM_RC
sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
char **argv, char **env)
{
SIM_CPU *cpu = STATE_CPU (sd, 0);
SIM_ADDR addr;
/* Set the PC. */
if (abfd != NULL)
addr = bfd_get_start_address (abfd);
else
addr = 0;
sim_pc_set (cpu, addr);
--
Pedro Alves
next prev parent reply other threads:[~2013-06-19 11:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 21:09 Luis Machado
2013-06-19 11:43 ` Pedro Alves [this message]
2013-06-19 12:20 ` Luis Machado
2013-06-19 14:53 ` Pedro Alves
2013-06-19 15:20 ` Luis Machado
2013-06-20 13:39 ` Luis Machado
2013-06-20 17:50 ` Mike Frysinger
2013-06-20 18:34 ` Pedro Alves
2013-06-20 21:33 ` Stan Shebs
2013-06-20 22:00 ` Mike Frysinger
2013-06-21 10:58 ` Pedro Alves
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=51C193AE.7010608@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=lgustavo@codesourcery.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