[llvm-dev] LLVM libraries and custom assertions.

Paul Hancock via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 15 17:03:23 PDT 2016


Catching SIGABRT seems reasonable for a graceful crash, but I'm also already making use of LLVM's internal fatal_error_handler. However said handler is only called for very specific things, the rest all use direct calls to assert, do I need to disable the LLVM_ENABLE_ASSERTIONS flag to change this?

I also just noticed however that there's an exception handler flag too, which I didn't notice before as it's called "LLVM_ENABLE_EH". Will be rebuilding now with that enabled and will see if it works how I want it to, but I have to question the sensibility of naming the flag like that when there's already flags with much longer names...?


- Paul

________________________________
From: Sanjoy Das <sanjoy at playingwithpointers.com>
Sent: 16 August 2016 09:27
To: Paul Hancock
Cc: llvm-dev at lists.llvm.org
Subject: Re: [llvm-dev] LLVM libraries and custom assertions.

You can consider catching SIGABRT, or maybe LD_PRELOAD'ing an
implementation for abort (not sure if the latter is possible, but
should be easy to try out).  I don't know how to do better than that
without recompiling LLVM.

Another option is to let LLVM's client register an "error handler"
that gets called instead of abort() on a failed assert, but you'll
have to change and rebuild LLVM to do this (and have a non-standard
assert definition).  This can be a little cleaner, depending on what
you're trying to do.  I don't have a good sense of what others think
of this, but I'll be for upstreaming a mechanism of this sort to LLVM.

-- Sanjoy

On Mon, Aug 15, 2016 at 4:19 PM, Paul Hancock via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Is there a simple method for compiling a custom assertion header/call into
> all the LLVM libraries? I want my application to be able to handle any
> thrown assertions (ie; as an exception) and recover or crash gracefully. I
> already have a custom header in place in the application's source, however
> this doesn't have an effect on [most of] the already compiled lib's.
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
llvm-dev Info Page<http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
lists.llvm.org
To see the collection of prior postings to the list, visit the llvm-dev Archives. Using llvm-dev: To post a message to all the list members, send ...


>



--
Sanjoy Das
http://playingwithpointers.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160816/9d76ba7e/attachment.html>


More information about the llvm-dev mailing list