Skip to content
This repository was archived by the owner on Apr 2, 2020. It is now read-only.
12 changes: 10 additions & 2 deletions cmake/LLDBDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,17 @@ endif()

if(LLDB_BUILT_STANDALONE)
# this needs to be linked statially
list(APPEND LLDB_SYSTEM_LIBS ${PATH_TO_CMARK_BUILD}/src/libcmark.a)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
list(APPEND LLDB_SYSTEM_LIBS ${PATH_TO_CMARK_BUILD}/src/cmark.lib)
else()
list(APPEND LLDB_SYSTEM_LIBS ${PATH_TO_CMARK_BUILD}/src/libcmark.a)
endif()
else()
list(APPEND LLDB_SYSTEM_LIBS libcmark_static)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
list(APPEND LLDB_SYSTEM_LIBS ${PATH_TO_CMARK_BUILD}/src/cmark_static.lib)
else()
list(APPEND LLDB_SYSTEM_LIBS libcmark_static)
endif()
endif()

set(LLVM_LINK_COMPONENTS
Expand Down
4 changes: 2 additions & 2 deletions include/lldb/Symbol/SwiftASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ namespace swift {
enum class IRGenDebugInfoKind : unsigned;
class CanType;
class IRGenOptions;
class PrintOptions;
struct PrintOptions;
class SILModule;
namespace irgen {
class FixedTypeInfo;
class TypeInfo;
}
}

class CachedMemberInfo;
struct CachedMemberInfo;
class DWARFASTParser;
class SwiftEnumDescriptor;

Expand Down
47 changes: 35 additions & 12 deletions source/Core/IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObjectRegister.h"
#ifndef LLDB_DISABLE_LIBEDIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file differ from the LLDB llvm.org SVN top of tree and the changes here are just syncing with top of tree SVN?

Copy link
Collaborator Author

@hughbe hughbe Dec 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically fixed the build errors that I presume were caused by a bad merge - many syntax errors occured as a result - e.g. missing {, unhandled identifiers etc. The changes to this file were copy-pasted from upstream, but the file is different.

Take a look at this commit here: https://github.com/hughbe/swift-lldb/commit/8d544a47ba95533c369949fa3bf0ad01dadea0a3
It demonstrates what the diff looks like when I copy-and-paste the remaining bits of IOHandler.cpp from upstream. Basically, its changes in API that I didn't want to modify right now because I don't really wan't to break all the things!

#include "lldb/Host/Editline.h"
#endif
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/Block.h"
Expand Down Expand Up @@ -273,12 +275,16 @@ IOHandlerEditline::IOHandlerEditline(
IOHandlerDelegate &delegate)
: IOHandler(debugger, type, input_sp, output_sp, error_sp, flags),
#ifndef LLDB_DISABLE_LIBEDIT
m_editline_ap(), m_delegate(delegate), m_prompt(),
m_continuation_prompt(), m_current_lines_ptr(nullptr),
m_base_line_number(line_number_start), m_curr_line_idx(UINT32_MAX),
m_multi_line(multi_line), m_color_prompts(color_prompts),
m_interrupt_exits(true), m_editing(false) {
m_editline_ap(),
#endif
m_delegate(delegate), m_prompt(), m_continuation_prompt(),
m_current_lines_ptr(nullptr), m_base_line_number(line_number_start),
m_curr_line_idx(UINT32_MAX), m_multi_line(multi_line),
m_color_prompts(color_prompts), m_interrupt_exits(true),
m_editing(false) {
SetPrompt(prompt);

#ifndef LLDB_DISABLE_LIBEDIT
bool use_editline = false;

use_editline = m_input_sp->GetFile().GetIsRealTerminal();
Expand Down Expand Up @@ -306,7 +312,11 @@ IOHandlerEditline::IOHandlerEditline(
SetContinuationPrompt(continuation_prompt);
}

IOHandlerEditline::~IOHandlerEditline() { m_editline_ap.reset(); }
IOHandlerEditline::~IOHandlerEditline() {
#ifndef LLDB_DISABLE_LIBEDIT
m_editline_ap.reset();
#endif
}

void IOHandlerEditline::Activate() {
IOHandler::Activate();
Expand All @@ -319,9 +329,11 @@ void IOHandlerEditline::Deactivate() {
}

bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
#ifndef LLDB_DISABLE_LIBEDIT
if (m_editline_ap) {
return m_editline_ap->GetLine(line, interrupted);
} else {
#endif
line.clear();

FILE *in = GetInputFILE();
Expand Down Expand Up @@ -383,7 +395,9 @@ bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
SetIsDone(true);
}
return false;
#ifndef LLDB_DISABLE_LIBEDIT
}
#endif
}

#ifndef LLDB_DISABLE_LIBEDIT
Expand Down Expand Up @@ -417,16 +431,18 @@ int IOHandlerEditline::AutoCompleteCallback(const char *current_line,
max_matches, matches);
return 0;
}
#endif

const char *IOHandlerEditline::GetPrompt() {
#ifndef LLDB_DISABLE_LIBEDIT
if (m_editline_ap)
if (m_editline_ap) {
return m_editline_ap->GetPrompt();
else if (m_prompt.empty())
return nullptr;
#else
if (m_prompt.empty())
return nullptr;
} else {
#endif
if (m_prompt.empty())
return nullptr;
#ifndef LLDB_DISABLE_LIBEDIT
}
#endif
return m_prompt.c_str();
}
Expand Down Expand Up @@ -473,6 +489,7 @@ bool IOHandlerEditline::GetLines(StringList &lines, bool &interrupted) {
m_current_lines_ptr = &lines;

bool success = false;
#ifndef LLDB_DISABLE_LIBEDIT
if (m_editline_ap) {
return m_editline_ap->GetLines(m_base_line_number, lines, interrupted);
} else {
Expand Down Expand Up @@ -501,7 +518,9 @@ bool IOHandlerEditline::GetLines(StringList &lines, bool &interrupted) {
}
}
success = lines.GetSize() > 0;
#ifndef LLDB_DISABLE_LIBEDIT
}
#endif
m_current_lines_ptr = NULL;
return success;
}
Expand Down Expand Up @@ -552,14 +571,18 @@ bool IOHandlerEditline::Interrupt() {
if (m_delegate.IOHandlerInterrupt(*this))
return true;

#ifndef LLDB_DISABLE_LIBEDIT
if (m_editline_ap)
return m_editline_ap->Interrupt();
#endif
return false;
}

void IOHandlerEditline::GotEOF() {
#ifndef LLDB_DISABLE_LIBEDIT
if (m_editline_ap)
m_editline_ap->Interrupt();
#endif
}

void IOHandlerEditline::PrintAsync(Stream *stream, const char *s, size_t len) {
Expand Down
7 changes: 0 additions & 7 deletions source/Core/Mangled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
#include "lldb/Host/windows/windows.h"
#include <Dbghelp.h>
#pragma comment(lib, "dbghelp.lib")
#define LLDB_USE_BUILTIN_DEMANGLER
#elif defined(__FreeBSD__)
#define LLDB_USE_BUILTIN_DEMANGLER
#elif defined(__GLIBCXX__)
#define LLDB_USE_BUILTIN_DEMANGLER
#else
#include <cxxabi.h>
#endif

#ifdef LLDB_USE_BUILTIN_DEMANGLER
Expand Down
32 changes: 15 additions & 17 deletions source/Expression/ExpressionSourceCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "lldb/Target/Target.h"

#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/FileSystem.h"

using namespace lldb_private;
Expand Down Expand Up @@ -201,7 +202,6 @@ bool ExpressionSourceCode::SaveExpressionTextToTempFile(
bool success = false;

const uint32_t expr_number = options.GetExpressionNumber();
FileSpec tmpdir_file_spec;

const bool playground = options.GetPlaygroundTransformEnabled();
const bool repl = options.GetREPLEnabled();
Expand All @@ -214,30 +214,25 @@ bool ExpressionSourceCode::SaveExpressionTextToTempFile(
else
file_prefix = "expr";

StreamString strm;
if (HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir,
tmpdir_file_spec)) {
strm.Printf("%s%u", file_prefix, expr_number);
tmpdir_file_spec.GetFilename().SetCStringWithLength(
strm.GetString().c_str(), strm.GetString().size());
expr_source_path = std::move(tmpdir_file_spec.GetPath());
} else {
strm.Printf("/tmp/%s%u", file_prefix, expr_number);
expr_source_path = std::move(strm.GetString());
}
llvm::Twine prefix =
llvm::Twine(file_prefix).concat(llvm::Twine(expr_number));

llvm::StringRef suffix;
switch (options.GetLanguage()) {
default:
expr_source_path.append(".cpp");
suffix = ".cpp";
break;

case lldb::eLanguageTypeSwift:
expr_source_path.append(".swift");
suffix = ".swift";
break;
}

int temp_fd = mkstemp(&expr_source_path[0]);
if (temp_fd != -1) {
int temp_fd;
llvm::SmallString<128> buffer;
std::error_code err =
llvm::sys::fs::createTemporaryFile(prefix, suffix, temp_fd, buffer);
if (!err) {
lldb_private::File file(temp_fd, true);
const size_t text_len = strlen(text);
size_t bytes_written = text_len;
Expand All @@ -251,10 +246,13 @@ bool ExpressionSourceCode::SaveExpressionTextToTempFile(
}
}
if (!success)
FileSystem::Unlink(FileSpec(expr_source_path.c_str(), true));
FileSystem::Unlink(FileSpec(buffer.c_str(), true));
}
if (!success)
expr_source_path.clear();
else
expr_source_path = buffer.str().str();

return success;
}

Expand Down
1 change: 0 additions & 1 deletion source/Expression/Materializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,6 @@ class EntityResultVariable : public Materializer::Entity {
CompilerType m_type;
bool m_is_program_reference;
bool m_keep_in_memory;
bool m_is_error_result;

lldb::addr_t m_temporary_allocation;
size_t m_temporary_allocation_size;
Expand Down
2 changes: 1 addition & 1 deletion source/Host/common/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ Error Socket::Close() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf("%p Socket::Close (fd = %i)", static_cast<void *>(this),
m_socket);
static_cast<int>(m_socket));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't m_socket a SOCKET on windows?:

SOCKET WSAAPI socket(
In int af,
In int type,
In int protocol
);

How does casting this to an integer help here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Socket is defined as:

typedef UINT_PTR        SOCKET;

The warning we therefore get is trying to convert unsigned long long to int


#if defined(_WIN32)
bool success = !!closesocket(m_socket);
Expand Down
20 changes: 10 additions & 10 deletions source/Host/windows/Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ int _chdir(const char *path);

namespace {
bool utf8ToWide(const char *utf8, wchar_t *buf, size_t bufSize) {
const llvm::UTF8 *sourceStart = reinterpret_cast<const llvm::UTF8 *>(utf8);
const UTF8 *sourceStart = reinterpret_cast<const UTF8 *>(utf8);
size_t sourceLen = strlen(utf8) + 1 /* convert null too */;
llvm::UTF16 *target = reinterpret_cast<llvm::UTF16 *>(buf);
llvm::ConversionFlags flags = llvm::strictConversion;
return llvm::ConvertUTF8toUTF16(&sourceStart, sourceStart + sourceLen, &target,
target + bufSize, flags) == llvm::conversionOK;
UTF16 *target = reinterpret_cast<UTF16 *>(buf);
ConversionFlags flags = strictConversion;
return ConvertUTF8toUTF16(&sourceStart, sourceStart + sourceLen, &target,
target + bufSize, flags) == conversionOK;
}

bool wideToUtf8(const wchar_t *wide, char *buf, size_t bufSize) {
const llvm::UTF16 *sourceStart = reinterpret_cast<const llvm::UTF16 *>(wide);
const UTF16 *sourceStart = reinterpret_cast<const UTF16 *>(wide);
size_t sourceLen = wcslen(wide) + 1 /* convert null too */;
llvm::UTF8 *target = reinterpret_cast<llvm::UTF8 *>(buf);
llvm::ConversionFlags flags = llvm::strictConversion;
return llvm::ConvertUTF16toUTF8(&sourceStart, sourceStart + sourceLen, &target,
target + bufSize, flags) == llvm::conversionOK;
UTF8 *target = reinterpret_cast<UTF8 *>(buf);
ConversionFlags flags = strictConversion;
return ConvertUTF16toUTF8(&sourceStart, sourceStart + sourceLen, &target,
target + bufSize, flags) == conversionOK;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class ClangExpressionDeclMap : public ClangASTSource {
//----------------------------------------------------------------------
class ParserVars {
public:
ParserVars(ClangExpressionDeclMap &decl_map) : m_decl_map(decl_map) {}
ParserVars() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let Sean Callanan comment on all expression parser changes.


Target *GetTarget() {
if (m_exe_ctx.GetTargetPtr())
Expand All @@ -387,7 +387,6 @@ class ClangExpressionDeclMap : public ClangASTSource {
///that receives new top-level
///functions.
private:
ClangExpressionDeclMap &m_decl_map;
DISALLOW_COPY_AND_ASSIGN(ParserVars);
};

Expand All @@ -398,7 +397,7 @@ class ClangExpressionDeclMap : public ClangASTSource {
//----------------------------------------------------------------------
void EnableParserVars() {
if (!m_parser_vars.get())
m_parser_vars.reset(new ParserVars(*this));
m_parser_vars = llvm::make_unique<ParserVars>();
}

//----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,9 @@ class EntityREPLPersistentVariable : public Materializer::Entity {
public:
EntityREPLPersistentVariable(
lldb::ExpressionVariableSP &persistent_variable_sp,
SwiftREPLMaterializer *parent,
Materializer::PersistentVariableDelegate *delegate)
SwiftREPLMaterializer *parent)
: Entity(), m_persistent_variable_sp(persistent_variable_sp),
m_parent(parent), m_delegate(delegate) {
m_parent(parent) {
// Hard-coding to maximum size of a pointer since persistent variables are
// materialized by reference
m_size = 8;
Expand Down Expand Up @@ -443,15 +442,15 @@ class EntityREPLPersistentVariable : public Materializer::Entity {
private:
lldb::ExpressionVariableSP m_persistent_variable_sp;
SwiftREPLMaterializer *m_parent;
Materializer::PersistentVariableDelegate *m_delegate;
};

uint32_t SwiftREPLMaterializer::AddPersistentVariable(
lldb::ExpressionVariableSP &persistent_variable_sp,
PersistentVariableDelegate *delegate, Error &err) {
(void)delegate;
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
iter->reset(
new EntityREPLPersistentVariable(persistent_variable_sp, this, delegate));
new EntityREPLPersistentVariable(persistent_variable_sp, this));
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
Expand Down
9 changes: 6 additions & 3 deletions source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,9 @@ lldb::ExpressionVariableSP SwiftUserExpression::GetResultAfterDematerialization(

SwiftUserExpression::ResultDelegate::ResultDelegate(
SwiftUserExpression &user_expression, bool is_error)
: m_user_expression(user_expression), m_is_error(is_error) {}
: m_is_error(is_error) {
(void)user_expression;
}

ConstString SwiftUserExpression::ResultDelegate::GetName() {
return m_persistent_state->GetNextPersistentVariableName(m_is_error);
Expand All @@ -721,8 +723,9 @@ lldb::ExpressionVariableSP &SwiftUserExpression::ResultDelegate::GetVariable() {
}

SwiftUserExpression::PersistentVariableDelegate::PersistentVariableDelegate(
SwiftUserExpression &user_expression)
: m_user_expression(user_expression) {}
SwiftUserExpression &user_expression) {
(void)user_expression;
}

ConstString SwiftUserExpression::PersistentVariableDelegate::GetName() {
return ConstString();
Expand Down
Loading