summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Host/Host.h3
-rw-r--r--lldb/source/Core/Log.cpp11
-rw-r--r--lldb/source/Core/Module.cpp10
-rw-r--r--lldb/source/Host/common/Host.cpp6
-rw-r--r--lldb/source/Host/freebsd/Host.cpp29
-rw-r--r--lldb/source/Host/linux/Host.cpp22
-rw-r--r--lldb/source/Host/macosx/Host.mm19
-rw-r--r--lldb/source/Symbol/ClangASTType.cpp14
-rw-r--r--lldb/source/Utility/LLDBAssert.cpp22
9 files changed, 38 insertions, 98 deletions
diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 6a0a60cd128..9ce83e28488 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -281,9 +281,6 @@ public:
static bool
OpenFileInExternalEditor (const FileSpec &file_spec,
uint32_t line_no);
-
- static void
- Backtrace (Stream &strm, uint32_t max_frames);
static size_t
GetEnvironment (StringList &env);
diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp
index fe4cfb366c8..2ac538470a6 100644
--- a/lldb/source/Core/Log.cpp
+++ b/lldb/source/Core/Log.cpp
@@ -29,6 +29,8 @@
#include "lldb/Interpreter/Args.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Signals.h"
using namespace lldb;
using namespace lldb_private;
@@ -122,8 +124,13 @@ Log::PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args)
header.PrintfVarArg (format, args);
stream_sp->Printf("%s\n", header.GetData());
- if (m_options.Test (LLDB_LOG_OPTION_BACKTRACE))
- Host::Backtrace (*stream_sp, 1024);
+ if (m_options.Test(LLDB_LOG_OPTION_BACKTRACE))
+ {
+ std::string back_trace;
+ llvm::raw_string_ostream stream(back_trace);
+ llvm::sys::PrintStackTrace(stream);
+ stream_sp->PutCString(back_trace.c_str());
+ }
stream_sp->Flush();
}
}
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 2a1663be5cc..d394118cba7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -40,6 +40,9 @@
#include "Plugins/ObjectFile/JIT/ObjectFileJIT.h"
+#include "llvm/Support/raw_os_ostream.h"
+#include "llvm/Support/Signals.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -1234,7 +1237,12 @@ Module::LogMessageVerboseBacktrace (Log *log, const char *format, ...)
log_message.PrintfVarArg (format, args);
va_end (args);
if (log->GetVerbose())
- Host::Backtrace (log_message, 1024);
+ {
+ std::string back_trace;
+ llvm::raw_string_ostream stream(back_trace);
+ llvm::sys::PrintStackTrace(stream);
+ log_message.PutCString(back_trace.c_str());
+ }
log->PutCString(log_message.GetString().c_str());
}
}
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index f7c1ac66b76..6b237ce06e2 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -397,12 +397,6 @@ Host::WillTerminate ()
#if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) && !defined (__linux__) // see macosx/Host.mm
-void
-Host::Backtrace (Stream &strm, uint32_t max_frames)
-{
- // TODO: Is there a way to backtrace the current process on other systems?
-}
-
size_t
Host::GetEnvironment (StringList &env)
{
diff --git a/lldb/source/Host/freebsd/Host.cpp b/lldb/source/Host/freebsd/Host.cpp
index e2bc1dc6232..62cf29365b0 100644
--- a/lldb/source/Host/freebsd/Host.cpp
+++ b/lldb/source/Host/freebsd/Host.cpp
@@ -50,35 +50,6 @@ extern "C" {
using namespace lldb;
using namespace lldb_private;
-void
-Host::Backtrace (Stream &strm, uint32_t max_frames)
-{
- char backtrace_path[] = "/tmp/lldb-backtrace-tmp-XXXXXX";
- int backtrace_fd = ::mkstemp (backtrace_path);
- if (backtrace_fd != -1)
- {
- std::vector<void *> frame_buffer (max_frames, NULL);
- int count = ::backtrace (&frame_buffer[0], frame_buffer.size());
- ::backtrace_symbols_fd (&frame_buffer[0], count, backtrace_fd);
-
- const off_t buffer_size = ::lseek(backtrace_fd, 0, SEEK_CUR);
-
- if (::lseek(backtrace_fd, 0, SEEK_SET) == 0)
- {
- char *buffer = (char *)::malloc (buffer_size);
- if (buffer)
- {
- ssize_t bytes_read = ::read (backtrace_fd, buffer, buffer_size);
- if (bytes_read > 0)
- strm.Write(buffer, bytes_read);
- ::free (buffer);
- }
- }
- ::close (backtrace_fd);
- ::unlink (backtrace_path);
- }
-}
-
size_t
Host::GetEnvironment (StringList &env)
{
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp
index edad8f7731e..520d0bdee93 100644
--- a/lldb/source/Host/linux/Host.cpp
+++ b/lldb/source/Host/linux/Host.cpp
@@ -377,28 +377,6 @@ Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
return GetProcessAndStatInfo (pid, process_info, stat_info, tracerpid);
}
-void
-Host::Backtrace (Stream &strm, uint32_t max_frames)
-{
-#ifndef __ANDROID__
- if (max_frames > 0)
- {
- std::vector<void *> frame_buffer (max_frames, NULL);
- int num_frames = ::backtrace (&frame_buffer[0], frame_buffer.size());
- char** strs = ::backtrace_symbols (&frame_buffer[0], num_frames);
- if (strs)
- {
- // Start at 1 to skip the "Host::Backtrace" frame
- for (int i = 1; i < num_frames; ++i)
- strm.Printf("%s\n", strs[i]);
- ::free (strs);
- }
- }
-#else
- assert(false && "::backtrace() not supported on Android");
-#endif
-}
-
size_t
Host::GetEnvironment (StringList &env)
{
diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm
index 512d3243e8e..3eb5a0e4079 100644
--- a/lldb/source/Host/macosx/Host.mm
+++ b/lldb/source/Host/macosx/Host.mm
@@ -704,25 +704,6 @@ Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no)
#endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
}
-
-void
-Host::Backtrace (Stream &strm, uint32_t max_frames)
-{
- if (max_frames > 0)
- {
- std::vector<void *> frame_buffer (max_frames, NULL);
- int num_frames = ::backtrace (&frame_buffer[0], frame_buffer.size());
- char** strs = ::backtrace_symbols (&frame_buffer[0], num_frames);
- if (strs)
- {
- // Start at 1 to skip the "Host::Backtrace" frame
- for (int i = 1; i < num_frames; ++i)
- strm.Printf("%s\n", strs[i]);
- ::free (strs);
- }
- }
-}
-
size_t
Host::GetEnvironment (StringList &env)
{
diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp
index f069114075b..777d555ed4c 100644
--- a/lldb/source/Symbol/ClangASTType.cpp
+++ b/lldb/source/Symbol/ClangASTType.cpp
@@ -30,6 +30,8 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/Signals.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/raw_ostream.h"
@@ -2135,11 +2137,14 @@ ClangASTType::GetBitSize (ExecutionContextScope *exe_scope) const
if (!g_printed)
{
StreamString s;
- s.Printf("warning: trying to determine the size of type ");
DumpTypeDescription(&s);
- s.Printf("\n without a valid ExecutionContext. this is not reliable. please file a bug against LLDB.\nbacktrace:\n");
- Host::Backtrace(s, UINT32_MAX);
- printf("%s\n", s.GetData());
+
+ llvm::outs() << "warning: trying to determine the size of type ";
+ llvm::outs() << s.GetString() << "\n";
+ llvm::outs() << "without a valid ExecutionContext. this is not reliable. please file a bug against LLDB.\n";
+ llvm::outs() << "backtrace:\n";
+ llvm::sys::PrintStackTrace(llvm::outs());
+ llvm::outs() << "\n";
g_printed = true;
}
}
@@ -2166,6 +2171,7 @@ ClangASTType::GetByteSize (ExecutionContextScope *exe_scope) const
return (GetBitSize (exe_scope) + 7) / 8;
}
+
size_t
ClangASTType::GetTypeBitAlign () const
{
diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp
index 875dd51bca3..c11c24b0e42 100644
--- a/lldb/source/Utility/LLDBAssert.cpp
+++ b/lldb/source/Utility/LLDBAssert.cpp
@@ -8,9 +8,12 @@
//===----------------------------------------------------------------------===//
#include "lldb/Utility/LLDBAssert.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/Host.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Signals.h"
+
+using namespace llvm;
using namespace lldb_private;
void
@@ -24,15 +27,10 @@ lldb_private::lldb_assert (int expression,
;
else
{
- StreamString stream;
- stream.Printf("Assertion failed: (%s), function %s, file %s, line %u\n",
- expr_text,
- func,
- file,
- line);
- stream.Printf("backtrace leading to the failure:\n");
- Host::Backtrace(stream, 1000);
- stream.Printf("please file a bug report against lldb reporting this failure log, and as many details as possible\n");
- printf("%s\n", stream.GetData());
+ errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
+ expr_text, func, file, line);
+ errs() << "backtrace leading to the failure:\n";
+ llvm::sys::PrintStackTrace(errs());
+ errs() << "please file a bug report against lldb reporting this failure log, and as many details as possible\n";
}
}
OpenPOWER on IntegriCloud