Fixed a ton of gcc compile warnings

Removed some unused variables, added some consts, changed some casts
to const_cast. I don't think any of these changes are very
controversial.

Differential Revision: http://reviews.llvm.org/D9674

llvm-svn: 237218
This commit is contained in:
Vince Harron 2015-05-13 00:25:54 +00:00
parent 9bbc3653c5
commit d7e6a4f2f0
33 changed files with 113 additions and 117 deletions

View File

@ -357,7 +357,7 @@ public:
/// 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.

View File

@ -195,7 +195,7 @@ public:
static lldb::CommandArgumentType
LookupArgumentName (const char *arg_name);
static ArgumentTableEntry *
static const ArgumentTableEntry *
FindArgumentDataByType (lldb::CommandArgumentType arg_type);
int

View File

@ -534,7 +534,7 @@ protected:
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());
}
}

View File

@ -106,7 +106,7 @@ DataBufferHeap::CopyData (const void *src, uint64_t src_len)
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

View File

@ -21,36 +21,36 @@ using namespace lldb;
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 @@ DataEncoder::GetSharedDataOffset () const
// 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();

View File

@ -1299,13 +1299,11 @@ FormatEntity::Format (const Entry &entry,
// 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;
}
}

View File

@ -181,12 +181,13 @@ GetPrintableImpl<StringElementType::ASCII> (uint8_t* buffer, uint8_t* buffer_end
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 @@ GetPrintableImpl<StringElementType::UTF8> (uint8_t* buffer, uint8_t* buffer_end,
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 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
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 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
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 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType
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 @@ ReadStringAndDumpToStream<StringElementType::ASCII> (ReadStringAndDumpToStreamOp
{
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 @@ ReadStringAndDumpToStream<StringElementType::ASCII> (ReadStringAndDumpToStreamOp
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 @@ ReadUTFBufferAndDumpToStream (const ReadStringAndDumpToStreamOptions& options,
Error error;
char *buffer = reinterpret_cast<char *>(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())
{

View File

@ -605,8 +605,11 @@ IRExecutionUnit::MemoryManager::allocateDataSection(uintptr_t Size,
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,

View File

@ -711,7 +711,7 @@ Editline::BreakLineCommand (int ch)
unsigned char
Editline::DeleteNextCharCommand (int ch)
{
LineInfoW * info = (LineInfoW *)el_wline (m_editline);
LineInfoW * info = const_cast<LineInfoW *>(el_wline (m_editline));
// Just delete the next character normally if possible
if (info->cursor < info->lastchar)
@ -755,7 +755,7 @@ Editline::DeleteNextCharCommand (int ch)
unsigned char
Editline::DeletePreviousCharCommand (int ch)
{
LineInfoW * info = (LineInfoW *)el_wline (m_editline);
LineInfoW * info = const_cast<LineInfoW *>(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 @@ Editline::FixIndentationCommand (int ch)
StringList lines = GetInputAsStringList (m_current_line_index + 1);
// Determine the cursor position
LineInfoW * info = (LineInfoW *)el_wline (m_editline);
LineInfoW * info = const_cast<LineInfoW *>(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 @@ Editline::RevertLineCommand (int ch)
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<LineInfoW *>(el_wline (m_editline));
info->cursor = info->buffer + m_revert_cursor_index;
if (info->cursor > info->lastchar)
{

View File

@ -136,7 +136,7 @@ LocateExecutableSymbolFileDsym (const ModuleSpec &module_spec)
"LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>",
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 @@ Symbols::LocateExecutableObjectFile (const ModuleSpec &module_spec)
"LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>",
uuid);
(void*)uuid);
FileSpec objfile_fspec;
ModuleSpecList module_specs;

View File

@ -1138,7 +1138,7 @@ Args::IsPositionalArgument (const char *arg)
return false;
bool is_positional = true;
char *cptr = (char *) arg;
const char *cptr = arg;
if (cptr[0] == '%')
{

View File

@ -2247,7 +2247,7 @@ CommandInterpreter::BuildAliasCommandArgs (CommandObject *alias_cmd_obj,
}
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 @@ CommandInterpreter::BuildAliasCommandArgs (CommandObject *alias_cmd_obj,
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 @@ CommandInterpreter::GetOptionArgumentPosition (const char *in_string)
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] == '%')

View File

@ -506,14 +506,14 @@ CommandObject::GetArgumentEntryAtIndex (int idx)
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 @@ void
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 @@ CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, Comma
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...

View File

@ -944,7 +944,7 @@ Options::HandleOptionArgumentCompletion
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;
}

View File

@ -382,6 +382,13 @@ ScriptInterpreterPython::LeaveSession ()
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<char*>(name), const_cast<char*>(mode), close);
}
bool
ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
FILE *in,
@ -447,7 +454,7 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
{
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 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
{
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 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
{
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);
}

View File

@ -263,10 +263,9 @@ ABISysV_hexagon::PrepareTrivialCall ( Thread &thread,
// 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<lldb::addr_t*>(&arg.value) = sp;
}
#if HEX_ABI_DEBUG
// print the original stack pointer
printf( "sp : %04" PRIx64 " \n", sp );

View File

@ -1428,7 +1428,7 @@ DynamicLoaderMacOSXDYLD::DYLDImageInfo::PutToLog (Log *log) const
{
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)
{

View File

@ -233,7 +233,7 @@ EmulationStateARM::WritePseudoMemory (EmulateInstruction *instruction,
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;

View File

@ -178,7 +178,7 @@ AdbClient::ReadMessage (std::string &message)
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);

View File

@ -1174,7 +1174,7 @@ PlatformDarwin::GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
// /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 @@ PlatformDarwin::DirectoryEnumerator(void *baton,
}
return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext;
};
}
FileSpec
PlatformDarwin::FindSDKInXcodeForModules (SDKType sdk_type,

View File

@ -665,9 +665,9 @@ PlatformPOSIX::ConnectRemote (Args& args)
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)
{

View File

@ -49,7 +49,7 @@ namespace
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 @@ ProcessLinux::Initialize()
//------------------------------------------------------------------------------
// 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

View File

@ -53,7 +53,7 @@ public:
//------------------------------------------------------------------
ProcessLinux(Target& target,
Listener &listener,
FileSpec *core_file);
const FileSpec *core_file);
Error
DoDetach(bool keep_stopped) override;
@ -98,7 +98,7 @@ public:
private:
FileSpec *m_core_file;
const FileSpec *m_core_file;
// Flag to avoid recursion when stopping all threads.
bool m_stopping_threads;

View File

@ -351,7 +351,7 @@ DoWriteMemory(lldb::pid_t pid,
(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;

View File

@ -772,48 +772,40 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
llvm::SmallString<PATH_MAX> 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
{
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() "
"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());
}
debugserver_args.AppendArgument("--named-pipe");
debugserver_args.AppendArgument(named_pipe_path.c_str());
}
else
{
listen = true;
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() "
"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());
}
}
else

View File

@ -677,15 +677,16 @@ GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data
// 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());

View File

@ -4094,18 +4094,18 @@ ProcessGDBRemote::GetLoadedModuleList (GDBLoadedModuleInfoList & list)
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 @@ ProcessGDBRemote::GetLoadedModuleList (GDBLoadedModuleInfoList & list)
}
// 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 @@ ProcessGDBRemote::GetLoadedModuleList (GDBLoadedModuleInfoList & list)
}
// 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)

View File

@ -191,7 +191,7 @@ DWARFFormValue::ExtractValue(const DWARFDataExtractor& data, lldb::offset_t* off
// 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;

View File

@ -69,7 +69,7 @@ NameToDIE::Dump (Stream *s)
for (uint32_t i=0; i<size; ++i)
{
const char *cstr = m_map.GetCStringAtIndex(i);
s->Printf("%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);
}
}

View File

@ -101,7 +101,7 @@ namespace lldb_private {
UNWIND_X86_64_REG_R15 = 5,
UNWIND_X86_64_REG_RBP = 6,
};
};
}
#ifndef UNWIND_SECOND_LEVEL_REGULAR

View File

@ -804,7 +804,7 @@ DWARFCallFrameInfo::FDEToUnwindPlan (dw_offset_t dwarf_offset, Address startaddr
// 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 @@ DWARFCallFrameInfo::FDEToUnwindPlan (dw_offset_t dwarf_offset, Address startaddr
// 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.

View File

@ -210,8 +210,8 @@ Symtab::DumpSymbolHeader (Stream *s)
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 @@ Symtab::FindSymbolByID (lldb::user_id_t symbol_uid) const
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;
}

View File

@ -867,7 +867,6 @@ PrepareCommandsForSourcing (const char *commands_data, size_t commands_size, int
{
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 @@ PrepareCommandsForSourcing (const char *commands_data, size_t commands_size, int
fprintf(stderr, "error: write(%i, %p, %" PRIu64 ") failed (errno = %i) "
"when trying to open LLDB commands pipe\n",
fds[WRITE], commands_data, static_cast<uint64_t>(commands_size), errno);
success = false;
}
else if (static_cast<size_t>(nrwr) == commands_size)
{
@ -911,14 +909,12 @@ PrepareCommandsForSourcing (const char *commands_data, size_t commands_size, int
"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;