<div dir="ltr"><div>Thanks for the comments. I should have done a bit more experimenting before writing up this RFC, it seems :) After sending it off, I played around with the existing code, tor refresh my memory of what I did a while back in adding the Recoverable/Unrecoverable Error callbacks. These are written with the intent that the client could decide how to handle errors, as Jonas points out, making the additional strictness level a little unnecessary. Unrecoverable errors stop the parsing, whereas recoverable allow it to continue as best it can. I think the current parser is stricter than it needs to be to provide useful information, so I'm going to put a patch up soon to loosen it up a bit before I start adding more checks.<br></div><div><br></div><div>The Errors reported by the parser only contain strings, which means that it's difficult for a client to use them in some other way, for example to identify issues that it might need to know/completely ignore etc. Short of adding extra data to the Error, such as an enum, it's unclear to me how to improve that situation. Of course, if we did add the extra data, it would allow LLDB and other clients to decide what errors to ignore/pay attention to on a finer grained basis, which partially achieves the lazy creation goal (only report the problems that apply to the things the client cares about), but doesn't improve responsiveness since the whole program will still be parsed.<br></div><div><br></div><div>Lazy creation of errors is tricky, at least for some cases, given the current code state. The problem is that the parser reads the name table, calculates the rows etc as it parses a program, and that's the only way of getting this data through the current interface. The only laziness available as things stand is to skip line tables that we don't want (e.g. to find the line table at a given offset). This ignores the body of the skipped programs. The alternative is to refactor the parser completely into much smaller pieces, which provide access to the desired bits individually, and delays reading until that point. I can definitely see benefits in this approach, and I think it would solve the needs of things at both ends of the scale (verifiers and dumpers) but it's a lot more work, which I'm not convinced I personally can take on, although I'd be happy to review it if others fancy attempting that option.<br></div><div><br></div><div>James<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 17 Dec 2019 at 08:36, Pavel Labath via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 16/12/2019 23:47, David Blaikie via llvm-dev wrote:<br>
> <br>
> <br>
> On Mon, Dec 16, 2019 at 2:40 PM Jonas Devlieghere <<a href="mailto:jonas@devlieghere.com" target="_blank">jonas@devlieghere.com</a><br>
> <mailto:<a href="mailto:jonas@devlieghere.com" target="_blank">jonas@devlieghere.com</a>>> wrote:<br>
> <br>
> Hey James,<br>
> <br>
> This sounds really interesting. A few things that come to mind:<br>
> <br>
> - I'm curious what kind of errors you'd be okay with in dump mode but<br>
> not in consumer mode. From LLDB's perspective, we probably want to<br>
> extract as much information as possible from a malformed line table,<br>
> as long as we don't end up lying of course.<br>
> - I need to take another look at the code, but don't we already have<br>
> something similar where the consumer can decide how to deal with these<br>
> kinds of issues? I'm bringing this up because I don't think we really<br>
> need different parsing modes. I think we need to let the consumer<br>
> decide what to do with the potential errors. The verifier in dwarfdump<br>
> would presumably stop after the first error (~strict mode) while the<br>
> dumper would just move on. Would the parsing modes then be a set of<br>
> "presets" with regards to how to handle these issues?<br>
> - I'm in favor of creating these error messages lazily, especially<br>
> for LLDB where we care about responsiveness. However, that does<br>
> conflict with the behavior you want for the DWARF verifier. We<br>
> probably want a way to control this?<br>
> <br>
> <br>
> For my part - I'd imagine the verifier would be an aggressive reader of<br>
> DWARF - it'd use the same lazy/high quality error API, but the verifier<br>
> code itself would try to walk all of the parts of the DWARF to manifest<br>
> any lazy error cases, rather than needing any other codepath in the parser.<br>
<br>
That would be my ideal setup as well (disclaimer: I work on lldb) --<br>
have the parser provide sufficient information so that the verification<br>
can be done from the "outside".<br>
<br>
That is, if the goal is to have stronger verification of generated line<br>
tables -- it's not fully clear (to me) whether that's your main<br>
motivation for adding these checks.<br>
<br>
regards,<br>
pavel<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>