<div dir="ltr">Test coverage?<br><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 13, 2016 at 2:39 PM Sean Callanan via Phabricator via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">spyffe retitled this revision from "Fix the linkage for __crashtracer_info__" to "Prepare PrettyStackTrace for LLDB adoption".<br class="gmail_msg">
spyffe updated the summary for this revision.<br class="gmail_msg">
spyffe updated this revision to Diff 81304.<br class="gmail_msg">
<br class="gmail_msg">
Repository:<br class="gmail_msg">
rL LLVM<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D27683" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D27683</a><br class="gmail_msg">
<br class="gmail_msg">
Files:<br class="gmail_msg">
include/llvm/Support/PrettyStackTrace.h<br class="gmail_msg">
lib/Support/PrettyStackTrace.cpp<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Index: lib/Support/PrettyStackTrace.cpp<br class="gmail_msg">
===================================================================<br class="gmail_msg">
--- lib/Support/PrettyStackTrace.cpp<br class="gmail_msg">
+++ lib/Support/PrettyStackTrace.cpp<br class="gmail_msg">
@@ -89,7 +89,7 @@<br class="gmail_msg">
= { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };<br class="gmail_msg">
}<br class="gmail_msg">
#elif defined (__APPLE__) && HAVE_CRASHREPORTER_INFO<br class="gmail_msg">
-static const char *__crashreporter_info__ = 0;<br class="gmail_msg">
+extern "C" const char *__crashreporter_info__ __attribute__((visibility("hidden"))) = 0;<br class="gmail_msg">
asm(".desc ___crashreporter_info__, 0x10");<br class="gmail_msg">
#endif<br class="gmail_msg">
<br class="gmail_msg">
@@ -145,6 +145,28 @@<br class="gmail_msg">
OS << Str << "\n";<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
+PrettyStackTraceFormat::PrettyStackTraceFormat(const char *format, ...) {<br class="gmail_msg">
+ va_list ap;<br class="gmail_msg">
+<br class="gmail_msg">
+ va_start(ap, format);<br class="gmail_msg">
+ const int size_or_error = vsnprintf(nullptr, 0, format, ap);<br class="gmail_msg">
+ va_end(ap);<br class="gmail_msg">
+<br class="gmail_msg">
+ if (size_or_error < 0) {<br class="gmail_msg">
+ return;<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
+ const int size = size_or_error + 1; // '\0'<br class="gmail_msg">
+<br class="gmail_msg">
+ Str.resize(size);<br class="gmail_msg">
+<br class="gmail_msg">
+ va_start(ap, format);<br class="gmail_msg">
+ vsnprintf(Str.data(), size, format, ap);<br class="gmail_msg">
+ va_end(ap);<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
+void PrettyStackTraceFormat::print(raw_ostream &OS) const { OS << Str << "\n"; }<br class="gmail_msg">
+<br class="gmail_msg">
void PrettyStackTraceProgram::print(raw_ostream &OS) const {<br class="gmail_msg">
OS << "Program arguments: ";<br class="gmail_msg">
// Print the argument list.<br class="gmail_msg">
Index: include/llvm/Support/PrettyStackTrace.h<br class="gmail_msg">
===================================================================<br class="gmail_msg">
--- include/llvm/Support/PrettyStackTrace.h<br class="gmail_msg">
+++ include/llvm/Support/PrettyStackTrace.h<br class="gmail_msg">
@@ -16,6 +16,7 @@<br class="gmail_msg">
#ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H<br class="gmail_msg">
#define LLVM_SUPPORT_PRETTYSTACKTRACE_H<br class="gmail_msg">
<br class="gmail_msg">
+#include "llvm/ADT/SmallVector.h"<br class="gmail_msg">
#include "llvm/Support/Compiler.h"<br class="gmail_msg">
<br class="gmail_msg">
namespace llvm {<br class="gmail_msg">
@@ -55,6 +56,16 @@<br class="gmail_msg">
void print(raw_ostream &OS) const override;<br class="gmail_msg">
};<br class="gmail_msg">
<br class="gmail_msg">
+ /// PrettyStackTraceFormat - This object prints a string (which may use<br class="gmail_msg">
+ /// printf-style formatting but should not contain newlines) to the stream<br class="gmail_msg">
+ /// as the stack trace when a crash occurs.<br class="gmail_msg">
+ class PrettyStackTraceFormat : public PrettyStackTraceEntry {<br class="gmail_msg">
+ llvm::SmallVector<char, 32> Str;<br class="gmail_msg">
+ public:<br class="gmail_msg">
+ PrettyStackTraceFormat(const char *format, ...);<br class="gmail_msg">
+ void print(raw_ostream &OS) const override;<br class="gmail_msg">
+ };<br class="gmail_msg">
+<br class="gmail_msg">
/// PrettyStackTraceProgram - This object prints a specified program arguments<br class="gmail_msg">
/// to the stream as the stack trace when a crash occurs.<br class="gmail_msg">
class PrettyStackTraceProgram : public PrettyStackTraceEntry {<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
cfe-commits mailing list<br class="gmail_msg">
<a href="mailto:cfe-commits@lists.llvm.org" class="gmail_msg" target="_blank">cfe-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class="gmail_msg">
</blockquote></div></div>