<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 19, 2016 at 9:39 AM Sean Callanan <<a href="mailto:scallanan@apple.com">scallanan@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg">That would require making LLDB crash and collecting the relevant crash log data out of the user's own logs. This isn't impossible – but additionally the generation of that log is asynchronous and you don't quite know when it'll land.<div class="gmail_msg">Would you be all right with a more restricted macOS-only unit test where we check that __crashreporter_info__ contains what we think it does? That won't check end-to-end but at least it'll give us some confidence that things are sane.</div></div></blockquote><div><br>I was thinking something like a unit test of <span style="color:rgb(33,33,33);font-size:13px">PrettyStackTraceFormat - that wouldn't need to be OS specific, would it?</span><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Sean</div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Dec 19, 2016, at 9:01 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="gmail_msg" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br class="m_5239063784351480498Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg">Test coverage?<br class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Tue, Dec 13, 2016 at 2:39 PM Sean Callanan via Phabricator via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" class="gmail_msg" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" 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>
</div></blockquote></div><br class="gmail_msg"></div></div></blockquote></div></div>