summaryrefslogtreecommitdiff
path: root/source/Core
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-07-01 13:24:58 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-07-01 13:24:58 +0000
commit1b306c26ade71504511d2fa75b03dfaee77f9620 (patch)
tree2c4c77af2ba9632c24ebf216b9a39989d74f5725 /source/Core
parentfdea456ad833fbab0d3a296a58250950f11a498c (diff)
downloadsrc-test2-1b306c26ade71504511d2fa75b03dfaee77f9620.tar.gz
src-test2-1b306c26ade71504511d2fa75b03dfaee77f9620.zip
Notes
Diffstat (limited to 'source/Core')
-rw-r--r--source/Core/CMakeLists.txt3
-rw-r--r--source/Core/Communication.cpp2
-rw-r--r--source/Core/Connection.cpp32
-rw-r--r--source/Core/Disassembler.cpp6
-rw-r--r--source/Core/FormatEntity.cpp10
-rw-r--r--source/Core/Mangled.cpp2
-rw-r--r--source/Core/Module.cpp2
-rw-r--r--source/Core/StructuredData.cpp314
-rw-r--r--source/Core/Timer.cpp135
9 files changed, 11 insertions, 495 deletions
diff --git a/source/Core/CMakeLists.txt b/source/Core/CMakeLists.txt
index 806227793f24..c5105bd9ab12 100644
--- a/source/Core/CMakeLists.txt
+++ b/source/Core/CMakeLists.txt
@@ -7,7 +7,6 @@ add_lldb_library(lldbCore
ArchSpec.cpp
Broadcaster.cpp
Communication.cpp
- Connection.cpp
Debugger.cpp
Disassembler.cpp
DumpDataExtractor.cpp
@@ -33,8 +32,6 @@ add_lldb_library(lldbCore
State.cpp
StreamAsynchronousIO.cpp
StreamFile.cpp
- StructuredData.cpp
- Timer.cpp
UserSettingsController.cpp
Value.cpp
ValueObject.cpp
diff --git a/source/Core/Communication.cpp b/source/Core/Communication.cpp
index 72873a9510b5..38ab902ab4b7 100644
--- a/source/Core/Communication.cpp
+++ b/source/Core/Communication.cpp
@@ -9,11 +9,11 @@
#include "lldb/Core/Communication.h"
-#include "lldb/Core/Connection.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/Listener.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Utility/Connection.h"
#include "lldb/Utility/ConstString.h" // for ConstString
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Logging.h" // for LogIfAnyCategoriesSet, LIBLLDB...
diff --git a/source/Core/Connection.cpp b/source/Core/Connection.cpp
deleted file mode 100644
index 60d1221c160c..000000000000
--- a/source/Core/Connection.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-//===-- Connection.cpp ------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Core/Connection.h"
-
-#if defined(_WIN32)
-#include "lldb/Host/windows/ConnectionGenericFileWindows.h"
-#endif
-
-#include "lldb/Host/ConnectionFileDescriptor.h"
-
-#include <string.h> // for strstr
-
-using namespace lldb_private;
-
-Connection::Connection() {}
-
-Connection::~Connection() {}
-
-Connection *Connection::CreateDefaultConnection(const char *url) {
-#if defined(_WIN32)
- if (strstr(url, "file://") == url)
- return new ConnectionGenericFile();
-#endif
- return new ConnectionFileDescriptor();
-}
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index 0a5d763b6d3f..6d463d552da6 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -17,7 +17,6 @@
#include "lldb/Core/ModuleList.h" // for ModuleList
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/SourceManager.h" // for SourceManager
-#include "lldb/Core/Timer.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Interpreter/OptionValueArray.h"
@@ -37,8 +36,9 @@
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Status.h"
-#include "lldb/Utility/Stream.h" // for Stream
-#include "lldb/Utility/StreamString.h" // for StreamString
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h" // for StreamString
+#include "lldb/Utility/Timer.h"
#include "lldb/lldb-private-enumerations.h" // for InstructionType:...
#include "lldb/lldb-private-interfaces.h" // for DisassemblerCrea...
#include "lldb/lldb-private-types.h" // for RegisterInfo
diff --git a/source/Core/FormatEntity.cpp b/source/Core/FormatEntity.cpp
index e3c346f79d6b..6002efe9244d 100644
--- a/source/Core/FormatEntity.cpp
+++ b/source/Core/FormatEntity.cpp
@@ -14,8 +14,7 @@
#include "lldb/Core/ArchSpec.h" // for ArchSpec
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/RegisterValue.h" // for RegisterValue
-#include "lldb/Core/StructuredData.h" // for StructuredData::O...
+#include "lldb/Core/RegisterValue.h" // for RegisterValue
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/DataVisualization.h"
@@ -50,9 +49,10 @@
#include "lldb/Utility/SharingPtr.h" // for SharingPtr
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
-#include "lldb/Utility/StringList.h" // for StringList
-#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
-#include "lldb/lldb-forward.h" // for ValueObjectSP
+#include "lldb/Utility/StringList.h" // for StringList
+#include "lldb/Utility/StructuredData.h" // for StructuredData::O...
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-forward.h" // for ValueObjectSP
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h" // for Triple, Triple::O...
diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp
index 4dac0b8f3bf1..211a0c32cee7 100644
--- a/source/Core/Mangled.cpp
+++ b/source/Core/Mangled.cpp
@@ -27,12 +27,12 @@
#include <cxxabi.h>
#endif
-#include "lldb/Core/Timer.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Logging.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/Timer.h"
#include "lldb/lldb-enumerations.h" // for LanguageType
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 1b510d2ff7b2..aaae4700db35 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -17,7 +17,6 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/SearchFilter.h" // for SearchFilt...
#include "lldb/Core/Section.h"
-#include "lldb/Core/Timer.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -45,6 +44,7 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h" // for Stream
#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/Timer.h"
#if defined(LLVM_ON_WIN32)
#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX
diff --git a/source/Core/StructuredData.cpp b/source/Core/StructuredData.cpp
deleted file mode 100644
index b03665ed3485..000000000000
--- a/source/Core/StructuredData.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-//===---------------------StructuredData.cpp ---------------------*- C++-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Core/StructuredData.h"
-
-#include "lldb/Host/File.h"
-#include "lldb/Host/StringConvert.h"
-#include "lldb/Utility/DataBuffer.h"
-#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/JSON.h"
-#include "lldb/Utility/Status.h"
-#include "lldb/Utility/Stream.h" // for Stream
-#include "lldb/Utility/StreamString.h"
-#include "lldb/lldb-enumerations.h" // for FilePermissions::eFilePermiss...
-#include "lldb/lldb-forward.h" // for DataBufferSP
-
-#include "llvm/ADT/STLExtras.h" // for make_unique
-
-#include <limits> // for numeric_limits
-
-#include <errno.h>
-#include <inttypes.h>
-#include <stdio.h> // for printf
-#include <stdlib.h>
-#include <sys/types.h> // for off_t
-
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// Functions that use a JSONParser to parse JSON into StructuredData
-//----------------------------------------------------------------------
-static StructuredData::ObjectSP ParseJSONValue(JSONParser &json_parser);
-static StructuredData::ObjectSP ParseJSONObject(JSONParser &json_parser);
-static StructuredData::ObjectSP ParseJSONArray(JSONParser &json_parser);
-
-StructuredData::ObjectSP
-StructuredData::ParseJSONFromFile(const FileSpec &input_spec, Status &error) {
- StructuredData::ObjectSP return_sp;
- if (!input_spec.Exists()) {
- error.SetErrorStringWithFormat("input file %s does not exist.",
- input_spec.GetPath().c_str());
- return return_sp;
- }
-
- File input_file(nullptr, File::OpenOptions::eOpenOptionRead,
- lldb::eFilePermissionsUserRead);
- std::string input_path = input_spec.GetPath();
- error =
- input_file.Open(input_path.c_str(), File::OpenOptions::eOpenOptionRead,
- lldb::eFilePermissionsUserRead);
-
- if (!error.Success()) {
- error.SetErrorStringWithFormat("could not open input file: %s - %s.",
- input_spec.GetPath().c_str(),
- error.AsCString());
- return return_sp;
- }
-
- lldb::DataBufferSP input_data;
- size_t num_bytes = std::numeric_limits<size_t>::max();
- off_t offset = 0;
- error = input_file.Read(num_bytes, offset, true, input_data);
- if (!error.Success()) {
- error.SetErrorStringWithFormat("could not read input file: %s - %s.",
- input_spec.GetPath().c_str(),
- error.AsCString());
- return return_sp;
- }
- JSONParser json_parser((char *)input_data->GetBytes());
- return_sp = ParseJSONValue(json_parser);
- return return_sp;
-}
-
-static StructuredData::ObjectSP ParseJSONObject(JSONParser &json_parser) {
- // The "JSONParser::Token::ObjectStart" token should have already been
- // consumed by the time this function is called
- auto dict_up = llvm::make_unique<StructuredData::Dictionary>();
-
- std::string value;
- std::string key;
- while (1) {
- JSONParser::Token token = json_parser.GetToken(value);
-
- if (token == JSONParser::Token::String) {
- key.swap(value);
- token = json_parser.GetToken(value);
- if (token == JSONParser::Token::Colon) {
- StructuredData::ObjectSP value_sp = ParseJSONValue(json_parser);
- if (value_sp)
- dict_up->AddItem(key, value_sp);
- else
- break;
- }
- } else if (token == JSONParser::Token::ObjectEnd) {
- return StructuredData::ObjectSP(dict_up.release());
- } else if (token == JSONParser::Token::Comma) {
- continue;
- } else {
- break;
- }
- }
- return StructuredData::ObjectSP();
-}
-
-static StructuredData::ObjectSP ParseJSONArray(JSONParser &json_parser) {
- // The "JSONParser::Token::ObjectStart" token should have already been
- // consumed
- // by the time this function is called
- auto array_up = llvm::make_unique<StructuredData::Array>();
-
- std::string value;
- std::string key;
- while (1) {
- StructuredData::ObjectSP value_sp = ParseJSONValue(json_parser);
- if (value_sp)
- array_up->AddItem(value_sp);
- else
- break;
-
- JSONParser::Token token = json_parser.GetToken(value);
- if (token == JSONParser::Token::Comma) {
- continue;
- } else if (token == JSONParser::Token::ArrayEnd) {
- return StructuredData::ObjectSP(array_up.release());
- } else {
- break;
- }
- }
- return StructuredData::ObjectSP();
-}
-
-static StructuredData::ObjectSP ParseJSONValue(JSONParser &json_parser) {
- std::string value;
- const JSONParser::Token token = json_parser.GetToken(value);
- switch (token) {
- case JSONParser::Token::ObjectStart:
- return ParseJSONObject(json_parser);
-
- case JSONParser::Token::ArrayStart:
- return ParseJSONArray(json_parser);
-
- case JSONParser::Token::Integer: {
- bool success = false;
- uint64_t uval = StringConvert::ToUInt64(value.c_str(), 0, 0, &success);
- if (success)
- return std::make_shared<StructuredData::Integer>(uval);
- } break;
-
- case JSONParser::Token::Float: {
- bool success = false;
- double val = StringConvert::ToDouble(value.c_str(), 0.0, &success);
- if (success)
- return std::make_shared<StructuredData::Float>(val);
- } break;
-
- case JSONParser::Token::String:
- return std::make_shared<StructuredData::String>(value);
-
- case JSONParser::Token::True:
- case JSONParser::Token::False:
- return std::make_shared<StructuredData::Boolean>(token ==
- JSONParser::Token::True);
-
- case JSONParser::Token::Null:
- return std::make_shared<StructuredData::Null>();
-
- default:
- break;
- }
- return StructuredData::ObjectSP();
-}
-
-StructuredData::ObjectSP StructuredData::ParseJSON(std::string json_text) {
- JSONParser json_parser(json_text.c_str());
- StructuredData::ObjectSP object_sp = ParseJSONValue(json_parser);
- return object_sp;
-}
-
-StructuredData::ObjectSP
-StructuredData::Object::GetObjectForDotSeparatedPath(llvm::StringRef path) {
- if (this->GetType() == lldb::eStructuredDataTypeDictionary) {
- std::pair<llvm::StringRef, llvm::StringRef> match = path.split('.');
- std::string key = match.first.str();
- ObjectSP value = this->GetAsDictionary()->GetValueForKey(key);
- if (value.get()) {
- // Do we have additional words to descend? If not, return the
- // value we're at right now.
- if (match.second.empty()) {
- return value;
- } else {
- return value->GetObjectForDotSeparatedPath(match.second);
- }
- }
- return ObjectSP();
- }
-
- if (this->GetType() == lldb::eStructuredDataTypeArray) {
- std::pair<llvm::StringRef, llvm::StringRef> match = path.split('[');
- if (match.second.size() == 0) {
- return this->shared_from_this();
- }
- errno = 0;
- uint64_t val = strtoul(match.second.str().c_str(), NULL, 10);
- if (errno == 0) {
- return this->GetAsArray()->GetItemAtIndex(val);
- }
- return ObjectSP();
- }
-
- return this->shared_from_this();
-}
-
-void StructuredData::Object::DumpToStdout(bool pretty_print) const {
- StreamString stream;
- Dump(stream, pretty_print);
- printf("%s\n", stream.GetData());
-}
-
-void StructuredData::Array::Dump(Stream &s, bool pretty_print) const {
- bool first = true;
- s << "[";
- if (pretty_print) {
- s << "\n";
- s.IndentMore();
- }
- for (const auto &item_sp : m_items) {
- if (first) {
- first = false;
- } else {
- s << ",";
- if (pretty_print)
- s << "\n";
- }
-
- if (pretty_print)
- s.Indent();
- item_sp->Dump(s, pretty_print);
- }
- if (pretty_print) {
- s.IndentLess();
- s.EOL();
- s.Indent();
- }
- s << "]";
-}
-
-void StructuredData::Integer::Dump(Stream &s, bool pretty_print) const {
- s.Printf("%" PRIu64, m_value);
-}
-
-void StructuredData::Float::Dump(Stream &s, bool pretty_print) const {
- s.Printf("%lg", m_value);
-}
-
-void StructuredData::Boolean::Dump(Stream &s, bool pretty_print) const {
- if (m_value == true)
- s.PutCString("true");
- else
- s.PutCString("false");
-}
-
-void StructuredData::String::Dump(Stream &s, bool pretty_print) const {
- std::string quoted;
- const size_t strsize = m_value.size();
- for (size_t i = 0; i < strsize; ++i) {
- char ch = m_value[i];
- if (ch == '"' || ch == '\\')
- quoted.push_back('\\');
- quoted.push_back(ch);
- }
- s.Printf("\"%s\"", quoted.c_str());
-}
-
-void StructuredData::Dictionary::Dump(Stream &s, bool pretty_print) const {
- bool first = true;
- s << "{";
- if (pretty_print) {
- s << "\n";
- s.IndentMore();
- }
- for (const auto &pair : m_dict) {
- if (first)
- first = false;
- else {
- s << ",";
- if (pretty_print)
- s << "\n";
- }
- if (pretty_print)
- s.Indent();
- s << "\"" << pair.first.AsCString() << "\" : ";
- pair.second->Dump(s, pretty_print);
- }
- if (pretty_print) {
- s.IndentLess();
- s.EOL();
- s.Indent();
- }
- s << "}";
-}
-
-void StructuredData::Null::Dump(Stream &s, bool pretty_print) const {
- s << "null";
-}
-
-void StructuredData::Generic::Dump(Stream &s, bool pretty_print) const {
- s << "0x" << m_object;
-}
diff --git a/source/Core/Timer.cpp b/source/Core/Timer.cpp
deleted file mode 100644
index 59c3e13a717e..000000000000
--- a/source/Core/Timer.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-//===-- Timer.cpp -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#include "lldb/Core/Timer.h"
-
-#include "lldb/Host/Host.h"
-#include "lldb/Utility/Stream.h"
-#include "lldb/lldb-types.h" // for thread_key_t
-
-#include <algorithm>
-#include <map>
-#include <mutex>
-#include <utility> // for pair
-#include <vector>
-
-#include <assert.h> // for assert
-#include <stdarg.h> // for va_end, va_list, va_start
-#include <stdio.h>
-
-using namespace lldb_private;
-
-#define TIMER_INDENT_AMOUNT 2
-
-namespace {
-typedef std::vector<Timer *> TimerStack;
-static std::atomic<Timer::Category *> g_categories;
-} // end of anonymous namespace
-
-std::atomic<bool> Timer::g_quiet(true);
-std::atomic<unsigned> Timer::g_display_depth(0);
-static std::mutex &GetFileMutex() {
- static std::mutex *g_file_mutex_ptr = new std::mutex();
- return *g_file_mutex_ptr;
-}
-
-static TimerStack &GetTimerStackForCurrentThread() {
- static thread_local TimerStack g_stack;
- return g_stack;
-}
-
-Timer::Category::Category(const char *cat) : m_name(cat) {
- m_nanos.store(0, std::memory_order_release);
- Category *expected = g_categories;
- do {
- m_next = expected;
- } while (!g_categories.compare_exchange_weak(expected, this));
-}
-
-void Timer::SetQuiet(bool value) { g_quiet = value; }
-
-Timer::Timer(Timer::Category &category, const char *format, ...)
- : m_category(category), m_total_start(std::chrono::steady_clock::now()) {
- TimerStack &stack = GetTimerStackForCurrentThread();
-
- stack.push_back(this);
- if (g_quiet && stack.size() <= g_display_depth) {
- std::lock_guard<std::mutex> lock(GetFileMutex());
-
- // Indent
- ::fprintf(stdout, "%*s", int(stack.size() - 1) * TIMER_INDENT_AMOUNT, "");
- // Print formatted string
- va_list args;
- va_start(args, format);
- ::vfprintf(stdout, format, args);
- va_end(args);
-
- // Newline
- ::fprintf(stdout, "\n");
- }
-}
-
-Timer::~Timer() {
- using namespace std::chrono;
-
- auto stop_time = steady_clock::now();
- auto total_dur = stop_time - m_total_start;
- auto timer_dur = total_dur - m_child_duration;
-
- TimerStack &stack = GetTimerStackForCurrentThread();
- if (g_quiet && stack.size() <= g_display_depth) {
- std::lock_guard<std::mutex> lock(GetFileMutex());
- ::fprintf(stdout, "%*s%.9f sec (%.9f sec)\n",
- int(stack.size() - 1) * TIMER_INDENT_AMOUNT, "",
- duration<double>(total_dur).count(),
- duration<double>(timer_dur).count());
- }
-
- assert(stack.back() == this);
- stack.pop_back();
- if (!stack.empty())
- stack.back()->ChildDuration(total_dur);
-
- // Keep total results for each category so we can dump results.
- m_category.m_nanos += std::chrono::nanoseconds(timer_dur).count();
-}
-
-void Timer::SetDisplayDepth(uint32_t depth) { g_display_depth = depth; }
-
-/* binary function predicate:
- * - returns whether a person is less than another person
- */
-
-typedef std::pair<const char *, uint64_t> TimerEntry;
-
-static bool CategoryMapIteratorSortCriterion(const TimerEntry &lhs,
- const TimerEntry &rhs) {
- return lhs.second > rhs.second;
-}
-
-void Timer::ResetCategoryTimes() {
- for (Category *i = g_categories; i; i = i->m_next)
- i->m_nanos.store(0, std::memory_order_release);
-}
-
-void Timer::DumpCategoryTimes(Stream *s) {
- std::vector<TimerEntry> sorted;
- for (Category *i = g_categories; i; i = i->m_next) {
- uint64_t nanos = i->m_nanos.load(std::memory_order_acquire);
- if (nanos)
- sorted.push_back(std::make_pair(i->m_name, nanos));
- }
- if (sorted.empty())
- return; // Later code will break without any elements.
-
- // Sort by time
- std::sort(sorted.begin(), sorted.end(), CategoryMapIteratorSortCriterion);
-
- for (const auto &timer : sorted)
- s->Printf("%.9f sec for %s\n", timer.second / 1000000000., timer.first);
-}