[PATCH] D27683: Prepare PrettyStackTrace for LLDB adoption

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 19 20:44:16 PST 2016


On Mon, Dec 19, 2016 at 9:39 AM Sean Callanan <scallanan at apple.com> wrote:

> 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.
> 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.
>

I was thinking something like a unit test of PrettyStackTraceFormat - that
wouldn't need to be OS specific, would it?


>
> Sean
>
> On Dec 19, 2016, at 9:01 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
> Test coverage?
>
> On Tue, Dec 13, 2016 at 2:39 PM Sean Callanan via Phabricator via
> cfe-commits <cfe-commits at lists.llvm.org> wrote:
>
> spyffe retitled this revision from "Fix the linkage for
> __crashtracer_info__" to "Prepare PrettyStackTrace for LLDB adoption".
> spyffe updated the summary for this revision.
> spyffe updated this revision to Diff 81304.
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D27683
>
> Files:
>   include/llvm/Support/PrettyStackTrace.h
>   lib/Support/PrettyStackTrace.cpp
>
>
> Index: lib/Support/PrettyStackTrace.cpp
> ===================================================================
> --- lib/Support/PrettyStackTrace.cpp
> +++ lib/Support/PrettyStackTrace.cpp
> @@ -89,7 +89,7 @@
>          = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
>  }
>  #elif defined (__APPLE__) && HAVE_CRASHREPORTER_INFO
> -static const char *__crashreporter_info__ = 0;
> +extern "C" const char *__crashreporter_info__
> __attribute__((visibility("hidden"))) = 0;
>  asm(".desc ___crashreporter_info__, 0x10");
>  #endif
>
> @@ -145,6 +145,28 @@
>    OS << Str << "\n";
>  }
>
> +PrettyStackTraceFormat::PrettyStackTraceFormat(const char *format, ...) {
> +  va_list ap;
> +
> +  va_start(ap, format);
> +  const int size_or_error = vsnprintf(nullptr, 0, format, ap);
> +  va_end(ap);
> +
> +  if (size_or_error < 0) {
> +    return;
> +  }
> +
> +  const int size = size_or_error + 1; // '\0'
> +
> +  Str.resize(size);
> +
> +  va_start(ap, format);
> +  vsnprintf(Str.data(), size, format, ap);
> +  va_end(ap);
> +}
> +
> +void PrettyStackTraceFormat::print(raw_ostream &OS) const { OS << Str <<
> "\n"; }
> +
>  void PrettyStackTraceProgram::print(raw_ostream &OS) const {
>    OS << "Program arguments: ";
>    // Print the argument list.
> Index: include/llvm/Support/PrettyStackTrace.h
> ===================================================================
> --- include/llvm/Support/PrettyStackTrace.h
> +++ include/llvm/Support/PrettyStackTrace.h
> @@ -16,6 +16,7 @@
>  #ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H
>  #define LLVM_SUPPORT_PRETTYSTACKTRACE_H
>
> +#include "llvm/ADT/SmallVector.h"
>  #include "llvm/Support/Compiler.h"
>
>  namespace llvm {
> @@ -55,6 +56,16 @@
>      void print(raw_ostream &OS) const override;
>    };
>
> +  /// PrettyStackTraceFormat - This object prints a string (which may use
> +  /// printf-style formatting but should not contain newlines) to the
> stream
> +  /// as the stack trace when a crash occurs.
> +  class PrettyStackTraceFormat : public PrettyStackTraceEntry {
> +    llvm::SmallVector<char, 32> Str;
> +  public:
> +    PrettyStackTraceFormat(const char *format, ...);
> +    void print(raw_ostream &OS) const override;
> +  };
> +
>    /// PrettyStackTraceProgram - This object prints a specified program
> arguments
>    /// to the stream as the stack trace when a crash occurs.
>    class PrettyStackTraceProgram : public PrettyStackTraceEntry {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161220/62d15c37/attachment.html>


More information about the cfe-commits mailing list