Make lldb -Werror clean on Windows.

Differential Revision: https://reviews.llvm.org/D25247

llvm-svn: 283344
This commit is contained in:
Zachary Turner 2016-10-05 17:07:34 +00:00
parent d6ef28462b
commit 5a8ad4591b
39 changed files with 274 additions and 233 deletions

View File

@ -25,11 +25,11 @@ public:
void SetOwnsHandle(bool owns);
virtual Error Terminate();
virtual Error GetMainModule(FileSpec &file_spec) const;
Error Terminate() override;
Error GetMainModule(FileSpec &file_spec) const override;
virtual lldb::pid_t GetProcessId() const;
virtual bool IsRunning() const;
lldb::pid_t GetProcessId() const override;
bool IsRunning() const override;
HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback,
bool monitor_signals) override;

View File

@ -57,10 +57,9 @@
typedef unsigned short mode_t;
// pyconfig.h typedefs this. We require python headers to be included before
// any
// LLDB headers, but there's no way to prevent python's pid_t definition from
// leaking, so this is the best option.
#ifndef Py_CONFIG_H
// any LLDB headers, but there's no way to prevent python's pid_t definition
// from leaking, so this is the best option.
#ifndef NO_PID_T
typedef uint32_t pid_t;
#endif
@ -69,7 +68,10 @@ typedef uint32_t pid_t;
#define STDERR_FILENO 2
#define S_IFDIR _S_IFDIR
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
#endif
#endif // _MSC_VER

View File

@ -37,17 +37,17 @@ public:
// set the file descriptors that we will watch for when calling
// select. This will cause FD_SET() to be called prior to calling select
// using the "fd" provided.
void FDSetRead(int fd);
void FDSetWrite(int fd);
void FDSetError(int fd);
void FDSetRead(lldb::socket_t fd);
void FDSetWrite(lldb::socket_t fd);
void FDSetError(lldb::socket_t fd);
// Call the FDIsSet*() functions after calling SelectHelper::Select()
// to check which file descriptors are ready for read/write/error. This
// will contain the result of FD_ISSET after calling select for a given
// file descriptor.
bool FDIsSetRead(int fd) const;
bool FDIsSetWrite(int fd) const;
bool FDIsSetError(int fd) const;
bool FDIsSetRead(lldb::socket_t fd) const;
bool FDIsSetWrite(lldb::socket_t fd) const;
bool FDIsSetError(lldb::socket_t fd) const;
// Call the system's select() to wait for descriptors using
// timeout provided in a call the SelectHelper::SetTimeout(),
@ -69,7 +69,7 @@ protected:
bool read_set : 1, write_set : 1, error_set : 1, read_is_set : 1,
write_is_set : 1, error_is_set : 1;
};
llvm::DenseMap<int, FDInfo> m_fd_map;
llvm::DenseMap<lldb::socket_t, FDInfo> m_fd_map;
llvm::Optional<std::chrono::steady_clock::time_point> m_end_time;
};

View File

@ -259,7 +259,7 @@ Mangled::GetDemangledName(lldb::LanguageType language) const {
log->Printf("demangled msvc: %s -> \"%s\"", mangled_name,
demangled_name);
else
log->Printf("demangled msvc: %s -> error: 0x%" PRIx64, mangled_name,
log->Printf("demangled msvc: %s -> error: 0x%lu", mangled_name,
result);
}

View File

@ -654,7 +654,7 @@ bool SourceManager::File::CalculateLineOffsets(uint32_t line) {
}
}
if (!m_offsets.empty()) {
if (m_offsets.back() < end - start)
if (m_offsets.back() < size_t(end - start))
m_offsets.push_back(end - start);
}
return true;

View File

