[llvm-commits] [llvm] r171989 - in /llvm/trunk: include/llvm/Support/Signals.h lib/Support/Unix/Signals.inc lib/Support/Windows/Signals.inc
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Jan 21 10:13:01 PST 2013
On Jan 21, 2013, at 3:41 AM, Alexander Potapenko <glider at google.com> wrote:
> BTW GCC complains about %t in Signals.inc:
>
> Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Signals.cpp.o
> cc1plus: warnings being treated as errors
> In file included from /Users/glider/src/asan/llvm/lib/Support/Signals.cpp:30:
> /Users/glider/src/asan/llvm/lib/Support/Unix/Signals.inc: In function
> 'void llvm::sys::PrintStackTrace(FILE*)':
> /Users/glider/src/asan/llvm/lib/Support/Unix/Signals.inc:298: warning:
> ISO C++ does not support the 't' printf length modifier
> /Users/glider/src/asan/llvm/lib/Support/Unix/Signals.inc:298: warning:
> ISO C++ does not support the 't' printf length modifier
>
> Will another length modifier work for you?
I didn't introduce it, so "it works for me"™
>
> On Wed, Jan 9, 2013 at 11:42 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
>> Author: akirtzidis
>> Date: Wed Jan 9 13:42:40 2013
>> New Revision: 171989
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=171989&view=rev
>> Log:
>> Move the internal PrintStackTrace function that is used for llvm::sys::PrintStackTraceOnErrorSignal(),
>> into a new function llvm::sys::PrintStackTrace, so that it's available to clients for logging purposes.
>>
>> Modified:
>> llvm/trunk/include/llvm/Support/Signals.h
>> llvm/trunk/lib/Support/Unix/Signals.inc
>> llvm/trunk/lib/Support/Windows/Signals.inc
>>
>> Modified: llvm/trunk/include/llvm/Support/Signals.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Signals.h?rev=171989&r1=171988&r2=171989&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Support/Signals.h (original)
>> +++ llvm/trunk/include/llvm/Support/Signals.h Wed Jan 9 13:42:40 2013
>> @@ -38,6 +38,9 @@
>> /// @brief Print a stack trace if a fatal signal occurs.
>> void PrintStackTraceOnErrorSignal();
>>
>> + /// \brief Print the stack trace using the given \c FILE object.
>> + void PrintStackTrace(FILE *);
>> +
>> /// AddSignalHandler - Add a function to be called when an abort/kill signal
>> /// is delivered to the process. The handler can have a cookie passed to it
>> /// to identify what instance of the handler it is.
>>
>> Modified: llvm/trunk/lib/Support/Unix/Signals.inc
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Signals.inc?rev=171989&r1=171988&r2=171989&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Support/Unix/Signals.inc (original)
>> +++ llvm/trunk/lib/Support/Unix/Signals.inc Wed Jan 9 13:42:40 2013
>> @@ -254,7 +254,7 @@
>> //
>> // On glibc systems we have the 'backtrace' function, which works nicely, but
>> // doesn't demangle symbols.
>> -static void PrintStackTrace(void *) {
>> +void llvm::sys::PrintStackTrace(FILE *FD) {
>> #if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
>> static void* StackTrace[256];
>> // Use backtrace() to output a backtrace on Linux systems with glibc.
>> @@ -278,26 +278,26 @@
>> Dl_info dlinfo;
>> dladdr(StackTrace[i], &dlinfo);
>>
>> - fprintf(stderr, "%-2d", i);
>> + fprintf(FD, "%-2d", i);
>>
>> const char* name = strrchr(dlinfo.dli_fname, '/');
>> - if (name == NULL) fprintf(stderr, " %-*s", width, dlinfo.dli_fname);
>> - else fprintf(stderr, " %-*s", width, name+1);
>> + if (name == NULL) fprintf(FD, " %-*s", width, dlinfo.dli_fname);
>> + else fprintf(FD, " %-*s", width, name+1);
>>
>> - fprintf(stderr, " %#0*lx",
>> + fprintf(FD, " %#0*lx",
>> (int)(sizeof(void*) * 2) + 2, (unsigned long)StackTrace[i]);
>>
>> if (dlinfo.dli_sname != NULL) {
>> int res;
>> - fputc(' ', stderr);
>> + fputc(' ', FD);
>> char* d = abi::__cxa_demangle(dlinfo.dli_sname, NULL, NULL, &res);
>> - if (d == NULL) fputs(dlinfo.dli_sname, stderr);
>> - else fputs(d, stderr);
>> + if (d == NULL) fputs(dlinfo.dli_sname, FD);
>> + else fputs(d, FD);
>> free(d);
>>
>> - fprintf(stderr, " + %tu",(char*)StackTrace[i]-(char*)dlinfo.dli_saddr);
>> + fprintf(FD, " + %tu",(char*)StackTrace[i]-(char*)dlinfo.dli_saddr);
>> }
>> - fputc('\n', stderr);
>> + fputc('\n', FD);
>> }
>> #else
>> backtrace_symbols_fd(StackTrace, depth, STDERR_FILENO);
>> @@ -305,10 +305,14 @@
>> #endif
>> }
>>
>> +static void PrintStackTraceSignalHandler(void *) {
>> + PrintStackTrace(stderr);
>> +}
>> +
>> /// PrintStackTraceOnErrorSignal - When an error signal (such as SIGABRT or
>> /// SIGSEGV) is delivered to the process, print a stack trace and then exit.
>> void llvm::sys::PrintStackTraceOnErrorSignal() {
>> - AddSignalHandler(PrintStackTrace, 0);
>> + AddSignalHandler(PrintStackTraceSignalHandler, 0);
>>
>> #if defined(__APPLE__)
>> // Environment variable to disable any kind of crash dialog.
>>
>> Modified: llvm/trunk/lib/Support/Windows/Signals.inc
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Signals.inc?rev=171989&r1=171988&r2=171989&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Support/Windows/Signals.inc (original)
>> +++ llvm/trunk/lib/Support/Windows/Signals.inc Wed Jan 9 13:42:40 2013
>> @@ -295,6 +295,10 @@
>> LeaveCriticalSection(&CriticalSection);
>> }
>>
>> +void llvm::sys::PrintStackTrace(FILE *) {
>> + // FIXME: Implement.
>> +}
>> +
>>
>> void sys::SetInterruptFunction(void (*IF)()) {
>> RegisterHandler();
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
> --
> Alexander Potapenko
> Software Engineer
> Google Moscow
More information about the llvm-commits
mailing list