[llvm-commits] Error-handling fixes for the x86 disassembler

Sean Callanan scallanan at apple.com
Thu Apr 1 18:48:17 PDT 2010


We talked about this a little off-list, and decided to have the disassembler return an error code in all cases, but only print a debug message on NDEBUG builds.  The idea was to use the DEBUG macro and debugs() stream.

The attached patch implements these updates.  Please let me know what you think.

Sean



On Mar 31, 2010, at 8:50 PM, Chris Lattner wrote:

> On Mar 31, 2010, at 6:13 PM, Sean Callanan wrote:
>>> However, I don't see how error messages from the disassembler are going to be very useful.  Errors like:
>>> 
>>> Corrupt table!  Unknown modrm_type
>>> Cannot have Mod = 0b11 and a SIB byte
>>> Expected a REG or R/M encoding in fixupReg
>>> No modifier but an operand expects one.
>>> 
>>> Are not going to mean anything to anyone.  I don't think there is such thing as a useful error message that can come out of a disassembler other than "unrecognized instruction".  Given this, I don't see the value in an error reporting api at all here.
>> 
>> I'll just have error() call fprintf(stderr) unless NDEBUG is defined.  New patch attached.
> 
> As daniel mentioned, nothing in lib can use printf.
> 
> Why not have this abort if assertions are enabled?  Causing a printout to happen (presumably as a debugging aid) does not make any sense if linked into a random app that uses the disassembler.
> 
> -Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100401/b666ff36/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x86-disassembler-assert.r4.diff
Type: application/octet-stream
Size: 28061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100401/b666ff36/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100401/b666ff36/attachment-0001.html>


More information about the llvm-commits mailing list