Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Zaric, Zoran (Zare)" <Zoran.Zaric@amd.com>
To: Tom Tromey <tom@tromey.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v2] Replace the symbol needs evaluator with a parser
Date: Thu, 12 Nov 2020 21:17:19 +0000	[thread overview]
Message-ID: <DM6PR12MB2762BBBBCC1D6B21522ABF99F8E70@DM6PR12MB2762.namprd12.prod.outlook.com> (raw)
In-Reply-To: <87eekycp3c.fsf@tromey.com>

[AMD Official Use Only - Internal Distribution Only]

> >>>>> "Zoran" == Zoran Zaric <Zoran.Zaric@amd.com> writes:
> 
> Zoran> The problem here is that faking results of target interactions
> Zoran> can yield an incorrect evaluation result.
> 
> ...
> 
> Zoran> This is clearly a wrong result and it causes the debugger to crash.
> 
> Zoran> +      /* The DWARF expression might have a bug causing an infinite
> Zoran> +         loop.  In that case, quitting is the only way out.  */
> Zoran> +      QUIT;
> 
> Can this really occur in this scanner?
> 
> For evaluation I can understand it, but this scanner seems to just walk the
> bytecode once, so I don't see how it is possible.

It is not. 

The test is exposing a bug in the previous evaluator based approach. My point was to prevent people going back to that approach.

> 
> For gimli (again) we have a maximum operation count to avoid this kind of
> problem.  gdb could do this as well.
> 
> Meanwhile, about the linear scan -- it seems to me that nothing in DWARF
> requires (1) that the expression not contain embedded garbage, and (2) that
> it not be possible to branch to the middle of some other instruction.  (If
> there is text along these lines, I'd like to hear about it; I looked in the past
> and couldn't find it.)

I am not sure about your point about  expressions not contain embedded garbage. The DWARF expression is a byte stream with clearly defined content for every operation.

Regarding jumping in the middle of another operation, this is true, DWARF doesn't prevent that or define what is supposed to be done.

And I agree it would be really useful to have a checking mechanism that converts that byte stream into an internal representation, where during that conversion we could check and report all kind of things that can be wrong with the expression.

> This is pathological, of course.  But on the other hand, if the motivation is to
> avoid crashes, it seems bad to, say, let this function pass through some
> bytecode that would then be interpreted a different way by the actual
> evaluator.
> 
> Personally I'd be fine with rejecting this bad stuff from the evaluator as well.
> But anyway the difficulty is that they have to be in sync, and aren't.
> 
> Another approach would be to record which offsets are branched to; and to
> pop from such a list when an unconditional branch is encountered.
> This would solve both problems as well.

I agree with all your points and to be honest I am not advocating for symbol needs mechanism (new or old) at all, and nothing would make me happier then to get rid of it.

My next patch series is supposed to redesign the DWARF evaluator mechanism in a way that it can be used in places where the symbol needs is currently used. The downside of that approach is that the scanner is still going to be considerable faster, but maybe we don't really care about that.

If at that time we feel that it is better to use the new evaluator instead of the new symbol need scanner, I would be happy to do the switch.

Zoran

  reply	other threads:[~2020-11-12 21:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07 17:26 Zoran Zaric
2020-10-21 20:35 ` Tom Tromey
2020-10-22 14:58   ` Zaric, Zoran (Zare)
2020-10-27 19:51     ` Pedro Alves
2020-11-12 20:03     ` Tom Tromey
2020-11-12 20:11 ` Tom Tromey
2020-11-12 21:17   ` Zaric, Zoran (Zare) [this message]
2020-11-12 21:29     ` Zaric, Zoran (Zare)
2020-11-30 18:18       ` Zaric, Zoran (Zare) via Gdb-patches

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=DM6PR12MB2762BBBBCC1D6B21522ABF99F8E70@DM6PR12MB2762.namprd12.prod.outlook.com \
    --to=zoran.zaric@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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