Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Keith Seitz <keiths@redhat.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Validate explicit locations with early termination
Date: Thu, 07 Dec 2017 21:34:00 -0000	[thread overview]
Message-ID: <003824fa-c538-3f02-729f-8bf8192d51a5@ericsson.com> (raw)
In-Reply-To: <20171207212046.13452-1-keiths@redhat.com>

On 2017-12-07 04:20 PM, Keith Seitz wrote:
> breakpoints/22569 involves an internal error generated by the rather
> innocent looking command:
> 
> (gdb) break -source test.cpp main
> .../linespec.c:3302: internal-error: void decode_line_full(...):
> Assertion `result.size () == 1 || canonical->pre_expanded' failed.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n)
> 
> The input string is tokenized into "-source", "test.cpp", and "main"
> (input parsing breaks on whitespace). create_breakpoint is then called with
> the explicit location (containing only the source file name) and "main" as
> the extra_string argument.
> 
> No SaLs are created for this underspecified explicit location, and the
> "result.size () == 1" evaluates false (as does the pre_expanded condition).
> This triggers the assertion.
> 
> Normally string_to_explicit_location validates the input string.  However,
> the presence of the string "main" causes the parser to exit early:
> 
>    802        else
>    803          {
>    804            /* End of the explicit location specification.
>    805               Stop parsing and return whatever explicit location was
>    806               parsed.  */
>    807            *argp = start;
>    808            return location;
>    809          }
> 
> This bypasses the validation that is done a few lines down in this function
> which would have emitted the expected error.  This patch fixes that.
> 
> Additionally, this patch also fixes an inconsistency with error reporting
> in this use case:
> 
> (gdb) b -source foo
> Source filename requires function, label, or line offset.
> (gdb) b -source foo main
> No source file named foo.
> 
> These two commands should have elicited the same error message.
> 
> gdb/ChangeLog:
> 
> 	PR breakpoints/22569
> 	* location.c (string_to_explicit_location): When terminating
> 	parsing early, break out of enclosing loop instead of returning.
> 
> gdb/testsuite/ChangeLog:
> 
> 	PR breakpoints/22569
> 	* gdb.linespec/ls-errs.exp: Change expected result of "break
> 	-source this file has spaces.c -line 3".
> 	Check that an explicit source file followed by whitespace is
> 	identified as an invalid explicit location.

This is quick customer support!  This patch fixes the reported issue
and LGTM.

Thanks!

Simon


  reply	other threads:[~2017-12-07 21:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 21:20 Keith Seitz
2017-12-07 21:34 ` Simon Marchi [this message]
2017-12-07 23:41   ` Keith Seitz

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=003824fa-c538-3f02-729f-8bf8192d51a5@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@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