Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Aleksandar Ristovski <aristovski@qnx.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [patch] validate binary before use
Date: Wed, 03 Apr 2013 18:52:00 -0000	[thread overview]
Message-ID: <20130403180917.GA6102@host2.jankratochvil.net> (raw)
In-Reply-To: <515B12D1.7050505@qnx.com>

On Tue, 02 Apr 2013 19:18:09 +0200, Aleksandar Ristovski wrote:
> [AR]
> Ok, it's been a while since I looked at gdb.exp closely, and
> 'no-message' was added since. Changed the test as so:
> 
> @@ -93,15 +93,7 @@ proc solib_matching_test { solibfile symsloaded msg } {
> 
>    set bp_location [gdb_get_line_number "set breakpoint 1 here"]
> 
> -  send_gdb "tbreak ${srcfile}:${bp_location}\n"
> -  gdb_expect {
> -    -re "Temporary breakpoint.*${gdb_prompt} $" {
> -    }
> -    default {
> -      untested "${msg} - Failed to set temp. breakpoint at ${bp_location}"
> -      return -1
> -    }
> -  }
> +  gdb_breakpoint ${srcfile}:${bp_location} temporary no-message

"no-message" should not be used there, there should be just:
    gdb_breakpoint ${srcfile}:${bp_location} temporary

Copy-pasting here the comment of gdb_break from lib/gdb.exp:

# Note: The handling of message vs no-message is messed up, but it's based
# on historical usage.  By default this function does not print passes,
# only fails.
# no-message: turns off printing of fails (and passes, but they're already off)
# message: turns on printing of passes (and fails, but they're already on)

I have even verified now the behavior really fully corresponds to this comment.

You do not want to suppress FAIL if ${srcfile}:${bp_location} is not found.


> >Again, successful runto_main does not produce any PASS message.
> 
> 
> [AR]
> It does produce PASS (see gdb.exp, lines 476-488),

It does not, runto has the same parameters and behavior as gdb_breakpoint.

On those lines is:
            if { $print_pass } {
                pass $test_name
            }
 
But $print_pass is true only if "message" parameter was specified, "message"
parameter should not be specified.


> but this comment is not relevant as test does not use 'run' any more, it
> uses gdb_run_cmd; it does not need to stop at main, just run to the line it
> wants.

There is now:

+  gdb_run_cmd { ${binlibfiledirrun} }
+  gdb_expect {
+    -re "set breakpoint 1 here.*${gdb_prompt} $" {
+    }
+    default {
+      untested "${msg} - Failed to hit breakpoint at ${bp_location}"
+      return -1
+    }
+  }

Never use gdb_expect, there is gdb_test_multiple for such cases which
automatically handles various errors, that "default" case is not needed there.

But here even gdb_test_multiple is not needed, use just:

gdb_run_cmd { ${binlibfiledirrun} }
gdb_test "" "set breakpoint 1 here.*" ""

First empty parameter of gdb_test does not send anything, even no newline.


> >But when you expect only one shared library make the expectation explicit,
> >both for a single line and for ${binlibfilebase}.
> >
> >   gdb_test "info sharedlibrary ${solibfile}" \
> >     "From\[^\r\n\]*To\[^\r\n\]*Syms\[^\r\n\]*Read\[^\r\n\]*Shared\[^\r\n\]*\r\n\[^\r\n\]*${symsloaded}\[^\r\n\]*[string_to_regexp ${binlibfilebase}]" \
> >   (I did not test this regex.)
> >
> >I can very well imagine GDB could print >= 2 lines or a line without
> >${binlibfilebase} there which could make false PASS.
> 
> [AR] How can it print >= 2 lines?

For example when "set auto-solib-add off" starts to behave differently and for
example vDSO get still displayed (if they get displayed) etc.


> I will augument regex to explicitly look for ${solibfile}

This will not work as if there are >= 2 lines ${symsloaded} may match on one
line and ${solibfile} may match on a different line.


> 
> @@ -124,7 +124,7 @@ proc solib_matching_test { solibfile symsloaded msg } {
>    }
> 
>    gdb_test "info sharedlibrary ${solibfile}" \
> -    "From.*To.*Syms.*Read.*Shared.*\r\n.*${symsloaded}.*" \
> +    "From.*To.*Syms.*Read.*Shared.*\r\n.*${symsloaded}.*${solibfile}.*" \
>      "${msg} - Symbols for ${solibfile} loaded: expected '${symsloaded}'"
>    return 0
>  }


Thanks,
Jan


  reply	other threads:[~2013-04-03 18:09 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21 20:21 Aleksandar Ristovski
2012-12-24 19:57 ` Aleksandar Ristovski
2012-12-25  7:37   ` Jan Kratochvil
2012-12-27 20:07     ` Aleksandar Ristovski
2012-12-27 20:59       ` Jan Kratochvil
2012-12-27 21:03         ` Aleksandar Ristovski
2012-12-27 21:13           ` Jan Kratochvil
2012-12-27 21:21             ` Aleksandar Ristovski
2013-01-29 16:15               ` Aleksandar Ristovski
2013-01-30 19:17                 ` Jan Kratochvil
2013-01-31 14:23                   ` Aleksandar Ristovski
2013-02-01  3:06                     ` Jan Kratochvil
2013-02-01 14:31                       ` Aleksandar Ristovski
2013-02-01 20:43                         ` Jan Kratochvil
2013-02-01 21:32                           ` Aleksandar Ristovski
2013-02-02 12:25                             ` Jan Kratochvil
2013-02-21 21:00                               ` Aleksandar Ristovski
2013-02-21 21:07                                 ` Jan Kratochvil
2013-01-31  6:35                 ` Jan Kratochvil
2013-01-31 14:24                   ` Aleksandar Ristovski
2013-02-22 15:09                     ` Aleksandar Ristovski
2013-02-27 17:42                       ` Aleksandar Ristovski
2013-02-27 18:14                         ` Aleksandar Ristovski
2013-03-22 16:58                         ` Aleksandar Ristovski
2013-03-22 14:45                           ` Aleksandar Ristovski
2013-03-28 20:56                           ` Jan Kratochvil
2013-04-02 17:25                             ` Aleksandar Ristovski
2013-04-02 17:32                               ` Aleksandar Ristovski
2013-04-02 17:45                               ` Jan Kratochvil
2013-04-02 18:02                                 ` Aleksandar Ristovski
2013-04-03 18:52                                   ` Jan Kratochvil [this message]
2013-04-04 11:07                                     ` Aleksandar Ristovski
2013-04-04 13:30                                       ` Jan Kratochvil
2013-04-04 17:15                                         ` Aleksandar Ristovski
2013-04-04 18:11                                           ` Aleksandar Ristovski
2013-04-05 13:03                                           ` Jan Kratochvil
2013-04-05 16:08                                             ` Aleksandar Ristovski
2013-04-07  6:06                                               ` Jan Kratochvil
2013-04-08 18:54                                             ` Pedro Alves
2013-04-09  1:15                                               ` Jan Kratochvil
2013-04-05 15:05                                           ` Aleksandar Ristovski
2013-04-07 10:24                                             ` Aleksandar Ristovski
2013-04-08 18:32                                             ` Jan Kratochvil
2013-04-07  5:54                                           ` Jan Kratochvil
2013-04-04  3:16                               ` Jan Kratochvil
2012-12-26 19:24 ` Poenitz Andre
2012-12-27 20:10   ` Aleksandar Ristovski

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=20130403180917.GA6102@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=aristovski@qnx.com \
    --cc=gdb-patches@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