Index: include/lldb/Core/DataEncoder.h =================================================================== --- include/lldb/Core/DataEncoder.h +++ include/lldb/Core/DataEncoder.h @@ -357,7 +357,7 @@ /// The number of bytes that this object now contains. //------------------------------------------------------------------ uint32_t - SetData (const void *bytes, uint32_t length, lldb::ByteOrder byte_order); + SetData (void *bytes, uint32_t length, lldb::ByteOrder byte_order); //------------------------------------------------------------------ /// Adopt a subset of shared data in \a data_sp. Index: include/lldb/Interpreter/CommandObject.h =================================================================== --- include/lldb/Interpreter/CommandObject.h +++ include/lldb/Interpreter/CommandObject.h @@ -195,7 +195,7 @@ static lldb::CommandArgumentType LookupArgumentName (const char *arg_name); - static ArgumentTableEntry * + static const ArgumentTableEntry * FindArgumentDataByType (lldb::CommandArgumentType arg_type); int Index: source/Commands/CommandObjectMemory.cpp =================================================================== --- source/Commands/CommandObjectMemory.cpp +++ source/Commands/CommandObjectMemory.cpp @@ -534,7 +534,7 @@ clang::TypeDecl *tdecl = target->GetPersistentVariables().GetPersistentType(ConstString(lookup_type_name)); if (tdecl) { - clang_ast_type.SetClangType(&tdecl->getASTContext(),(lldb::clang_type_t)tdecl->getTypeForDecl()); + clang_ast_type.SetClangType(&tdecl->getASTContext(),(const lldb::clang_type_t)tdecl->getTypeForDecl()); } } Index: source/Core/DataBufferHeap.cpp =================================================================== --- source/Core/DataBufferHeap.cpp +++ source/Core/DataBufferHeap.cpp @@ -106,7 +106,7 @@ void DataBufferHeap::AppendData (const void *src, uint64_t src_len) { - m_data.insert(m_data.end(), (uint8_t *)src, (uint8_t *)src + src_len); + m_data.insert(m_data.end(), (const uint8_t *)src, (const uint8_t *)src + src_len); } void Index: source/Core/DataEncoder.cpp =================================================================== --- source/Core/DataEncoder.cpp +++ source/Core/DataEncoder.cpp @@ -21,36 +21,36 @@ using namespace lldb_private; static inline void -WriteInt16(const unsigned char* ptr, unsigned offset, uint16_t value) +WriteInt16(unsigned char* ptr, unsigned offset, uint16_t value) { *(uint16_t *)(ptr + offset) = value; } static inline void -WriteInt32 (const unsigned char* ptr, unsigned offset, uint32_t value) +WriteInt32 (unsigned char* ptr, unsigned offset, uint32_t value) { *(uint32_t *)(ptr + offset) = value; } static inline void -WriteInt64(const unsigned char* ptr, unsigned offset, uint64_t value) +WriteInt64(unsigned char* ptr, unsigned offset, uint64_t value) { *(uint64_t *)(ptr + offset) = value; } static inline void -WriteSwappedInt16(const unsigned char* ptr, unsigned offset, uint16_t value) +WriteSwappedInt16(unsigned char* ptr, unsigned offset, uint16_t value) { *(uint16_t *)(ptr + offset) = llvm::ByteSwap_16(value); } static inline void -WriteSwappedInt32 (const unsigned char* ptr, unsigned offset, uint32_t value) +WriteSwappedInt32 (unsigned char* ptr, unsigned offset, uint32_t value) { *(uint32_t *)(ptr + offset) = llvm::ByteSwap_32(value); } static inline void -WriteSwappedInt64(const unsigned char* ptr, unsigned offset, uint64_t value) +WriteSwappedInt64(unsigned char* ptr, unsigned offset, uint64_t value) { *(uint64_t *)(ptr + offset) = llvm::ByteSwap_64(value); } @@ -153,7 +153,7 @@ // any data extracted will be endian swapped. //---------------------------------------------------------------------- uint32_t -DataEncoder::SetData (const void *bytes, uint32_t length, ByteOrder endian) +DataEncoder::SetData (void *bytes, uint32_t length, ByteOrder endian) { m_byte_order = endian; m_data_sp.reset(); Index: source/Core/FormatEntity.cpp =================================================================== --- source/Core/FormatEntity.cpp +++ source/Core/FormatEntity.cpp @@ -1299,13 +1299,11 @@ // Watch for the special "tid" format... if (entry.printf_format == "tid") { - bool handled = false; Target &target = thread->GetProcess()->GetTarget(); ArchSpec arch (target.GetArchitecture ()); llvm::Triple::OSType ostype = arch.IsValid() ? arch.GetTriple().getOS() : llvm::Triple::UnknownOS; if ((ostype == llvm::Triple::FreeBSD) || (ostype == llvm::Triple::Linux)) { - handled = true; format = "%" PRIu64; } } Index: source/DataFormatters/StringPrinter.cpp =================================================================== --- source/DataFormatters/StringPrinter.cpp +++ source/DataFormatters/StringPrinter.cpp @@ -181,12 +181,13 @@ break; default: if (isprint(*buffer)) - retval = {buffer,1}; + retval = {buffer,1}; else { - retval = { new uint8_t[5],4,[] (const uint8_t* c) {delete[] c;} }; - sprintf((char*)retval.GetBytes(),"\\x%02x",*buffer); - break; + uint8_t* data = new uint8_t[5]; + sprintf((char*)data,"\\x%02x",*buffer); + retval = {data, 4, [] (const uint8_t* c) {delete[] c;} }; + break; } } @@ -288,8 +289,9 @@ retval = {buffer,utf8_encoded_len}; else { - retval = { new uint8_t[11],10,[] (const uint8_t* c) {delete[] c;} }; - sprintf((char*)retval.GetBytes(),"\\U%08x",codepoint); + uint8_t* data = new uint8_t[11]; + sprintf((char*)data,"\\U%08x",codepoint); + retval = { data,10,[] (const uint8_t* c) {delete[] c;} }; break; } } @@ -352,8 +354,8 @@ sourceSize = bufferSPSize/(origin_encoding / 4); } - SourceDataType *data_ptr = (SourceDataType*)data.GetDataStart(); - SourceDataType *data_end_ptr = data_ptr + sourceSize; + const SourceDataType *data_ptr = (const SourceDataType*)data.GetDataStart(); + const SourceDataType *data_end_ptr = data_ptr + sourceSize; while (data_ptr < data_end_ptr) { @@ -365,7 +367,7 @@ data_ptr++; } - data_ptr = (SourceDataType*)data.GetDataStart(); + data_ptr = (const SourceDataType*)data.GetDataStart(); lldb::DataBufferSP utf8_data_buffer_sp; UTF8* utf8_data_ptr = nullptr; @@ -376,7 +378,7 @@ utf8_data_buffer_sp.reset(new DataBufferHeap(4*bufferSPSize,0)); utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes(); utf8_data_end_ptr = utf8_data_ptr + utf8_data_buffer_sp->GetByteSize(); - ConvertFunction ( (const SourceDataType**)&data_ptr, data_end_ptr, &utf8_data_ptr, utf8_data_end_ptr, lenientConversion ); + ConvertFunction ( &data_ptr, data_end_ptr, &utf8_data_ptr, utf8_data_end_ptr, lenientConversion ); utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes(); // needed because the ConvertFunction will change the value of the data_ptr } else @@ -449,7 +451,6 @@ { assert(options.GetStream() && "need a Stream to print the string to"); Error my_error; - size_t my_data_read; ProcessSP process_sp(options.GetProcessSP()); @@ -467,7 +468,7 @@ lldb::DataBufferSP buffer_sp(new DataBufferHeap(size,0)); - my_data_read = process_sp->ReadCStringFromMemory(options.GetLocation(), (char*)buffer_sp->GetBytes(), size, my_error); + process_sp->ReadCStringFromMemory(options.GetLocation(), (char*)buffer_sp->GetBytes(), size, my_error); if (my_error.Fail()) return false; @@ -568,11 +569,10 @@ Error error; char *buffer = reinterpret_cast(buffer_sp->GetBytes()); - size_t data_read = 0; if (needs_zero_terminator) - data_read = process_sp->ReadStringFromMemory(options.GetLocation(), buffer, bufferSPSize, error, type_width); + process_sp->ReadStringFromMemory(options.GetLocation(), buffer, bufferSPSize, error, type_width); else - data_read = process_sp->ReadMemoryFromInferior(options.GetLocation(), (char*)buffer_sp->GetBytes(), bufferSPSize, error); + process_sp->ReadMemoryFromInferior(options.GetLocation(), (char*)buffer_sp->GetBytes(), bufferSPSize, error); if (error.Fail()) { Index: source/Expression/IRExecutionUnit.cpp =================================================================== --- source/Expression/IRExecutionUnit.cpp +++ source/Expression/IRExecutionUnit.cpp @@ -605,8 +605,11 @@ uint8_t *return_value = m_default_mm_ap->allocateDataSection(Size, Alignment, SectionID, SectionName, IsReadOnly); + uint32_t permissions = lldb::ePermissionsReadable; + if (IsReadOnly) + permissions |= lldb::ePermissionsWritable; m_parent.m_records.push_back(AllocationRecord((uintptr_t)return_value, - lldb::ePermissionsReadable | (IsReadOnly ? 0 : lldb::ePermissionsWritable), + permissions, GetSectionTypeFromSectionName (SectionName, AllocationKind::Data), Size, Alignment, Index: source/Host/common/Editline.cpp =================================================================== --- source/Host/common/Editline.cpp +++ source/Host/common/Editline.cpp @@ -711,7 +711,7 @@ unsigned char Editline::DeleteNextCharCommand (int ch) { - LineInfoW * info = (LineInfoW *)el_wline (m_editline); + LineInfoW * info = const_cast(el_wline (m_editline)); // Just delete the next character normally if possible if (info->cursor < info->lastchar) @@ -755,7 +755,7 @@ unsigned char Editline::DeletePreviousCharCommand (int ch) { - LineInfoW * info = (LineInfoW *)el_wline (m_editline); + LineInfoW * info = const_cast(el_wline (m_editline)); // Just delete the previous character normally when not at the start of a line if (info->cursor > info->buffer) @@ -861,7 +861,7 @@ StringList lines = GetInputAsStringList (m_current_line_index + 1); // Determine the cursor position - LineInfoW * info = (LineInfoW *)el_wline (m_editline); + LineInfoW * info = const_cast(el_wline (m_editline)); int cursor_position = info->cursor - info->buffer; int indent_correction = m_fix_indentation_callback (this, lines, cursor_position, m_fix_indentation_callback_baton); @@ -887,7 +887,7 @@ el_winsertstr (m_editline, m_input_lines[m_current_line_index].c_str()); if (m_revert_cursor_index >= 0) { - LineInfoW * info = (LineInfoW *)el_wline (m_editline); + LineInfoW * info = const_cast(el_wline (m_editline)); info->cursor = info->buffer + m_revert_cursor_index; if (info->cursor > info->lastchar) { Index: source/Host/common/Symbols.cpp =================================================================== --- source/Host/common/Symbols.cpp +++ source/Host/common/Symbols.cpp @@ -136,7 +136,7 @@ "LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)", exec_fspec ? exec_fspec->GetFilename().AsCString ("") : "", arch ? arch->GetArchitectureName() : "", - uuid); + (void*)uuid); FileSpec symbol_fspec; // First try and find the dSYM in the same directory as the executable or in @@ -159,7 +159,7 @@ "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)", exec_fspec ? exec_fspec->GetFilename().AsCString ("") : "", arch ? arch->GetArchitectureName() : "", - uuid); + (void*)uuid); FileSpec objfile_fspec; ModuleSpecList module_specs; Index: source/Interpreter/Args.cpp =================================================================== --- source/Interpreter/Args.cpp +++ source/Interpreter/Args.cpp @@ -1138,7 +1138,7 @@ return false; bool is_positional = true; - char *cptr = (char *) arg; + const char *cptr = arg; if (cptr[0] == '%') { Index: source/Interpreter/CommandInterpreter.cpp =================================================================== --- source/Interpreter/CommandInterpreter.cpp +++ source/Interpreter/CommandInterpreter.cpp @@ -2247,7 +2247,7 @@ } cmd_args.Clear(); - cmd_args.SetArguments (new_args.GetArgumentCount(), (const char **) new_args.GetArgumentVector()); + cmd_args.SetArguments (new_args.GetArgumentCount(), new_args.GetConstArgumentVector()); } else { @@ -2258,7 +2258,7 @@ if (wants_raw_input) { cmd_args.Clear(); - cmd_args.SetArguments (new_args.GetArgumentCount(), (const char **) new_args.GetArgumentVector()); + cmd_args.SetArguments (new_args.GetArgumentCount(), new_args.GetConstArgumentVector()); } return; } @@ -2274,7 +2274,7 @@ int position = 0; // Any string that isn't an argument position, i.e. '%' followed by an integer, gets a position // of zero. - char *cptr = (char *) in_string; + const char *cptr = in_string; // Does it start with '%' if (cptr[0] == '%') Index: source/Interpreter/CommandObject.cpp =================================================================== --- source/Interpreter/CommandObject.cpp +++ source/Interpreter/CommandObject.cpp @@ -506,14 +506,14 @@ return nullptr; } -CommandObject::ArgumentTableEntry * +const CommandObject::ArgumentTableEntry * CommandObject::FindArgumentDataByType (CommandArgumentType arg_type) { const ArgumentTableEntry *table = CommandObject::GetArgumentTable(); for (int i = 0; i < eArgTypeLastArg; ++i) if (table[i].arg_type == arg_type) - return (ArgumentTableEntry *) &(table[i]); + return &(table[i]); return nullptr; } @@ -522,7 +522,7 @@ CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter) { const ArgumentTableEntry* table = CommandObject::GetArgumentTable(); - ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]); + const ArgumentTableEntry *entry = &(table[arg_type]); // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... @@ -556,7 +556,7 @@ const char * CommandObject::GetArgumentName (CommandArgumentType arg_type) { - ArgumentTableEntry *entry = (ArgumentTableEntry *) &(CommandObject::GetArgumentTable()[arg_type]); + const ArgumentTableEntry *entry = &(CommandObject::GetArgumentTable()[arg_type]); // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... Index: source/Interpreter/Options.cpp =================================================================== --- source/Interpreter/Options.cpp +++ source/Interpreter/Options.cpp @@ -944,7 +944,7 @@ lldb::CommandArgumentType option_arg_type = opt_defs[opt_defs_index].argument_type; if (option_arg_type != eArgTypeNone) { - CommandObject::ArgumentTableEntry *arg_entry = CommandObject::FindArgumentDataByType (opt_defs[opt_defs_index].argument_type); + const CommandObject::ArgumentTableEntry *arg_entry = CommandObject::FindArgumentDataByType (opt_defs[opt_defs_index].argument_type); if (arg_entry) completion_mask = arg_entry->completion_type; } Index: source/Interpreter/ScriptInterpreterPython.cpp =================================================================== --- source/Interpreter/ScriptInterpreterPython.cpp +++ source/Interpreter/ScriptInterpreterPython.cpp @@ -382,6 +382,13 @@ m_session_is_active = false; } +static PyObject * +PyFile_FromFile_Const(FILE *fp, const char *name, const char *mode, int (*close)(FILE *)) +{ + // Read through the Python source, doesn't seem to modify these strings + return PyFile_FromFile(fp, const_cast(name), const_cast(mode), close); +} + bool ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags, FILE *in, @@ -447,7 +454,7 @@ { m_saved_stdin.Reset(sys_module_dict.GetItemForKey("stdin")); // This call can deadlock your process if the file is locked - PyObject *new_file = PyFile_FromFile (in, (char *) "", (char *) "r", nullptr); + PyObject *new_file = PyFile_FromFile_Const (in, "", "r", nullptr); sys_module_dict.SetItemForKey ("stdin", new_file); Py_DECREF (new_file); } @@ -459,7 +466,7 @@ { m_saved_stdout.Reset(sys_module_dict.GetItemForKey("stdout")); - PyObject *new_file = PyFile_FromFile (out, (char *) "", (char *) "w", nullptr); + PyObject *new_file = PyFile_FromFile_Const (out, "", "w", nullptr); sys_module_dict.SetItemForKey ("stdout", new_file); Py_DECREF (new_file); } @@ -472,7 +479,7 @@ { m_saved_stderr.Reset(sys_module_dict.GetItemForKey("stderr")); - PyObject *new_file = PyFile_FromFile (err, (char *) "", (char *) "w", nullptr); + PyObject *new_file = PyFile_FromFile_Const (err, "", "w", nullptr); sys_module_dict.SetItemForKey ("stderr", new_file); Py_DECREF (new_file); } Index: source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp =================================================================== --- source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp +++ source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp @@ -263,10 +263,9 @@ // update the argument with the target pointer //XXX: This is a gross hack for getting around the const - *((size_t*)(&arg.value)) = sp; + *const_cast(&arg.value) = sp; } - #if HEX_ABI_DEBUG // print the original stack pointer printf( "sp : %04" PRIx64 " \n", sp ); Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -1428,7 +1428,7 @@ { if (log == NULL) return; - uint8_t *u = (uint8_t *)uuid.GetBytes(); + const uint8_t *u = (const uint8_t *)uuid.GetBytes(); if (address == LLDB_INVALID_ADDRESS) { Index: source/Plugins/Instruction/ARM/EmulationStateARM.cpp =================================================================== --- source/Plugins/Instruction/ARM/EmulationStateARM.cpp +++ source/Plugins/Instruction/ARM/EmulationStateARM.cpp @@ -233,7 +233,7 @@ bool success; EmulationStateARM *pseudo_state = (EmulationStateARM *) baton; - uint64_t value = *((uint64_t *) dst); + uint64_t value = *((const uint64_t *) dst); success = pseudo_state->StoreToPseudoAddress (addr, value, length); if (success) return length; Index: source/Plugins/Platform/Android/AdbClient.cpp =================================================================== --- source/Plugins/Platform/Android/AdbClient.cpp +++ source/Plugins/Platform/Android/AdbClient.cpp @@ -178,7 +178,7 @@ if (error.Fail ()) return error; - int packet_len = 0; + unsigned int packet_len = 0; sscanf (buffer, "%x", &packet_len); std::string result (packet_len, 0); m_conn.Read (&result[0], packet_len, kConnTimeout, status, &error); Index: source/Plugins/Platform/MacOSX/PlatformDarwin.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1174,7 +1174,7 @@ // /bin/sh re-exec's itself as /bin/bash requiring another resume. // But it only does this if the COMMAND_MODE environment variable // is set to "legacy". - char * const *envp = (char * const*)launch_info.GetEnvironmentEntries().GetConstArgumentVector(); + const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector(); if (envp != NULL) { for (int i = 0; envp[i] != NULL; i++) @@ -1346,7 +1346,7 @@ } return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; -}; +} FileSpec PlatformDarwin::FindSDKInXcodeForModules (SDKType sdk_type, Index: source/Plugins/Platform/POSIX/PlatformPOSIX.cpp =================================================================== --- source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -665,9 +665,9 @@ if (m_options.get()) { OptionGroupOptions* options = m_options.get(); - OptionGroupPlatformRSync* m_rsync_options = (OptionGroupPlatformRSync*)options->GetGroupWithOption('r'); - OptionGroupPlatformSSH* m_ssh_options = (OptionGroupPlatformSSH*)options->GetGroupWithOption('s'); - OptionGroupPlatformCaching* m_cache_options = (OptionGroupPlatformCaching*)options->GetGroupWithOption('c'); + const OptionGroupPlatformRSync* m_rsync_options = (OptionGroupPlatformRSync*)options->GetGroupWithOption('r'); + const OptionGroupPlatformSSH* m_ssh_options = (OptionGroupPlatformSSH*)options->GetGroupWithOption('s'); + const OptionGroupPlatformCaching* m_cache_options = (OptionGroupPlatformCaching*)options->GetGroupWithOption('c'); if (m_rsync_options->m_rsync) { Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -3003,7 +3003,6 @@ lldb::tid_t deferred_signal_tid = LLDB_INVALID_THREAD_ID; lldb::tid_t deferred_signal_skip_tid = LLDB_INVALID_THREAD_ID; - int deferred_signo = 0; NativeThreadProtocolSP deferred_signal_thread_sp; bool stepping = false; bool software_single_step = !SupportHardwareSingleStepping(); @@ -3100,7 +3099,6 @@ { deferred_signal_tid = thread_sp->GetID (); deferred_signal_thread_sp = thread_sp; - deferred_signo = SIGSTOP; } break; Index: source/Plugins/Process/Linux/ProcessLinux.h =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.h +++ source/Plugins/Process/Linux/ProcessLinux.h @@ -53,7 +53,7 @@ //------------------------------------------------------------------ ProcessLinux(Target& target, Listener &listener, - FileSpec *core_file); + const FileSpec *core_file); Error DoDetach(bool keep_stopped) override; @@ -98,7 +98,7 @@ private: - FileSpec *m_core_file; + const FileSpec *m_core_file; // Flag to avoid recursion when stopping all threads. bool m_stopping_threads; Index: source/Plugins/Process/Linux/ProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.cpp +++ source/Plugins/Process/Linux/ProcessLinux.cpp @@ -49,7 +49,7 @@ ProcessSP ProcessLinux::CreateInstance(Target &target, Listener &listener, const FileSpec *core_file) { - return ProcessSP(new ProcessLinux(target, listener, (FileSpec *)core_file)); + return ProcessSP(new ProcessLinux(target, listener, core_file)); } void @@ -68,7 +68,7 @@ //------------------------------------------------------------------------------ // Constructors and destructors. -ProcessLinux::ProcessLinux(Target& target, Listener &listener, FileSpec *core_file) +ProcessLinux::ProcessLinux(Target& target, Listener &listener, const FileSpec *core_file) : ProcessPOSIX(target, listener, GetStaticLinuxSignalsSP ()), m_core_file(core_file), m_stopping_threads(false) { #if 0 Index: source/Plugins/Process/Linux/ProcessMonitor.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessMonitor.cpp +++ source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -376,7 +376,7 @@ (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_SHORT) && size <= POSIX_LOG_MEMORY_SHORT_BYTES))) log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, - (void*)vm_addr, *(unsigned long*)src, *(unsigned long*)buff); + (void*)vm_addr, *(const unsigned long*)src, *(const unsigned long*)buff); } vm_addr += word_size; Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -259,7 +259,7 @@ strm.Printf("<%4" PRIu64 "> send packet: %.*s", (uint64_t)bytes_written, (int)binary_start_offset, packet_data); const uint8_t *p; // Print binary data exactly as sent - for (p = (uint8_t*)packet_data + binary_start_offset; *p != '#'; ++p) + for (p = (const uint8_t*)packet_data + binary_start_offset; *p != '#'; ++p) strm.Printf("\\x%2.2x", *p); // Print the checksum strm.Printf("%*s", (int)3, p); @@ -772,48 +772,40 @@ llvm::SmallString named_pipe_path; Pipe port_pipe; - bool listen = false; - if (host_and_port[0]) + if (host_and_port[0] && in_port == 0) { // Create a temporary file to get the stdout/stderr and redirect the // output of the command into this file. We will later read this file // if all goes well and fill the data into "command_output_ptr" - if (in_port == 0) + // Binding to port zero, we need to figure out what port it ends up + // using using a named pipe... + error = port_pipe.CreateWithUniqueName("debugserver-named-pipe", false, named_pipe_path); + if (error.Success()) { - // Binding to port zero, we need to figure out what port it ends up - // using using a named pipe... - error = port_pipe.CreateWithUniqueName("debugserver-named-pipe", false, named_pipe_path); - if (error.Success()) - { - debugserver_args.AppendArgument("--named-pipe"); - debugserver_args.AppendArgument(named_pipe_path.c_str()); - } - else + debugserver_args.AppendArgument("--named-pipe"); + debugserver_args.AppendArgument(named_pipe_path.c_str()); + } + else + { + if (log) + log->Printf("GDBRemoteCommunication::%s() " + "named pipe creation failed: %s", + __FUNCTION__, error.AsCString()); + // let's try an unnamed pipe + error = port_pipe.CreateNew(true); + if (error.Fail()) { if (log) log->Printf("GDBRemoteCommunication::%s() " - "named pipe creation failed: %s", + "unnamed pipe creation failed: %s", __FUNCTION__, error.AsCString()); - // let's try an unnamed pipe - error = port_pipe.CreateNew(true); - if (error.Fail()) - { - if (log) - log->Printf("GDBRemoteCommunication::%s() " - "unnamed pipe creation failed: %s", - __FUNCTION__, error.AsCString()); - return error; - } - int write_fd = port_pipe.GetWriteFileDescriptor(); - debugserver_args.AppendArgument("--pipe"); - debugserver_args.AppendArgument(std::to_string(write_fd).c_str()); - launch_info.AppendCloseFileAction(port_pipe.GetReadFileDescriptor()); + return error; } - } - else - { - listen = true; + int write_fd = port_pipe.GetWriteFileDescriptor(); + debugserver_args.AppendArgument("--pipe"); + debugserver_args.AppendArgument(std::to_string(write_fd).c_str()); + launch_info.AppendCloseFileAction(port_pipe.GetReadFileDescriptor()); } } else Index: source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -677,15 +677,16 @@ // This means buffer will be a little more than 2x larger than necessary but we resize // it down once we've extracted all hex ascii chars from the packet. DataBufferHeap buffer (G_packet_len, 0); + + const uint32_t bytes_extracted = response.GetHexBytes (buffer.GetBytes(), + buffer.GetByteSize(), + '\xcc'); + DataExtractor restore_data (buffer.GetBytes(), buffer.GetByteSize(), m_reg_data.GetByteOrder(), m_reg_data.GetAddressByteSize()); - - const uint32_t bytes_extracted = response.GetHexBytes ((void *)restore_data.GetDataStart(), - restore_data.GetByteSize(), - '\xcc'); - + if (bytes_extracted < restore_data.GetByteSize()) restore_data.SetData(restore_data.GetDataStart(), bytes_extracted, m_reg_data.GetByteOrder()); Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4094,18 +4094,18 @@ if (!child->name) continue; - if (strcmp ((char*)child->name, "library") != 0) + if (strcmp ((const char*)child->name, "library") != 0) continue; GDBLoadedModuleInfoList::LoadedModuleInfo module; for (xmlAttrPtr prop = child->properties; prop; prop=prop->next) { - if (strcmp ((char*)prop->name, "name") == 0) + if (strcmp ((const char*)prop->name, "name") == 0) module.set_name (xmlExGetTextContent (prop)); // the address of the link_map struct. - if (strcmp ((char*)prop->name, "lm") == 0) + if (strcmp ((const char*)prop->name, "lm") == 0) { std::string val = xmlExGetTextContent (prop); if (val.length() > 2) @@ -4116,7 +4116,7 @@ } // the displacement as read from the field 'l_addr' of the link_map struct. - if (strcmp ((char*)prop->name, "l_addr") == 0) + if (strcmp ((const char*)prop->name, "l_addr") == 0) { std::string val = xmlExGetTextContent (prop); if (val.length() > 2) @@ -4127,7 +4127,7 @@ } // the memory address of the libraries PT_DYAMIC section. - if (strcmp ((char*)prop->name, "l_ld") == 0) + if (strcmp ((const char*)prop->name, "l_ld") == 0) { std::string val = xmlExGetTextContent (prop); if (val.length() > 2) Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -191,7 +191,7 @@ // Set the string value to also be the data for inlined cstr form values only // so we can tell the difference between DW_FORM_string and DW_FORM_strp form // values; - m_value.data = (uint8_t*)m_value.value.cstr; break; + m_value.data = (const uint8_t*)m_value.value.cstr; break; case DW_FORM_exprloc: case DW_FORM_block: m_value.value.uval = data.GetULEB128(offset_ptr); is_block = true; break; case DW_FORM_block1: m_value.value.uval = data.GetU8(offset_ptr); is_block = true; break; Index: source/Plugins/SymbolFile/DWARF/NameToDIE.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/NameToDIE.cpp +++ source/Plugins/SymbolFile/DWARF/NameToDIE.cpp @@ -69,7 +69,7 @@ for (uint32_t i=0; iPrintf("%p: {0x%8.8x} \"%s\"\n", (void *)cstr, m_map.GetValueAtIndexUnchecked(i), cstr); + s->Printf("%p: {0x%8.8x} \"%s\"\n", (const void *)cstr, m_map.GetValueAtIndexUnchecked(i), cstr); } } Index: source/Symbol/CompactUnwindInfo.cpp =================================================================== --- source/Symbol/CompactUnwindInfo.cpp +++ source/Symbol/CompactUnwindInfo.cpp @@ -101,7 +101,7 @@ UNWIND_X86_64_REG_R15 = 5, UNWIND_X86_64_REG_RBP = 6, }; -}; +} #ifndef UNWIND_SECOND_LEVEL_REGULAR Index: source/Symbol/DWARFCallFrameInfo.cpp =================================================================== --- source/Symbol/DWARFCallFrameInfo.cpp +++ source/Symbol/DWARFCallFrameInfo.cpp @@ -804,7 +804,7 @@ // the DWARF expression. reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset); uint32_t block_len = (uint32_t)m_cfi_data.GetULEB128(&offset); - const uint8_t *block_data = (uint8_t *)m_cfi_data.GetData(&offset, block_len); + const uint8_t *block_data = (const uint8_t *)m_cfi_data.GetData(&offset, block_len); reg_location.SetAtDWARFExpression(block_data, block_len); row->SetRegisterInfo (reg_num, reg_location); @@ -858,7 +858,7 @@ // evaluation stack prior to execution of the DWARF expression. reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset); uint32_t block_len = (uint32_t)m_cfi_data.GetULEB128(&offset); - const uint8_t* block_data = (uint8_t*)m_cfi_data.GetData(&offset, block_len); + const uint8_t* block_data = (const uint8_t*)m_cfi_data.GetData(&offset, block_len); //#if defined(__i386__) || defined(__x86_64__) // // The EH frame info for EIP and RIP contains code that looks for traps to // // be a specific type and increments the PC. Index: source/Symbol/Symtab.cpp =================================================================== --- source/Symbol/Symtab.cpp +++ source/Symbol/Symtab.cpp @@ -210,8 +210,8 @@ static int CompareSymbolID (const void *key, const void *p) { - const user_id_t match_uid = *(user_id_t*) key; - const user_id_t symbol_uid = ((Symbol *)p)->GetID(); + const user_id_t match_uid = *(const user_id_t*) key; + const user_id_t symbol_uid = ((const Symbol *)p)->GetID(); if (match_uid < symbol_uid) return -1; if (match_uid > symbol_uid) @@ -227,7 +227,7 @@ Symbol *symbol = (Symbol*)::bsearch (&symbol_uid, &m_symbols[0], m_symbols.size(), - (uint8_t *)&m_symbols[1] - (uint8_t *)&m_symbols[0], + sizeof(m_symbols[0]), CompareSymbolID); return symbol; } Index: tools/driver/Driver.cpp =================================================================== --- tools/driver/Driver.cpp +++ tools/driver/Driver.cpp @@ -867,7 +867,6 @@ { enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE - bool success = true; ::FILE *commands_file = NULL; fds[0] = -1; fds[1] = -1; @@ -885,7 +884,6 @@ fprintf(stderr, "error: write(%i, %p, %" PRIu64 ") failed (errno = %i) " "when trying to open LLDB commands pipe\n", fds[WRITE], commands_data, static_cast(commands_size), errno); - success = false; } else if (static_cast(nrwr) == commands_size) { @@ -911,14 +909,12 @@ "error: fdopen(%i, \"r\") failed (errno = %i) when " "trying to open LLDB commands pipe\n", fds[READ], errno); - success = false; } } } else { fprintf(stderr, "error: can't create pipe file descriptors for LLDB commands\n"); - success = false; } return commands_file;