@ -135,7 +135,7 @@ GetPrintableImpl<StringPrinter::StringElementType::UTF8>(uint8_t *buffer,
unsigned utf8_encoded_len = llvm::getNumBytesForUTF8(*buffer);
if (1 + buffer_end - buffer < utf8_encoded_len) {
if (1u + std::distance(buffer, buffer_end) < utf8_encoded_len) {
// I don't have enough bytes - print whatever I have left
retval = {buffer, static_cast<size_t>(1 + buffer_end - buffer)};
next = buffer_end + 1;

View File

@ -25,7 +25,7 @@ Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint,
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
if (log)
log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64
", size_hint = %lu, hardware = %s",
", size_hint = %zu, hardware = %s",
__FUNCTION__, addr, size_hint, hardware ? "true" : "false");
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@ -47,7 +47,7 @@ Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint,
if (log)
log->Printf(
"NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64
", size_hint = %lu, hardware = %s",
", size_hint = %zu, hardware = %s",
__FUNCTION__, addr, size_hint, hardware ? "true" : "false");
NativeBreakpointSP breakpoint_sp;
@ -56,7 +56,7 @@ Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint,
if (log)
log->Printf(
"NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64
", size_hint = %lu, hardware = %s -- FAILED: %s",
", size_hint = %zu, hardware = %s -- FAILED: %s",
__FUNCTION__, addr, size_hint, hardware ? "true" : "false",
error.AsCString());
return error;

View File

@ -1,5 +1,4 @@
#ifndef _WIN32
#include "lldb/Host/ProcessRunLock.h"
namespace lldb_private {

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
#if defined(_MSC_VER)
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#include "lldb/Host/SocketAddress.h"
#include <stddef.h>
#include <stdio.h>
@ -41,7 +45,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) {
case AF_INET: {
{
const char *formatted = inet_ntoa(*static_cast<const in_addr *>(src));
if (formatted && strlen(formatted) < size) {
if (formatted && strlen(formatted) < static_cast<size_t>(size)) {
return ::strcpy(dst, formatted);
}
}

View File

@ -62,12 +62,12 @@ Error SoftwareBreakpoint::CreateSoftwareBreakpoint(
if (bp_opcode_size > MAX_TRAP_OPCODE_SIZE) {
if (log)
log->Printf("SoftwareBreakpoint::%s cannot support %lu trapcode bytes, "
"max size is %lu",
log->Printf("SoftwareBreakpoint::%s cannot support %zu trapcode bytes, "
"max size is %zu",
__FUNCTION__, bp_opcode_size, MAX_TRAP_OPCODE_SIZE);
return Error("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() "
"returned too many trap opcode bytes: requires %lu but we "
"only support a max of %lu",
"returned too many trap opcode bytes: requires %zu but we "
"only support a max of %zu",
bp_opcode_size, MAX_TRAP_OPCODE_SIZE);
}
@ -135,13 +135,13 @@ Error SoftwareBreakpoint::EnableSoftwareBreakpoint(
if (bytes_read != bp_opcode_size) {
if (log)
log->Printf("SoftwareBreakpoint::%s failed to read memory while "
"attempting to set breakpoint: attempted to read %lu bytes "
"but only read %" PRIu64,
__FUNCTION__, bp_opcode_size, (uint64_t)bytes_read);
"attempting to set breakpoint: attempted to read %zu bytes "
"but only read %zu",
__FUNCTION__, bp_opcode_size, bytes_read);
return Error("SoftwareBreakpoint::%s failed to read memory while "
"attempting to set breakpoint: attempted to read %lu bytes "
"but only read %" PRIu64,
__FUNCTION__, bp_opcode_size, (uint64_t)bytes_read);
"attempting to set breakpoint: attempted to read %zu bytes "
"but only read %zu",
__FUNCTION__, bp_opcode_size, bytes_read);
}
// Log what we read.
@ -171,8 +171,8 @@ Error SoftwareBreakpoint::EnableSoftwareBreakpoint(
if (bytes_written != bp_opcode_size) {
error.SetErrorStringWithFormat(
"SoftwareBreakpoint::%s failed write memory while attempting to set "
"breakpoint: attempted to write %lu bytes but only wrote %" PRIu64,
__FUNCTION__, bp_opcode_size, (uint64_t)bytes_written);
"breakpoint: attempted to write %zu bytes but only wrote %zu",
__FUNCTION__, bp_opcode_size, bytes_written);
if (log)
log->PutCString(error.AsCString());
return error;
@ -194,13 +194,13 @@ Error SoftwareBreakpoint::EnableSoftwareBreakpoint(
if (verify_bytes_read != bp_opcode_size) {
if (log)
log->Printf("SoftwareBreakpoint::%s failed to read memory while "
"attempting to verify breakpoint: attempted to read %lu "
"bytes but only read %" PRIu64,
__FUNCTION__, bp_opcode_size, (uint64_t)verify_bytes_read);
"attempting to verify breakpoint: attempted to read %zu "
"bytes but only read %zu",
__FUNCTION__, bp_opcode_size, verify_bytes_read);
return Error("SoftwareBreakpoint::%s failed to read memory while "
"attempting to verify breakpoint: attempted to read %lu bytes "
"but only read %" PRIu64,
__FUNCTION__, bp_opcode_size, (uint64_t)verify_bytes_read);
"attempting to verify breakpoint: attempted to read %zu bytes "
"but only read %zu",
__FUNCTION__, bp_opcode_size, verify_bytes_read);
}
if (::memcmp(bp_opcode_bytes, verify_bp_opcode_bytes, bp_opcode_size) != 0) {
@ -271,8 +271,8 @@ Error SoftwareBreakpoint::DoDisable() {
if (error.Success() && bytes_read < m_opcode_size) {
error.SetErrorStringWithFormat(
"SoftwareBreakpointr::%s addr=0x%" PRIx64
": tried to read %lu bytes but only read %" PRIu64,
__FUNCTION__, m_addr, m_opcode_size, (uint64_t)bytes_read);
": tried to read %zu bytes but only read %zu",
__FUNCTION__, m_addr, m_opcode_size, bytes_read);
}
if (error.Success()) {
bool verify = false;
@ -287,8 +287,8 @@ Error SoftwareBreakpoint::DoDisable() {
if (error.Success() && bytes_written < m_opcode_size) {
error.SetErrorStringWithFormat(
"SoftwareBreakpoint::%s addr=0x%" PRIx64
": tried to write %lu bytes but only wrote %" PRIu64,
__FUNCTION__, m_addr, m_opcode_size, (uint64_t)bytes_written);
": tried to write %zu bytes but only wrote %zu",
__FUNCTION__, m_addr, m_opcode_size, bytes_written);
}
if (error.Success()) {
verify = true;
@ -312,8 +312,8 @@ Error SoftwareBreakpoint::DoDisable() {
if (error.Success() && verify_bytes_read < m_opcode_size) {
error.SetErrorStringWithFormat(
"SoftwareBreakpoint::%s addr=0x%" PRIx64
": tried to read %lu verification bytes but only read %" PRIu64,
__FUNCTION__, m_addr, m_opcode_size, (uint64_t)verify_bytes_read);
": tried to read %zu verification bytes but only read %zu",
__FUNCTION__, m_addr, m_opcode_size, verify_bytes_read);
}
if (error.Success()) {
// compare the memory we just read with the original opcode

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
#if defined(_MSC_VER)
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#include "lldb/Host/common/TCPSocket.h"
#include "lldb/Core/Log.h"

View File

@ -102,7 +102,11 @@ Error UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
&service_info_list);
if (err != 0) {
error.SetErrorStringWithFormat(
#if defined(_MSC_VER) && defined(UNICODE)
"getaddrinfo(%s, %s, &hints, &info) returned error %i (%S)",
#else
"getaddrinfo(%s, %s, &hints, &info) returned error %i (%s)",
#endif
host_str.c_str(), port_str.c_str(), err, gai_strerror(err));
return error;
}

View File

@ -259,11 +259,9 @@ finish:
IncrementFilePointer(return_info.GetBytes());
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log) {
log->Printf("%" PRIxPTR " ConnectionGenericFile::Read() handle = %" PRIxPTR
", dst = %" PRIxPTR ", dst_len = %" PRIu64 ") => %" PRIu64
", error = %s",
this, m_file, dst, static_cast<uint64_t>(dst_len),
static_cast<uint64_t>(return_info.GetBytes()),
log->Printf("%p ConnectionGenericFile::Read() handle = %p, dst = %p, "
"dst_len = %zu) => %zu, error = %s",
this, m_file, dst, dst_len, return_info.GetBytes(),
return_info.GetError().AsCString());
}
@ -310,12 +308,9 @@ finish:
IncrementFilePointer(return_info.GetBytes());
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log) {
log->Printf("%" PRIxPTR
" ConnectionGenericFile::Write() handle = %" PRIxPTR
", src = %" PRIxPTR ", src_len = %" PRIu64 ") => %" PRIu64
", error = %s",
this, m_file, src, static_cast<uint64_t>(src_len),
static_cast<uint64_t>(return_info.GetBytes()),
log->Printf("%p ConnectionGenericFile::Write() handle = %p, src = %p, "
"src_len = %zu) => %zu, error = %s",
this, m_file, src, src_len, return_info.GetBytes(),
return_info.GetError().AsCString());
}
return return_info.GetBytes();

View File

@ -266,8 +266,7 @@ int el_set(EditLine *el, int code, ...) {
const char *name = va_arg(vl, const char *);
for (int i = 0; i < _bindings.size(); i++) {
el_binding *bind = _bindings[i];
for (auto bind : _bindings) {
if (strcmp(bind->name, name) == 0) {
bind->key = va_arg(vl, const char *);
break;

View File

@ -65,7 +65,7 @@ Error FileSystem::DeleteDirectory(const FileSpec &file_spec, bool recurse) {
path_buffer.push_back(0);
path_buffer.push_back(0);
SHFILEOPSTRUCTW shfos = {0};
SHFILEOPSTRUCTW shfos = {};
shfos.wFunc = FO_DELETE;
shfos.pFrom = (LPCWSTR)path_buffer.data();
shfos.fFlags = FOF_NO_UI;

View File

@ -159,7 +159,7 @@ uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
if (!snapshot.IsValid())
return 0;
PROCESSENTRY32W pe = {0};
PROCESSENTRY32W pe = {};
pe.dwSize = sizeof(PROCESSENTRY32W);
if (Process32FirstW(snapshot.get(), &pe)) {
do {

View File

@ -21,7 +21,7 @@ Error fileLock(HANDLE file_handle, DWORD flags, const uint64_t start,
if (start != 0)
return Error("Non-zero start lock regions are not supported");
OVERLAPPED overlapped = {0};
OVERLAPPED overlapped = {};
if (!::LockFileEx(file_handle, flags, 0, len, 0, &overlapped) &&
::GetLastError() != ERROR_IO_PENDING)
@ -64,7 +64,7 @@ Error LockFileWindows::DoTryReadLock(const uint64_t start, const uint64_t len) {
}
Error LockFileWindows::DoUnlock() {
OVERLAPPED overlapped = {0};
OVERLAPPED overlapped = {};
if (!::UnlockFileEx(m_file, 0, m_len, 0, &overlapped) &&
::GetLastError() != ERROR_IO_PENDING)

View File

@ -134,7 +134,7 @@ Error PipeWindows::OpenNamedPipe(llvm::StringRef name,
assert(is_read ? !CanRead() : !CanWrite());
SECURITY_ATTRIBUTES attributes = {0};
SECURITY_ATTRIBUTES attributes = {};
attributes.bInheritHandle = child_process_inherit;
std::string pipe_path = "\\\\.\\Pipe\\";

View File

@ -26,7 +26,7 @@ void CreateEnvironmentBuffer(const Args &env, std::vector<char> &buffer) {
return;
// Environment buffer is a null terminated list of null terminated strings
for (int i = 0; i < env.GetArgumentCount(); ++i) {
for (size_t i = 0; i < env.GetArgumentCount(); ++i) {
std::wstring warg;
if (llvm::ConvertUTF8toWide(env.GetArgumentAtIndex(i), warg)) {
buffer.insert(buffer.end(), (char *)warg.c_str(),
@ -47,8 +47,8 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
std::string executable;
std::string commandLine;
std::vector<char> environment;
STARTUPINFO startupinfo = {0};
PROCESS_INFORMATION pi = {0};
STARTUPINFO startupinfo = {};
PROCESS_INFORMATION pi = {};
HANDLE stdin_handle = GetStdioHandle(launch_info, STDIN_FILENO);
HANDLE stdout_handle = GetStdioHandle(launch_info, STDOUT_FILENO);
@ -120,7 +120,7 @@ ProcessLauncherWindows::GetStdioHandle(const ProcessLaunchInfo &launch_info,
const FileAction *action = launch_info.GetFileActionForFD(fd);
if (action == nullptr)
return NULL;
SECURITY_ATTRIBUTES secattr = {0};
SECURITY_ATTRIBUTES secattr = {};
secattr.nLength = sizeof(SECURITY_ATTRIBUTES);
secattr.bInheritHandle = TRUE;

View File

@ -46,7 +46,7 @@ ProcessRunLock::ProcessRunLock() : m_running(false) {
InitializeSRWLock(GetLock(m_rwlock));
}
ProcessRunLock::~ProcessRunLock() { delete m_rwlock; }
ProcessRunLock::~ProcessRunLock() { delete static_cast<SRWLOCK *>(m_rwlock); }
bool ProcessRunLock::ReadTryLock() {
::ReadLock(m_rwlock);

View File

@ -275,7 +275,7 @@ void Args::UpdateArgsAfterOptionParsing() {
// This happens because getopt_long_only may permute the order of the
// arguments in argv, so we need to re-order the quotes and the refs array
// to match.
for (int i = 0; i < m_argv.size() - 1; ++i) {
for (size_t i = 0; i < m_argv.size() - 1; ++i) {
const char *argv = m_argv[i];
auto pos =
std::find_if(m_entries.begin() + i, m_entries.end(),
@ -352,8 +352,8 @@ void Args::AppendArguments(const char **argv) {
assert(m_argv.size() == m_entries.size() + 1);
assert(m_argv.back() == nullptr);
m_argv.pop_back();
for (int i = 0; i < argc; ++i) {
m_entries.emplace_back(argv[i], '\0');
for (auto arg : llvm::makeArrayRef(argv, argc)) {
m_entries.emplace_back(arg, '\0');
m_argv.push_back(m_entries.back().data());
}
@ -412,7 +412,7 @@ void Args::SetArguments(size_t argc, const char **argv) {
auto args = llvm::makeArrayRef(argv, argc);
m_entries.resize(argc);
m_argv.resize(argc + 1);
for (int i = 0; i < args.size(); ++i) {
for (size_t i = 0; i < args.size(); ++i) {
char quote =
((args[i][0] == '\'') || (args[i][0] == '"') || (args[i][0] == '`'))
? args[i][0]

View File

@ -2597,7 +2597,8 @@ void CommandInterpreter::OutputHelpText(Stream &strm, const char *word_text,
for (uint32_t i = 0; i < len; i++) {
if ((text[i] == ' ' && ::strchr((text + i + 1), ' ') &&
chars_left < ::strchr((text + i + 1), ' ') - (text + i)) ||
chars_left < static_cast<uint32_t>(::strchr((text + i + 1), ' ') -
(text + i))) ||
text[i] == '\n') {
chars_left = max_columns - indent_size;
strm.EOL();

View File

@ -129,7 +129,7 @@ void ObjectContainerUniversalMachO::Dump(Stream *s) const {
s->Indent();
const size_t num_archs = GetNumArchitectures();
const size_t num_objects = GetNumObjects();
s->Printf("ObjectContainerUniversalMachO, num_archs = %lu, num_objects = %lu",
s->Printf("ObjectContainerUniversalMachO, num_archs = %zu, num_objects = %zu",
num_archs, num_objects);
uint32_t i;
ArchSpec arch;

View File

@ -124,13 +124,12 @@ bool RegisterContextWindows::CacheAllRegisterValues() {
&m_context)) {
WINERR_IFALL(
WINDOWS_LOG_REGISTERS,
"GetThreadContext failed with error %u while caching register values.",
"GetThreadContext failed with error %lu while caching register values.",
::GetLastError());
return false;
}
WINLOG_IFALL(WINDOWS_LOG_REGISTERS,
"GetThreadContext successfully updated the register values.",
::GetLastError());
"GetThreadContext successfully updated the register values.");
m_context_stale = false;
return true;
}

View File

@ -62,52 +62,72 @@ RegisterInfo g_register_infos[] = {
{ehframe_eax_i386, dwarf_eax_i386, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, lldb_eax_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
{DEFINE_GPR(ebx, nullptr),
{ehframe_ebx_i386, dwarf_ebx_i386, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, lldb_ebx_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
{DEFINE_GPR(ecx, nullptr),
{ehframe_ecx_i386, dwarf_ecx_i386, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, lldb_ecx_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
{DEFINE_GPR(edx, nullptr),
{ehframe_edx_i386, dwarf_edx_i386, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, lldb_edx_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
{DEFINE_GPR(edi, nullptr),
{ehframe_edi_i386, dwarf_edi_i386, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, lldb_edi_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
{DEFINE_GPR(esi, nullptr),
{ehframe_esi_i386, dwarf_esi_i386, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, lldb_esi_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
{DEFINE_GPR(ebp, "fp"),
{ehframe_ebp_i386, dwarf_ebp_i386, LLDB_REGNUM_GENERIC_FP,
LLDB_INVALID_REGNUM, lldb_ebp_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
{DEFINE_GPR(esp, "sp"),
{ehframe_esp_i386, dwarf_esp_i386, LLDB_REGNUM_GENERIC_SP,
LLDB_INVALID_REGNUM, lldb_esp_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
{DEFINE_GPR(eip, "pc"),
{ehframe_eip_i386, dwarf_eip_i386, LLDB_REGNUM_GENERIC_PC,
LLDB_INVALID_REGNUM, lldb_eip_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
{DEFINE_GPR_BIN(eflags, "flags"),
{ehframe_eflags_i386, dwarf_eflags_i386, LLDB_REGNUM_GENERIC_FLAGS,
LLDB_INVALID_REGNUM, lldb_eflags_i386},
nullptr,
nullptr},
nullptr,
nullptr,
0u},
};
static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@ -196,7 +216,7 @@ bool RegisterContextWindows_x86::ReadRegisterHelper(
reg_name);
return false;
}
WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from %s", value,
WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%lx from %s", value,
reg_name);
reg_value.SetUInt32(value);
return true;

View File

@ -54,9 +54,8 @@ struct DebugAttachContext {
}
DebuggerThread::DebuggerThread(DebugDelegateSP debug_delegate)
: m_debug_delegate(debug_delegate), m_image_file(nullptr),
m_debugging_ended_event(nullptr), m_is_shutting_down(false),
m_pid_to_detach(0), m_detached(false) {
: m_debug_delegate(debug_delegate), m_pid_to_detach(0),
m_is_shutting_down(false) {
m_debugging_ended_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr);
}
@ -85,7 +84,7 @@ Error DebuggerThread::DebugLaunch(const ProcessLaunchInfo &launch_info) {
Error DebuggerThread::DebugAttach(lldb::pid_t pid,
const ProcessAttachInfo &attach_info) {
WINLOG_IFALL(WINDOWS_LOG_PROCESS,
"DebuggerThread::DebugAttach attaching to '%u'", (DWORD)pid);
"DebuggerThread::DebugAttach attaching to '%llu'", pid);
Error error;
DebugAttachContext *context = new DebugAttachContext(this, pid, attach_info);
@ -95,7 +94,7 @@ Error DebuggerThread::DebugAttach(lldb::pid_t pid,
if (!error.Success()) {
WINERR_IFALL(WINDOWS_LOG_PROCESS,
"DebugAttach couldn't attach to process '%u'. %s", (DWORD)pid,
"DebugAttach couldn't attach to process '%llu'. %s", pid,
error.AsCString());
}
@ -157,8 +156,8 @@ lldb::thread_result_t DebuggerThread::DebuggerThreadAttachRoutine(
std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DebuggerThread preparing to attach to "
"process '%u' on background thread.",
(DWORD)pid);
"process '%llu' on background thread.",
pid);
if (!DebugActiveProcess((DWORD)pid)) {
Error error(::GetLastError(), eErrorTypeWin32);
@ -233,25 +232,25 @@ Error DebuggerThread::StopDebugging(bool terminate) {
}
}
WINLOG_IFALL(WINDOWS_LOG_PROCESS,
"StopDebugging waiting for detach from process %u to complete.",
pid);
WINLOG_IFALL(
WINDOWS_LOG_PROCESS,
"StopDebugging waiting for detach from process %llu to complete.", pid);
DWORD wait_result = WaitForSingleObject(m_debugging_ended_event, 5000);
if (wait_result != WAIT_OBJECT_0) {
error.SetError(GetLastError(), eErrorTypeWin32);
WINERR_IFALL(WINDOWS_LOG_PROCESS,
"StopDebugging WaitForSingleObject(0x%p, 5000) returned %u",
"StopDebugging WaitForSingleObject(0x%p, 5000) returned %lu",
m_debugging_ended_event, wait_result);
} else {
WINLOG_IFALL(WINDOWS_LOG_PROCESS,
"StopDebugging detach from process %u completed successfully.",
pid);
WINLOG_IFALL(
WINDOWS_LOG_PROCESS,
"StopDebugging detach from process %llu completed successfully.", pid);
}
if (!error.Success()) {
WINERR_IFALL(WINDOWS_LOG_PROCESS, "StopDebugging encountered an error "
"while trying to stop process %u. %s",
"while trying to stop process %llu. %s",
pid, error.AsCString());
}
return error;
@ -280,7 +279,7 @@ void DebuggerThread::FreeProcessHandles() {
}
void DebuggerThread::DebugLoop() {
DEBUG_EVENT dbe = {0};
DEBUG_EVENT dbe = {};
bool should_debug = true;
WINLOG_IFALL(WINDOWS_LOG_EVENT, "Entering WaitForDebugEvent loop");
while (should_debug) {
@ -335,7 +334,7 @@ void DebuggerThread::DebugLoop() {
WINLOGD_IFALL(
WINDOWS_LOG_EVENT,
"DebugLoop calling ContinueDebugEvent(%u, %u, %u) on thread %u.",
"DebugLoop calling ContinueDebugEvent(%lu, %lu, %lu) on thread %lu.",
dbe.dwProcessId, dbe.dwThreadId, continue_status,
::GetCurrentThreadId());
@ -347,8 +346,8 @@ void DebuggerThread::DebugLoop() {
} else {
WINERR_IFALL(
WINDOWS_LOG_EVENT,
"DebugLoop returned FALSE from WaitForDebugEvent. Error = %u",
::GetCurrentThreadId(), ::GetLastError());
"DebugLoop returned FALSE from WaitForDebugEvent. Error = %lu",
::GetLastError());
should_debug = false;
}
@ -371,7 +370,7 @@ DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
info.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT) {
WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION |
WINDOWS_LOG_PROCESS,
"Breakpoint exception is cue to detach from process 0x%x",
"Breakpoint exception is cue to detach from process 0x%lx",
m_pid_to_detach.load());
::DebugActiveProcessStop(m_pid_to_detach);
m_detached = true;
@ -388,8 +387,8 @@ DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
m_active_exception.reset(
new ExceptionRecord(info.ExceptionRecord, thread_id));
WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION,
"HandleExceptionEvent encountered %s chance exception 0x%x on "
"thread 0x%x",
"HandleExceptionEvent encountered %s chance exception 0x%lx on "
"thread 0x%lx",
first_chance ? "first" : "second",
info.ExceptionRecord.ExceptionCode, thread_id);
@ -415,7 +414,7 @@ DWORD
DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info,
DWORD thread_id) {
WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD,
"HandleCreateThreadEvent Thread 0x%x spawned in process %I64u",
"HandleCreateThreadEvent Thread 0x%lx spawned in process %llu",
thread_id, m_process.GetProcessId());
HostThread thread(info.hThread);
thread.GetNativeThread().SetOwnsHandle(false);
@ -456,7 +455,7 @@ DebuggerThread::HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info,
DWORD thread_id) {
WINLOG_IFANY(
WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD,
"HandleExitThreadEvent Thread %u exited with code %u in process %I64u",
"HandleExitThreadEvent Thread %lu exited with code %lu in process %llu",
thread_id, info.dwExitCode, m_process.GetProcessId());
m_debug_delegate->OnExitThread(thread_id, info.dwExitCode);
return DBG_CONTINUE;
@ -466,7 +465,7 @@ DWORD
DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info,
DWORD thread_id) {
WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD,
"HandleExitProcessEvent process %I64u exited with code %u",
"HandleExitProcessEvent process %llu exited with code %lu",
m_process.GetProcessId(), info.dwExitCode);
m_debug_delegate->OnExitProcess(info.dwExitCode);
@ -480,7 +479,7 @@ DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info,
DWORD thread_id) {
if (info.hFile == nullptr) {
// Not sure what this is, so just ignore it.
WINWARN_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent has "
WINWARN_IFALL(WINDOWS_LOG_EVENT, "Inferior %llu - HandleLoadDllEvent has "
"a NULL file handle, returning...",
m_process.GetProcessId());
return DBG_CONTINUE;
@ -510,8 +509,8 @@ DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info,
m_debug_delegate->OnLoadDll(module_spec, load_addr);
} else {
WINERR_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent Error "
"%u occurred calling "
WINERR_IFALL(WINDOWS_LOG_EVENT, "Inferior %llu - HandleLoadDllEvent Error "
"%lu occurred calling "
"GetFinalPathNameByHandle",
m_process.GetProcessId(), ::GetLastError());
}
@ -524,7 +523,7 @@ DWORD
DebuggerThread::HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info,
DWORD thread_id) {
WINLOG_IFALL(WINDOWS_LOG_EVENT,
"HandleUnloadDllEvent process %I64u unloading DLL at addr 0x%p.",
"HandleUnloadDllEvent process %llu unloading DLL at addr 0x%p.",
m_process.GetProcessId(), info.lpBaseOfDll);
m_debug_delegate->OnUnloadDll(
@ -540,8 +539,8 @@ DebuggerThread::HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info,
DWORD
DebuggerThread::HandleRipEvent(const RIP_INFO &info, DWORD thread_id) {
WINERR_IFALL(WINDOWS_LOG_EVENT, "HandleRipEvent encountered error %u "
"(type=%u) in process %I64u thread %u",
WINERR_IFALL(WINDOWS_LOG_EVENT, "HandleRipEvent encountered error %lu "
"(type=%lu) in process %llu thread %lu",
info.dwError, info.dwType, m_process.GetProcessId(), thread_id);
Error error(info.dwError, eErrorTypeWin32);

View File

@ -68,27 +68,31 @@ private:
HostProcess m_process; // The process being debugged.
HostThread m_main_thread; // The main thread of the inferior.
HANDLE m_image_file; // The image file of the process being debugged.
ExceptionRecordSP
m_active_exception; // The current exception waiting to be handled
// The image file of the process being debugged.
HANDLE m_image_file = nullptr;
Predicate<ExceptionResult>
m_exception_pred; // A predicate which gets signalled when an exception
// is finished processing and the debug loop can be
// continued.
// The current exception waiting to be handled
ExceptionRecordSP m_active_exception;
HANDLE m_debugging_ended_event; // An event which gets signalled by the
// debugger thread when it
// exits the debugger loop and is detached from the inferior.
// A predicate which gets signalled when an exception is finished processing
// and the debug loop can be continued.
Predicate<ExceptionResult> m_exception_pred;
std::atomic<DWORD> m_pid_to_detach; // Signals the loop to detach from the
// process (specified by pid).
std::atomic<bool> m_is_shutting_down; // Signals the debug loop to stop
// processing certain types of
// events that block shutdown.
bool m_detached; // Indicates we've detached from the inferior process and the
// debug loop can exit.
// An event which gets signalled by the debugger thread when it exits the
// debugger loop and is detached from the inferior.
HANDLE m_debugging_ended_event = nullptr;
// Signals the loop to detach from the process (specified by pid).
std::atomic<DWORD> m_pid_to_detach;
// Signals the debug loop to stop processing certain types of events that
// block shutdown.
std::atomic<bool> m_is_shutting_down;
// Indicates we've detached from the inferior process and the debug loop can
// exit.
bool m_detached = false;
static lldb::thread_result_t DebuggerThreadLaunchRoutine(void *data);
lldb::thread_result_t
@ -99,5 +103,4 @@ private:
const ProcessAttachInfo &launch_info);
};
}
#endif

View File

@ -94,9 +94,7 @@ namespace lldb_private {
// OS specific types and implementation details from a public header file.
class ProcessWindowsData {
public:
ProcessWindowsData(bool stop_at_entry)
: m_stop_at_entry(stop_at_entry), m_initial_stop_event(nullptr),
m_initial_stop_received(false) {
ProcessWindowsData(bool stop_at_entry) : m_stop_at_entry(stop_at_entry) {
m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr);
}
@ -105,9 +103,9 @@ public:
lldb_private::Error m_launch_error;
lldb_private::DebuggerThreadSP m_debugger;
StopInfoSP m_pending_stop_info;
HANDLE m_initial_stop_event;
HANDLE m_initial_stop_event = nullptr;
bool m_initial_stop_received = false;
bool m_stop_at_entry;
bool m_initial_stop_received;
std::map<lldb::tid_t, HostThread> m_new_threads;
std::set<lldb::tid_t> m_exited_threads;
};
@ -153,8 +151,8 @@ const char *ProcessWindowsLive::GetPluginDescriptionStatic() {
Error ProcessWindowsLive::EnableBreakpointSite(BreakpointSite *bp_site) {
WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS,
"EnableBreakpointSite called with bp_site 0x%p "
"(id=%d, addr=0x%x)",
bp_site->GetID(), bp_site->GetLoadAddress());
"(id=%d, addr=0x%llx)",
bp_site, bp_site->GetID(), bp_site->GetLoadAddress());
Error error = EnableSoftwareBreakpoint(bp_site);
if (!error.Success()) {
@ -167,7 +165,7 @@ Error ProcessWindowsLive::EnableBreakpointSite(BreakpointSite *bp_site) {
Error ProcessWindowsLive::DisableBreakpointSite(BreakpointSite *bp_site) {
WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS,
"DisableBreakpointSite called with bp_site 0x%p "
"(id=%d, addr=0x%x)",
"(id=%d, addr=0x%llx)",
bp_site, bp_site->GetID(), bp_site->GetLoadAddress());
Error error = DisableSoftwareBreakpoint(bp_site);
@ -199,12 +197,13 @@ bool ProcessWindowsLive::UpdateThreadList(ThreadList &old_thread_list,
++continued_threads;
WINLOGV_IFALL(
WINDOWS_LOG_THREAD,
"UpdateThreadList - Thread %u was running and is still running.",
"UpdateThreadList - Thread %llu was running and is still running.",
old_thread_id);
} else {
WINLOGV_IFALL(WINDOWS_LOG_THREAD,
"UpdateThreadList - Thread %u was running and has exited.",
old_thread_id);
WINLOGV_IFALL(
WINDOWS_LOG_THREAD,
"UpdateThreadList - Thread %llu was running and has exited.",
old_thread_id);
++exited_threads;
}
}
@ -218,7 +217,7 @@ bool ProcessWindowsLive::UpdateThreadList(ThreadList &old_thread_list,
++new_size;
++new_threads;
WINLOGV_IFALL(WINDOWS_LOG_THREAD,
"UpdateThreadList - Thread %u is new since last update.",
"UpdateThreadList - Thread %llu is new since last update.",
thread_info.first);
}
@ -250,7 +249,7 @@ Error ProcessWindowsLive::DoLaunch(Module *exe_module,
std::string message = stream.GetString();
result.SetErrorString(message.c_str());
WINERR_IFALL(WINDOWS_LOG_PROCESS, message.c_str());
WINERR_IFALL(WINDOWS_LOG_PROCESS, "%s", message.c_str());
return result;
}
@ -328,7 +327,7 @@ Error ProcessWindowsLive::DoAttachToProcessWithID(
WINLOG_IFALL(
WINDOWS_LOG_PROCESS,
"DoAttachToProcessWithID successfully attached to process with pid=%u",
"DoAttachToProcessWithID successfully attached to process with pid=%lu",
process_id);
// We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the
@ -385,7 +384,7 @@ Error ProcessWindowsLive::DoResume() {
WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_THREAD,
"DoResume resuming %u threads.", m_thread_list.GetSize());
for (int i = 0; i < m_thread_list.GetSize(); ++i) {
for (uint32_t i = 0; i < m_thread_list.GetSize(); ++i) {
auto thread = std::static_pointer_cast<TargetThreadWindowsLive>(
m_thread_list.GetThreadAtIndex(i));
thread->DoResume();
@ -438,7 +437,7 @@ Error ProcessWindowsLive::DoDetach(bool keep_stopped) {
if (private_state != eStateExited && private_state != eStateDetached) {
WINLOG_IFALL(
WINDOWS_LOG_PROCESS,
"DoDetach called for process %I64u while state = %u. Detaching...",
"DoDetach called for process %p while state = %d. Detaching...",
debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
private_state);
error = debugger_thread->StopDebugging(false);
@ -451,8 +450,8 @@ Error ProcessWindowsLive::DoDetach(bool keep_stopped) {
m_session_data.reset();
} else {
WINERR_IFALL(
WINDOWS_LOG_PROCESS, "DoDetach called for process %I64u while state = "
"%u, but cannot destroy in this state.",
WINDOWS_LOG_PROCESS, "DoDetach called for process %p while state = "
"%d, but cannot destroy in this state.",
debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
private_state);
}
@ -487,7 +486,7 @@ Error ProcessWindowsLive::DoDestroy() {
Error error;
if (private_state != eStateExited && private_state != eStateDetached) {
WINLOG_IFALL(
WINDOWS_LOG_PROCESS, "DoDestroy called for process %I64u while state = "
WINDOWS_LOG_PROCESS, "DoDestroy called for process %p while state = "
"%u. Shutting down...",
debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
private_state);
@ -498,8 +497,8 @@ Error ProcessWindowsLive::DoDestroy() {
m_session_data.reset();
} else {
WINERR_IFALL(
WINDOWS_LOG_PROCESS, "DoDestroy called for process %I64u while state = "
"%u, but cannot destroy in this state.",
WINDOWS_LOG_PROCESS, "DoDestroy called for process %p while state = "
"%d, but cannot destroy in this state.",
debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
private_state);
}
@ -554,7 +553,7 @@ void ProcessWindowsLive::RefreshStateAfterStop() {
stop_thread->SetStopInfo(stop_info);
} else {
WINLOG_IFANY(WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_STEP,
"RefreshStateAfterStop single stepping thread %u",
"RefreshStateAfterStop single stepping thread %llu",
stop_thread->GetID());
stop_info = StopInfo::CreateStopReasonToTrace(*stop_thread);
stop_thread->SetStopInfo(stop_info);
@ -616,7 +615,7 @@ void ProcessWindowsLive::RefreshStateAfterStop() {
stop_info = StopInfo::CreateStopReasonWithException(
*stop_thread, desc_stream.str().c_str());
stop_thread->SetStopInfo(stop_info);
WINLOG_IFALL(WINDOWS_LOG_EXCEPTION, desc_stream.str().c_str());
WINLOG_IFALL(WINDOWS_LOG_EXCEPTION, "%s", desc_stream.str().c_str());
return;
}
}
@ -733,7 +732,7 @@ Error ProcessWindowsLive::GetMemoryRegionInfo(lldb::addr_t vm_addr,
if (!m_session_data) {
error.SetErrorString(
"GetMemoryRegionInfo called with no debugging session.");
WINERR_IFALL(WINDOWS_LOG_MEMORY, error.AsCString());
WINERR_IFALL(WINDOWS_LOG_MEMORY, "%s", error.AsCString());
return error;
}
HostProcess process = m_session_data->m_debugger->GetProcess();
@ -741,7 +740,7 @@ Error ProcessWindowsLive::GetMemoryRegionInfo(lldb::addr_t vm_addr,
if (handle == nullptr || handle == LLDB_INVALID_PROCESS) {
error.SetErrorString(
"GetMemoryRegionInfo called with an invalid target process.");
WINERR_IFALL(WINDOWS_LOG_MEMORY, error.AsCString());
WINERR_IFALL(WINDOWS_LOG_MEMORY, "%s", error.AsCString());
return error;
}
@ -749,7 +748,7 @@ Error ProcessWindowsLive::GetMemoryRegionInfo(lldb::addr_t vm_addr,
"GetMemoryRegionInfo getting info for address 0x%I64x", vm_addr);
void *addr = reinterpret_cast<void *>(vm_addr);
MEMORY_BASIC_INFORMATION mem_info = {0};
MEMORY_BASIC_INFORMATION mem_info = {};
SIZE_T result = ::VirtualQueryEx(handle, addr, &mem_info, sizeof(mem_info));
if (result == 0) {
if (::GetLastError() == ERROR_INVALID_PARAMETER) {
@ -812,10 +811,10 @@ Error ProcessWindowsLive::GetMemoryRegionInfo(lldb::addr_t vm_addr,
}
error.SetError(::GetLastError(), eErrorTypeWin32);
WINLOGV_IFALL(WINDOWS_LOG_MEMORY, "Memory region info for address 0x%I64u: "
WINLOGV_IFALL(WINDOWS_LOG_MEMORY, "Memory region info for address %llu: "
"readable=%s, executable=%s, writable=%s",
BOOL_STR(info.GetReadable()), BOOL_STR(info.GetExecutable()),
BOOL_STR(info.GetWritable()));
vm_addr, BOOL_STR(info.GetReadable()),
BOOL_STR(info.GetExecutable()), BOOL_STR(info.GetWritable()));
return error;
}
@ -835,7 +834,7 @@ bool ProcessWindowsLive::CanDebug(lldb::TargetSP target_sp,
void ProcessWindowsLive::OnExitProcess(uint32_t exit_code) {
// No need to acquire the lock since m_session_data isn't accessed.
WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Process %u exited with code %u", GetID(),
WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Process %llu exited with code %u", GetID(),
exit_code);
TargetSP target = m_target_sp.lock();
@ -912,7 +911,7 @@ ProcessWindowsLive::OnDebugException(bool first_chance,
// lldb logs, and then add logging to the process plugin.
if (!m_session_data) {
WINERR_IFANY(WINDOWS_LOG_EXCEPTION, "Debugger thread reported exception "
"0x%x at address 0x%I64x, but there is "
"0x%lx at address 0x%llu, but there is "
"no session.",
record.GetExceptionCode(), record.GetExceptionAddress());
return ExceptionResult::SendToApplication;
@ -949,7 +948,7 @@ ProcessWindowsLive::OnDebugException(bool first_chance,
break;
default:
WINLOG_IFANY(WINDOWS_LOG_EXCEPTION, "Debugger thread reported exception "
"0x%x at address 0x%I64x "
"0x%lx at address 0x%llx "
"(first_chance=%s)",
record.GetExceptionCode(), record.GetExceptionAddress(),
BOOL_STR(first_chance));

View File

@ -26,7 +26,7 @@
#include "llvm/Support/Mutex.h"
#include "plugins/Process/Windows/Common/ProcessWindows.h"
#include "Plugins/Process/Windows/Common/ProcessWindows.h"
class ProcessMonitor;

View File

@ -162,25 +162,21 @@ bool ProcessWinMiniDump::Impl::UpdateThreadList(ThreadList &old_thread_list,
if (m_is_wow64) {
// On Windows, a 32-bit process can run on a 64-bit machine under
// WOW64.
// If the minidump was captured with a 64-bit debugger, then the
// CONTEXT
// we just grabbed from the mini_dump_thread is the one for the 64-bit
// "native" process rather than the 32-bit "guest" process we care
// about.
// In this case, we can get the 32-bit CONTEXT from the TEB (Thread
// Environment Block) of the 64-bit process.
// WOW64. If the minidump was captured with a 64-bit debugger, then
// the CONTEXT we just grabbed from the mini_dump_thread is the one
// for the 64-bit "native" process rather than the 32-bit "guest"
// process we care about. In this case, we can get the 32-bit CONTEXT
// from the TEB (Thread Environment Block) of the 64-bit process.
Error error;
TEB64 wow64teb = {0};
TEB64 wow64teb = {};
m_self->ReadMemory(mini_dump_thread.Teb, &wow64teb, sizeof(wow64teb),
error);
if (error.Success()) {
// Slot 1 of the thread-local storage in the 64-bit TEB points to a
// structure
// that includes the 32-bit CONTEXT (after a ULONG).
// structure that includes the 32-bit CONTEXT (after a ULONG).
// See: https://msdn.microsoft.com/en-us/library/ms681670.aspx
const size_t addr = wow64teb.TlsSlots[1];
Range range = {0};
const lldb::addr_t addr = wow64teb.TlsSlots[1];
Range range = {};
if (FindMemoryRange(addr, &range)) {
lldbassert(range.start <= addr);
const size_t offset = addr - range.start + sizeof(ULONG);
@ -234,7 +230,7 @@ size_t ProcessWinMiniDump::Impl::DoReadMemory(lldb::addr_t addr, void *buf,
// ranges a mini dump typically has, so I'm not sure if searching for the
// appropriate range linearly each time is stupid. Perhaps we should build
// an index for faster lookups.
Range range = {0};
Range range = {};
if (!FindMemoryRange(addr, &range)) {
return 0;
}
@ -275,7 +271,7 @@ Error ProcessWinMiniDump::Impl::GetMemoryRegionInfo(
const MINIDUMP_MEMORY_INFO *next_entry = nullptr;
for (int i = 0; i < list->NumberOfEntries; ++i) {
for (uint64_t i = 0; i < list->NumberOfEntries; ++i) {
const auto entry = reinterpret_cast<const MINIDUMP_MEMORY_INFO *>(
reinterpret_cast<const char *>(list) + list->SizeOfHeader +
i * list->SizeOfEntry);

View File

@ -206,7 +206,7 @@ Error ELFLinuxPrStatus::Parse(DataExtractor &data, ArchSpec &arch) {
ByteOrder byteorder = data.GetByteOrder();
if (GetSize(arch) > data.GetByteSize()) {
error.SetErrorStringWithFormat(
"NT_PRSTATUS size should be %lu, but the remaining bytes are: %" PRIu64,
"NT_PRSTATUS size should be %zu, but the remaining bytes are: %" PRIu64,
GetSize(arch), data.GetByteSize());
return error;
}
@ -271,7 +271,7 @@ Error ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch) {
ByteOrder byteorder = data.GetByteOrder();
if (GetSize(arch) > data.GetByteSize()) {
error.SetErrorStringWithFormat(
"NT_PRPSINFO size should be %lu, but the remaining bytes are: %" PRIu64,
"NT_PRPSINFO size should be %zu, but the remaining bytes are: %" PRIu64,
GetSize(arch), data.GetByteSize());
return error;
}

View File

@ -20,8 +20,9 @@
#include "llvm/Support/Compiler.h"
#if defined(LLVM_ON_WIN32)
// If anyone #includes Host/PosixApi.h later, it will try to typedef pid_t. We
// need to ensure
// this doesn't happen.
// need to ensure this doesn't happen. At the same time, Python.h will also try
// to redefine a bunch of stuff that PosixApi.h defines. So define it all now
// so that PosixApi.h doesn't redefine it.
#define NO_PID_T
#endif
#if defined(__linux__)

View File

@ -4317,6 +4317,8 @@ ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
break;
case clang::Type::Adjusted:
break;
case clang::Type::ObjCTypeParam:
break;
}
// We don't know hot to display this type...
return lldb::eTypeClassOther;
@ -5122,6 +5124,8 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
// pointer type decayed from an array or function type.
case clang::Type::Decayed:
break;
case clang::Type::ObjCTypeParam:
break;
}
count = 0;
return lldb::eEncodingInvalid;
@ -5269,6 +5273,8 @@ lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
// pointer type decayed from an array or function type.
case clang::Type::Decayed:
break;
case clang::Type::ObjCTypeParam:
break;
}
// We don't know hot to display this type...
return lldb::eFormatBytes;

View File

@ -621,7 +621,7 @@ bool OCamlASTContext::DumpTypeValue(
}
if (IsScalarType(type)) {
return data.Dump(s, byte_offset, format, byte_size, 1, UINT64_MAX,
return data.Dump(s, byte_offset, format, byte_size, 1, SIZE_MAX,
LLDB_INVALID_ADDRESS, bitfield_bit_size,
bitfield_bit_offset, exe_scope);
}

View File

@ -288,7 +288,7 @@ lldb::addr_t AllocatedBlock::ReserveBlock(uint32_t size) {
if (log)
log->Printf("[2] AllocatedBlock::ReserveBlock(%p) (size = %u "
"(0x%x)) => offset = 0x%x, %u %u bit chunks - "
"num_chunks %lu",
"num_chunks %zu",
(void *)this, size, size, last_offset, needed_chunks,
m_chunk_size, m_offset_to_chunk_size.size());
addr = m_addr + last_offset;
@ -307,7 +307,7 @@ lldb::addr_t AllocatedBlock::ReserveBlock(uint32_t size) {
if (log)
log->Printf("[3] AllocatedBlock::ReserveBlock(%p) (size = %u "
"(0x%x)) => offset = 0x%x, %u %u bit chunks - "
"num_chunks %lu",
"num_chunks %zu",
(void *)this, size, size, last_offset, needed_chunks,
m_chunk_size, m_offset_to_chunk_size.size());
addr = m_addr + last_offset;
@ -389,7 +389,7 @@ bool AllocatedBlock::FreeBlock(addr_t addr) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
if (log)
log->Printf("AllocatedBlock::FreeBlock(%p) (addr = 0x%16.16" PRIx64
") => %i, num_chunks: %lu",
") => %i, num_chunks: %zu",
(void *)this, (uint64_t)addr, success,
m_offset_to_chunk_size.size());
return success;

View File

@ -1279,6 +1279,7 @@ GetBaseExplainingValue(const Instruction::Operand &operand,
}
}
}
return std::make_pair(nullptr, 0);
}
std::pair<const Instruction::Operand *, int64_t>

View File

@ -45,13 +45,19 @@ void SelectHelper::SetTimeout(const std::chrono::microseconds &timeout) {
m_end_time = steady_clock::time_point(steady_clock::now() + timeout);
}
void SelectHelper::FDSetRead(int fd) { m_fd_map[fd].read_set = true; }
void SelectHelper::FDSetRead(lldb::socket_t fd) {
m_fd_map[fd].read_set = true;
}
void SelectHelper::FDSetWrite(int fd) { m_fd_map[fd].write_set = true; }
void SelectHelper::FDSetWrite(lldb::socket_t fd) {
m_fd_map[fd].write_set = true;
}
void SelectHelper::FDSetError(int fd) { m_fd_map[fd].error_set = true; }
void SelectHelper::FDSetError(lldb::socket_t fd) {
m_fd_map[fd].error_set = true;
}
bool SelectHelper::FDIsSetRead(int fd) const {
bool SelectHelper::FDIsSetRead(lldb::socket_t fd) const {
auto pos = m_fd_map.find(fd);
if (pos != m_fd_map.end())
return pos->second.read_is_set;
@ -59,7 +65,7 @@ bool SelectHelper::FDIsSetRead(int fd) const {
return false;
}
bool SelectHelper::FDIsSetWrite(int fd) const {
bool SelectHelper::FDIsSetWrite(lldb::socket_t fd) const {
auto pos = m_fd_map.find(fd);
if (pos != m_fd_map.end())
return pos->second.write_is_set;
@ -67,7 +73,7 @@ bool SelectHelper::FDIsSetWrite(int fd) const {
return false;
}
bool SelectHelper::FDIsSetError(int fd) const {
bool SelectHelper::FDIsSetError(lldb::socket_t fd) const {
auto pos = m_fd_map.find(fd);
if (pos != m_fd_map.end())
return pos->second.error_is_set;
@ -75,6 +81,14 @@ bool SelectHelper::FDIsSetError(int fd) const {
return false;
}
static void updateMaxFd(llvm::Optional<lldb::socket_t> &vold,
lldb::socket_t vnew) {
if (!vold.hasValue())
vold = vnew;
else
vold = std::max(*vold, vnew);
}
lldb_private::Error SelectHelper::Select() {
lldb_private::Error error;
#ifdef _MSC_VER
@ -85,13 +99,13 @@ lldb_private::Error SelectHelper::Select() {
return lldb_private::Error("Too many file descriptors for select()");
#endif
int max_read_fd = -1;
int max_write_fd = -1;
int max_error_fd = -1;
int max_fd = -1;
llvm::Optional<lldb::socket_t> max_read_fd;
llvm::Optional<lldb::socket_t> max_write_fd;
llvm::Optional<lldb::socket_t> max_error_fd;
llvm::Optional<lldb::socket_t> max_fd;
for (auto &pair : m_fd_map) {
pair.second.PrepareForSelect();
const int fd = pair.first;
const lldb::socket_t fd = pair.first;
#if !defined(__APPLE__) && !defined(_MSC_VER)
lldbassert(fd < FD_SETSIZE);
if (fd >= FD_SETSIZE) {
@ -99,26 +113,21 @@ lldb_private::Error SelectHelper::Select() {
return error;
}
#endif
if (pair.second.read_set) {
max_read_fd = std::max<int>(fd, max_read_fd);
max_fd = std::max<int>(fd, max_fd);
}
if (pair.second.write_set) {
max_write_fd = std::max<int>(fd, max_write_fd);
max_fd = std::max<int>(fd, max_fd);
}
if (pair.second.error_set) {
max_error_fd = std::max<int>(fd, max_error_fd);
max_fd = std::max<int>(fd, max_fd);
}
if (pair.second.read_set)
updateMaxFd(max_read_fd, fd);
if (pair.second.write_set)
updateMaxFd(max_write_fd, fd);
if (pair.second.error_set)
updateMaxFd(max_error_fd, fd);
updateMaxFd(max_fd, fd);
}
if (max_fd == -1) {
if (!max_fd.hasValue()) {
error.SetErrorString("no valid file descriptors");
return error;
}
const int nfds = max_fd + 1;
const unsigned nfds = static_cast<unsigned>(*max_fd) + 1;
fd_set *read_fdset_ptr = nullptr;
fd_set *write_fdset_ptr = nullptr;
fd_set *error_fdset_ptr = nullptr;
@ -130,15 +139,15 @@ lldb_private::Error SelectHelper::Select() {
llvm::SmallVector<fd_set, 1> write_fdset;
llvm::SmallVector<fd_set, 1> error_fdset;
if (max_read_fd >= 0) {
if (max_read_fd.hasValue()) {
read_fdset.resize((nfds / FD_SETSIZE) + 1);
read_fdset_ptr = read_fdset.data();
}
if (max_write_fd >= 0) {
if (max_write_fd.hasValue()) {
write_fdset.resize((nfds / FD_SETSIZE) + 1);
write_fdset_ptr = write_fdset.data();
}
if (max_error_fd >= 0) {
if (max_error_fd.hasValue()) {
error_fdset.resize((nfds / FD_SETSIZE) + 1);
error_fdset_ptr = error_fdset.data();
}
@ -153,15 +162,15 @@ lldb_private::Error SelectHelper::Select() {
fd_set write_fdset;
fd_set error_fdset;
if (max_read_fd >= 0) {
if (max_read_fd.hasValue()) {
FD_ZERO(&read_fdset);
read_fdset_ptr = &read_fdset;
}
if (max_write_fd >= 0) {
if (max_write_fd.hasValue()) {
FD_ZERO(&write_fdset);
write_fdset_ptr = &write_fdset;
}
if (max_error_fd >= 0) {
if (max_error_fd.hasValue()) {
FD_ZERO(&error_fdset);
error_fdset_ptr = &error_fdset;
}
@ -170,7 +179,7 @@ lldb_private::Error SelectHelper::Select() {
// Set the FD bits in the fdsets for read/write/error
//----------------------------------------------------------------------
for (auto &pair : m_fd_map) {
const int fd = pair.first;
const lldb::socket_t fd = pair.first;
if (pair.second.read_set)
FD_SET(fd, read_fdset_ptr);

View File

@ -189,8 +189,7 @@ bool CMICmdCmdGdbInfo::GetPrintFn(const CMIUtilString &vrPrintFnName,
// Throws: None.
//--
bool CMICmdCmdGdbInfo::PrintFnSharedLibrary() {
CMICmnStreamStdout &rStdout = CMICmnStreamStdout::Instance();
bool bOk = rStdout.TextToStdout(
bool bOk = CMICmnStreamStdout::TextToStdout(
"~\"From To Syms Read Shared Object Library\"");
CMICmnLLDBDebugSessionInfo &rSessionInfo(
@ -224,7 +223,7 @@ bool CMICmdCmdGdbInfo::PrintFnSharedLibrary() {
}
}
bOk = bOk &&
rStdout.TextToStdout(CMIUtilString::Format(
CMICmnStreamStdout::TextToStdout(CMIUtilString::Format(
"~\"0x%016" PRIx64 "\t0x%016" PRIx64 "\t%s\t\t%s\"", addrLoadS,
addrLoadS + addrLoadSize, strHasSymbols.c_str(),
strModuleFullPath.c_str()));

View File

@ -13,10 +13,11 @@
#include <eh.h>
#include <inttypes.h>
#include <io.h>
#include <lldb/Host/HostGetOpt.h>
#include <lldb/Host/windows/Windows.h>
#include <signal.h>
#include "lldb/Host/HostGetOpt.h"
#include "lldb/Host/windows/windows.h"
// This is not used by MI
struct timeval {
long tv_sec;