diff options
32 files changed, 194 insertions, 693 deletions
diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index c6a3dbe696b..875193440b2 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -106,16 +106,16 @@ AddProcessToMap (nub_process_t pid, MachProcessSP& procSP) // // Returns the number of items removed from the process map. //---------------------------------------------------------------------- -static size_t -RemoveProcessFromMap (nub_process_t pid) -{ - ProcessMap* process_map = GetProcessMap(false); - if (process_map) - { - return process_map->erase(pid); - } - return 0; -} +//static size_t +//RemoveProcessFromMap (nub_process_t pid) +//{ +// ProcessMap* process_map = GetProcessMap(false); +// if (process_map) +// { +// return process_map->erase(pid); +// } +// return 0; +//} //---------------------------------------------------------------------- // Get the shared pointer for PID from the existing process map. @@ -175,8 +175,8 @@ kqueue_thread (void *arg) } else if (death_event.flags & EV_ERROR) { - int error_no = death_event.data; - const char *error_str = strerror(death_event.data); + int error_no = static_cast<int>(death_event.data); + const char *error_str = strerror(error_no); if (error_str == NULL) error_str = "Unknown error"; DNBLogError ("Failed to initialize kqueue event: (%d): %s", error_no, error_str ); @@ -620,7 +620,7 @@ GetAllInfosMatchingName(const char *full_process_name, std::vector<struct kinfo_ else process_name++; - const int process_name_len = strlen(process_name); + const size_t process_name_len = strlen(process_name); std::vector<struct kinfo_proc> proc_infos; const size_t num_proc_infos = GetAllInfos(proc_infos); if (num_proc_infos > 0) @@ -1339,512 +1339,6 @@ DNBProcessSetEnableAsyncProfiling (nub_process_t pid, nub_bool_t enable, uint64_ } //---------------------------------------------------------------------- -// Formatted output that uses memory and registers from process and -// thread in place of arguments. -//---------------------------------------------------------------------- -nub_size_t -DNBPrintf (nub_process_t pid, nub_thread_t tid, nub_addr_t base_addr, FILE *file, const char *format) -{ - if (file == NULL) - return 0; - enum printf_flags - { - alternate_form = (1 << 0), - zero_padding = (1 << 1), - negative_field_width = (1 << 2), - blank_space = (1 << 3), - show_sign = (1 << 4), - show_thousands_separator= (1 << 5), - }; - - enum printf_length_modifiers - { - length_mod_h = (1 << 0), - length_mod_hh = (1 << 1), - length_mod_l = (1 << 2), - length_mod_ll = (1 << 3), - length_mod_L = (1 << 4), - length_mod_j = (1 << 5), - length_mod_t = (1 << 6), - length_mod_z = (1 << 7), - length_mod_q = (1 << 8), - }; - - nub_addr_t addr = base_addr; - char *end_format = (char*)format + strlen(format); - char *end = NULL; // For strtoXXXX calls; - std::basic_string<uint8_t> buf; - nub_size_t total_bytes_read = 0; - DNBDataRef data; - const char *f; - for (f = format; *f != '\0' && f < end_format; f++) - { - char ch = *f; - switch (ch) - { - case '%': - { - f++; // Skip the '%' character -// int min_field_width = 0; -// int precision = 0; - //uint32_t flags = 0; - uint32_t length_modifiers = 0; - uint32_t byte_size = 0; - uint32_t actual_byte_size = 0; - bool is_string = false; - bool is_register = false; - DNBRegisterValue register_value; - int64_t register_offset = 0; - nub_addr_t register_addr = INVALID_NUB_ADDRESS; - - // Create the format string to use for this conversion specification - // so we can remove and mprintf specific flags and formatters. - std::string fprintf_format("%"); - - // Decode any flags - switch (*f) - { - case '#': fprintf_format += *f++; break; //flags |= alternate_form; break; - case '0': fprintf_format += *f++; break; //flags |= zero_padding; break; - case '-': fprintf_format += *f++; break; //flags |= negative_field_width; break; - case ' ': fprintf_format += *f++; break; //flags |= blank_space; break; - case '+': fprintf_format += *f++; break; //flags |= show_sign; break; - case ',': fprintf_format += *f++; break; //flags |= show_thousands_separator;break; - case '{': - case '[': - { - // We have a register name specification that can take two forms: - // ${regname} or ${regname+offset} - // The action is to read the register value and add the signed offset - // (if any) and use that as the value to format. - // $[regname] or $[regname+offset] - // The action is to read the register value and add the signed offset - // (if any) and use the result as an address to dereference. The size - // of what is dereferenced is specified by the actual byte size that - // follows the minimum field width and precision (see comments below). - switch (*f) - { - case '{': - case '[': - { - char open_scope_ch = *f; - f++; - const char *reg_name = f; - size_t reg_name_length = strcspn(f, "+-}]"); - if (reg_name_length > 0) - { - std::string register_name(reg_name, reg_name_length); - f += reg_name_length; - register_offset = strtoll(f, &end, 0); - if (f < end) - f = end; - if ((open_scope_ch == '{' && *f != '}') || (open_scope_ch == '[' && *f != ']')) - { - fprintf(file, "error: Invalid register format string. Valid formats are %%{regname} or %%{regname+offset}, %%[regname] or %%[regname+offset]\n"); - return total_bytes_read; - } - else - { - f++; - if (DNBThreadGetRegisterValueByName(pid, tid, REGISTER_SET_ALL, register_name.c_str(), ®ister_value)) - { - // Set the address to dereference using the register value plus the offset - switch (register_value.info.size) - { - default: - case 0: - fprintf (file, "error: unsupported register size of %u.\n", register_value.info.size); - return total_bytes_read; - - case 1: register_addr = register_value.value.uint8 + register_offset; break; - case 2: register_addr = register_value.value.uint16 + register_offset; break; - case 4: register_addr = register_value.value.uint32 + register_offset; break; - case 8: register_addr = register_value.value.uint64 + register_offset; break; - case 16: - if (open_scope_ch == '[') - { - fprintf (file, "error: register size (%u) too large for address.\n", register_value.info.size); - return total_bytes_read; - } - break; - } - - if (open_scope_ch == '{') - { - byte_size = register_value.info.size; - is_register = true; // value is in a register - - } - else - { - addr = register_addr; // Use register value and offset as the address - } - } - else - { - fprintf(file, "error: unable to read register '%s' for process %#.4x and thread %#.8" PRIx64 "\n", register_name.c_str(), pid, tid); - return total_bytes_read; - } - } - } - } - break; - - default: - fprintf(file, "error: %%$ must be followed by (regname + n) or [regname + n]\n"); - return total_bytes_read; - } - } - break; - } - - // Check for a minimum field width - if (isdigit(*f)) - { - //min_field_width = strtoul(f, &end, 10); - strtoul(f, &end, 10); - if (end > f) - { - fprintf_format.append(f, end - f); - f = end; - } - } - - - // Check for a precision - if (*f == '.') - { - f++; - if (isdigit(*f)) - { - fprintf_format += '.'; - //precision = strtoul(f, &end, 10); - strtoul(f, &end, 10); - if (end > f) - { - fprintf_format.append(f, end - f); - f = end; - } - } - } - - - // mprintf specific: read the optional actual byte size (abs) - // after the standard minimum field width (mfw) and precision (prec). - // Standard printf calls you can have "mfw.prec" or ".prec", but - // mprintf can have "mfw.prec.abs", ".prec.abs" or "..abs". This is nice - // for strings that may be in a fixed size buffer, but may not use all bytes - // in that buffer for printable characters. - if (*f == '.') - { - f++; - actual_byte_size = strtoul(f, &end, 10); - if (end > f) - { - byte_size = actual_byte_size; - f = end; - } - } - - // Decode the length modifiers - switch (*f) - { - case 'h': // h and hh length modifiers - fprintf_format += *f++; - length_modifiers |= length_mod_h; - if (*f == 'h') - { - fprintf_format += *f++; - length_modifiers |= length_mod_hh; - } - break; - - case 'l': // l and ll length modifiers - fprintf_format += *f++; - length_modifiers |= length_mod_l; - if (*f == 'h') - { - fprintf_format += *f++; - length_modifiers |= length_mod_ll; - } - break; - - case 'L': fprintf_format += *f++; length_modifiers |= length_mod_L; break; - case 'j': fprintf_format += *f++; length_modifiers |= length_mod_j; break; - case 't': fprintf_format += *f++; length_modifiers |= length_mod_t; break; - case 'z': fprintf_format += *f++; length_modifiers |= length_mod_z; break; - case 'q': fprintf_format += *f++; length_modifiers |= length_mod_q; break; - } - - // Decode the conversion specifier - switch (*f) - { - case '_': - // mprintf specific format items - { - ++f; // Skip the '_' character - switch (*f) - { - case 'a': // Print the current address - ++f; - fprintf_format += "ll"; - fprintf_format += *f; // actual format to show address with follows the 'a' ("%_ax") - fprintf (file, fprintf_format.c_str(), addr); - break; - case 'o': // offset from base address - ++f; - fprintf_format += "ll"; - fprintf_format += *f; // actual format to show address with follows the 'a' ("%_ox") - fprintf(file, fprintf_format.c_str(), addr - base_addr); - break; - default: - fprintf (file, "error: unsupported mprintf specific format character '%c'.\n", *f); - break; - } - continue; - } - break; - - case 'D': - case 'O': - case 'U': - fprintf_format += *f; - if (byte_size == 0) - byte_size = sizeof(long int); - break; - - case 'd': - case 'i': - case 'o': - case 'u': - case 'x': - case 'X': - fprintf_format += *f; - if (byte_size == 0) - { - if (length_modifiers & length_mod_hh) - byte_size = sizeof(char); - else if (length_modifiers & length_mod_h) - byte_size = sizeof(short); - else if (length_modifiers & length_mod_ll) - byte_size = sizeof(long long); - else if (length_modifiers & length_mod_l) - byte_size = sizeof(long); - else - byte_size = sizeof(int); - } - break; - - case 'a': - case 'A': - case 'f': - case 'F': - case 'e': - case 'E': - case 'g': - case 'G': - fprintf_format += *f; - if (byte_size == 0) - { - if (length_modifiers & length_mod_L) - byte_size = sizeof(long double); - else - byte_size = sizeof(double); - } - break; - - case 'c': - if ((length_modifiers & length_mod_l) == 0) - { - fprintf_format += *f; - if (byte_size == 0) - byte_size = sizeof(char); - break; - } - // Fall through to 'C' modifier below... - - case 'C': - fprintf_format += *f; - if (byte_size == 0) - byte_size = sizeof(wchar_t); - break; - - case 's': - fprintf_format += *f; - if (is_register || byte_size == 0) - is_string = 1; - break; - - case 'p': - fprintf_format += *f; - if (byte_size == 0) - byte_size = sizeof(void*); - break; - } - - if (is_string) - { - std::string mem_string; - const size_t string_buf_len = 4; - char string_buf[string_buf_len+1]; - char *string_buf_end = string_buf + string_buf_len; - string_buf[string_buf_len] = '\0'; - nub_size_t bytes_read; - nub_addr_t str_addr = is_register ? register_addr : addr; - while ((bytes_read = DNBProcessMemoryRead(pid, str_addr, string_buf_len, &string_buf[0])) > 0) - { - // Did we get a NULL termination character yet? - if (strchr(string_buf, '\0') == string_buf_end) - { - // no NULL terminator yet, append as a std::string - mem_string.append(string_buf, string_buf_len); - str_addr += string_buf_len; - } - else - { - // yep - break; - } - } - // Append as a C-string so we don't get the extra NULL - // characters in the temp buffer (since it was resized) - mem_string += string_buf; - size_t mem_string_len = mem_string.size() + 1; - fprintf(file, fprintf_format.c_str(), mem_string.c_str()); - if (mem_string_len > 0) - { - if (!is_register) - { - addr += mem_string_len; - total_bytes_read += mem_string_len; - } - } - else - return total_bytes_read; - } - else - if (byte_size > 0) - { - buf.resize(byte_size); - nub_size_t bytes_read = 0; - if (is_register) - bytes_read = register_value.info.size; - else - bytes_read = DNBProcessMemoryRead(pid, addr, buf.size(), &buf[0]); - if (bytes_read > 0) - { - if (!is_register) - total_bytes_read += bytes_read; - - if (bytes_read == byte_size) - { - switch (*f) - { - case 'd': - case 'i': - case 'o': - case 'u': - case 'X': - case 'x': - case 'a': - case 'A': - case 'f': - case 'F': - case 'e': - case 'E': - case 'g': - case 'G': - case 'p': - case 'c': - case 'C': - { - if (is_register) - data.SetData(®ister_value.value.v_uint8[0], register_value.info.size); - else - data.SetData(&buf[0], bytes_read); - DNBDataRef::offset_t data_offset = 0; - if (byte_size <= 4) - { - uint32_t u32 = data.GetMax32(&data_offset, byte_size); - // Show the actual byte width when displaying hex - fprintf(file, fprintf_format.c_str(), u32); - } - else if (byte_size <= 8) - { - uint64_t u64 = data.GetMax64(&data_offset, byte_size); - // Show the actual byte width when displaying hex - fprintf(file, fprintf_format.c_str(), u64); - } - else - { - fprintf(file, "error: integer size not supported, must be 8 bytes or less (%u bytes).\n", byte_size); - } - if (!is_register) - addr += byte_size; - } - break; - - case 's': - fprintf(file, fprintf_format.c_str(), buf.c_str()); - addr += byte_size; - break; - - default: - fprintf(file, "error: unsupported conversion specifier '%c'.\n", *f); - break; - } - } - } - } - else - return total_bytes_read; - } - break; - - case '\\': - { - f++; - switch (*f) - { - case 'e': ch = '\e'; break; - case 'a': ch = '\a'; break; - case 'b': ch = '\b'; break; - case 'f': ch = '\f'; break; - case 'n': ch = '\n'; break; - case 'r': ch = '\r'; break; - case 't': ch = '\t'; break; - case 'v': ch = '\v'; break; - case '\'': ch = '\''; break; - case '\\': ch = '\\'; break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - ch = strtoul(f, &end, 8); - f = end; - break; - default: - ch = *f; - break; - } - fputc(ch, file); - } - break; - - default: - fputc(ch, file); - break; - } - } - return total_bytes_read; -} - - -//---------------------------------------------------------------------- // Get the number of threads for the specified process. //---------------------------------------------------------------------- nub_size_t diff --git a/lldb/tools/debugserver/source/DNB.h b/lldb/tools/debugserver/source/DNB.h index 177c4bdfffe..363ca042e83 100644 --- a/lldb/tools/debugserver/source/DNB.h +++ b/lldb/tools/debugserver/source/DNB.h @@ -156,12 +156,6 @@ const DNBRegisterSetInfo * nub_bool_t DNBGetRegisterInfoByName (const char *reg_name, DNBRegisterInfo* info); //---------------------------------------------------------------------- -// Printf style formatting for printing values in the inferior memory -// space and registers. -//---------------------------------------------------------------------- -nub_size_t DNBPrintf (nub_process_t pid, nub_thread_t tid, nub_addr_t addr, FILE *file, const char *format); - -//---------------------------------------------------------------------- // Other static nub information calls. //---------------------------------------------------------------------- const char * DNBStateAsString (nub_state_t state); diff --git a/lldb/tools/debugserver/source/DNBArch.h b/lldb/tools/debugserver/source/DNBArch.h index 54300374c78..b3cb070e55c 100644 --- a/lldb/tools/debugserver/source/DNBArch.h +++ b/lldb/tools/debugserver/source/DNBArch.h @@ -68,8 +68,8 @@ public: { } - virtual bool GetRegisterValue (int set, int reg, DNBRegisterValue *value) = 0; - virtual bool SetRegisterValue (int set, int reg, const DNBRegisterValue *value) = 0; + virtual bool GetRegisterValue (uint32_t set, uint32_t reg, DNBRegisterValue *value) = 0; + virtual bool SetRegisterValue (uint32_t set, uint32_t reg, const DNBRegisterValue *value) = 0; virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len) = 0; virtual nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len) = 0; virtual uint32_t SaveRegisterState () = 0; diff --git a/lldb/tools/debugserver/source/DNBBreakpoint.cpp b/lldb/tools/debugserver/source/DNBBreakpoint.cpp index 246797c8dae..2645f173306 100644 --- a/lldb/tools/debugserver/source/DNBBreakpoint.cpp +++ b/lldb/tools/debugserver/source/DNBBreakpoint.cpp @@ -22,7 +22,7 @@ #pragma mark -- DNBBreakpoint DNBBreakpoint::DNBBreakpoint(nub_addr_t addr, nub_size_t byte_size, bool hardware) : m_retain_count (1), - m_byte_size (byte_size), + m_byte_size (static_cast<uint32_t>(byte_size)), m_opcode(), m_addr(addr), m_enabled(0), diff --git a/lldb/tools/debugserver/source/DNBDataRef.h b/lldb/tools/debugserver/source/DNBDataRef.h index 7721f78c4a8..d0c34ced623 100644 --- a/lldb/tools/debugserver/source/DNBDataRef.h +++ b/lldb/tools/debugserver/source/DNBDataRef.h @@ -56,9 +56,9 @@ public: m_swap = false; } - offset_t BytesLeft (offset_t offset) const + size_t BytesLeft (size_t offset) const { - const offset_t size = GetSize(); + const size_t size = GetSize(); if (size > offset) return size - offset; return 0; diff --git a/lldb/tools/debugserver/source/DNBTimer.h b/lldb/tools/debugserver/source/DNBTimer.h index 717e1563be5..ca56e30c709 100644 --- a/lldb/tools/debugserver/source/DNBTimer.h +++ b/lldb/tools/debugserver/source/DNBTimer.h @@ -83,7 +83,7 @@ public: } void - GetTime (uint32_t& sec, uint32_t& usec) const + GetTime (uint64_t& sec, uint32_t& usec) const { PTHREAD_MUTEX_LOCKER (locker, m_mutexAP.get()); sec = m_timeval.tv_sec; diff --git a/lldb/tools/debugserver/source/MacOSX/Genealogy.cpp b/lldb/tools/debugserver/source/MacOSX/Genealogy.cpp index e6ada966b81..a5ee097aa2a 100644 --- a/lldb/tools/debugserver/source/MacOSX/Genealogy.cpp +++ b/lldb/tools/debugserver/source/MacOSX/Genealogy.cpp @@ -271,7 +271,7 @@ Genealogy::GetActivities(pid_t pid, const MachThreadList &thread_list, task_t ta uint32_t Genealogy::AddProcessExecutableInfo (ProcessExecutableInfoSP process_exe_info) { - const uint32_t info_size = m_process_executable_infos.size(); + const uint32_t info_size = static_cast<uint32_t>(m_process_executable_infos.size()); for (uint32_t idx = 0; idx < info_size; ++idx) { if (uuid_compare (m_process_executable_infos[idx]->image_uuid, process_exe_info->image_uuid) == 0) @@ -284,7 +284,7 @@ Genealogy::AddProcessExecutableInfo (ProcessExecutableInfoSP process_exe_info) } Genealogy::ProcessExecutableInfoSP -Genealogy::GetProcessExecutableInfosAtIndex(uint32_t idx) +Genealogy::GetProcessExecutableInfosAtIndex(size_t idx) { ProcessExecutableInfoSP info_sp; if (idx > 0) diff --git a/lldb/tools/debugserver/source/MacOSX/Genealogy.h b/lldb/tools/debugserver/source/MacOSX/Genealogy.h index 18521ee2346..d39145a06f2 100644 --- a/lldb/tools/debugserver/source/MacOSX/Genealogy.h +++ b/lldb/tools/debugserver/source/MacOSX/Genealogy.h @@ -85,7 +85,7 @@ public: typedef std::shared_ptr<ProcessExecutableInfo> ProcessExecutableInfoSP; ProcessExecutableInfoSP - GetProcessExecutableInfosAtIndex(uint32_t idx); + GetProcessExecutableInfosAtIndex(size_t idx); uint32_t AddProcessExecutableInfo(ProcessExecutableInfoSP process_exe_info); diff --git a/lldb/tools/debugserver/source/MacOSX/MachException.h b/lldb/tools/debugserver/source/MacOSX/MachException.h index 74041e0c4bd..73b9cb98a0f 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachException.h +++ b/lldb/tools/debugserver/source/MacOSX/MachException.h @@ -77,7 +77,7 @@ public: int SoftSignal() const { if (exc_type == EXC_SOFTWARE && exc_data.size() == 2 && exc_data[0] == EXC_SOFT_SIGNAL) - return exc_data[1]; + return static_cast<int>(exc_data[1]); return 0; } bool IsBreakpoint() const diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h b/lldb/tools/debugserver/source/MacOSX/MachProcess.h index 3cd60917f15..3d007a36e31 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h @@ -158,7 +158,7 @@ public: //---------------------------------------------------------------------- void SetEnableAsyncProfiling (bool enable, uint64_t internal_usec, DNBProfileDataScanType scan_type); bool IsProfilingEnabled () { return m_profile_enabled; } - uint64_t ProfileInterval () { return m_profile_interval_usec; } + useconds_t ProfileInterval () { return m_profile_interval_usec; } bool StartProfileThread (); static void * ProfileThread (void *arg); void SignalAsyncProfileData (const char *info); @@ -310,7 +310,7 @@ private: std::string m_stdout_data; bool m_profile_enabled; // A flag to indicate if profiling is enabled - uint64_t m_profile_interval_usec; // If enable, the profiling interval in microseconds + useconds_t m_profile_interval_usec; // If enable, the profiling interval in microseconds DNBProfileDataScanType m_profile_scan_type; // Indicates what needs to be profiled pthread_t m_profile_thread; // Thread ID for the thread that profiles the inferior PThreadMutex m_profile_data_mutex; // Multithreaded protection for profile info data diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm index 62149dc7177..3be4d65458c 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm @@ -40,7 +40,43 @@ #include "CFData.h" #include "CFString.h" -static CFStringRef CopyBundleIDForPath (const char *app_bundle_path, DNBError &err_str); +#if defined (WITH_SPRINGBOARD) || defined (WITH_BKS) +// This returns a CFRetained pointer to the Bundle ID for app_bundle_path, +// or NULL if there was some problem getting the bundle id. +static CFStringRef +CopyBundleIDForPath (const char *app_bundle_path, DNBError &err_str) +{ + CFBundle bundle(app_bundle_path); + CFStringRef bundleIDCFStr = bundle.GetIdentifier(); + std::string bundleID; + if (CFString::UTF8(bundleIDCFStr, bundleID) == NULL) + { + struct stat app_bundle_stat; + char err_msg[PATH_MAX]; + + if (::stat (app_bundle_path, &app_bundle_stat) < 0) + { + err_str.SetError(errno, DNBError::POSIX); + snprintf(err_msg, sizeof(err_msg), "%s: \"%s\"", err_str.AsString(), app_bundle_path); + err_str.SetErrorString(err_msg); + DNBLogThreadedIf(LOG_PROCESS, "%s() error: %s", __FUNCTION__, err_msg); + } + else + { + err_str.SetError(-1, DNBError::Generic); + snprintf(err_msg, sizeof(err_msg), "failed to extract CFBundleIdentifier from %s", app_bundle_path); + err_str.SetErrorString(err_msg); + DNBLogThreadedIf(LOG_PROCESS, "%s() error: failed to extract CFBundleIdentifier from '%s'", __FUNCTION__, app_bundle_path); + } + return NULL; + } + + DNBLogThreadedIf(LOG_PROCESS, "%s() extracted CFBundleIdentifier: %s", __FUNCTION__, bundleID.c_str()); + CFRetain (bundleIDCFStr); + + return bundleIDCFStr; +} +#endif // #if defined 9WITH_SPRINGBOARD) || defined (WITH_BKS) #ifdef WITH_SPRINGBOARD @@ -412,7 +448,7 @@ void MachProcess::SetEnableAsyncProfiling(bool enable, uint64_t interval_usec, DNBProfileDataScanType scan_type) { m_profile_enabled = enable; - m_profile_interval_usec = interval_usec; + m_profile_interval_usec = static_cast<useconds_t>(interval_usec); m_profile_scan_type = scan_type; if (m_profile_enabled && (m_profile_thread == NULL)) @@ -1515,7 +1551,7 @@ MachProcess::STDIOThread(void *arg) { char s[1024]; s[sizeof(s)-1] = '\0'; // Ensure we have NULL termination - int bytes_read = 0; + ssize_t bytes_read = 0; if (stdout_fd >= 0 && FD_ISSET (stdout_fd, &read_fds)) { do @@ -1524,12 +1560,12 @@ MachProcess::STDIOThread(void *arg) if (bytes_read < 0) { int read_errno = errno; - DNBLogThreadedIf(LOG_PROCESS, "read (stdout_fd, ) => %d errno: %d (%s)", bytes_read, read_errno, strerror(read_errno)); + DNBLogThreadedIf(LOG_PROCESS, "read (stdout_fd, ) => %zd errno: %d (%s)", bytes_read, read_errno, strerror(read_errno)); } else if (bytes_read == 0) { // EOF... - DNBLogThreadedIf(LOG_PROCESS, "read (stdout_fd, ) => %d (reached EOF for child STDOUT)", bytes_read); + DNBLogThreadedIf(LOG_PROCESS, "read (stdout_fd, ) => %zd (reached EOF for child STDOUT)", bytes_read); stdout_fd = -1; } else if (bytes_read > 0) @@ -1548,12 +1584,12 @@ MachProcess::STDIOThread(void *arg) if (bytes_read < 0) { int read_errno = errno; - DNBLogThreadedIf(LOG_PROCESS, "read (stderr_fd, ) => %d errno: %d (%s)", bytes_read, read_errno, strerror(read_errno)); + DNBLogThreadedIf(LOG_PROCESS, "read (stderr_fd, ) => %zd errno: %d (%s)", bytes_read, read_errno, strerror(read_errno)); } else if (bytes_read == 0) { // EOF... - DNBLogThreadedIf(LOG_PROCESS, "read (stderr_fd, ) => %d (reached EOF for child STDERR)", bytes_read); + DNBLogThreadedIf(LOG_PROCESS, "read (stderr_fd, ) => %zd (reached EOF for child STDERR)", bytes_read); stderr_fd = -1; } else if (bytes_read > 0) @@ -2309,7 +2345,7 @@ MachProcess::GetCPUTypeForLocalProcess (pid_t pid) cpu_type_t cpu; size_t cpu_len = sizeof(cpu); - if (::sysctl (mib, len, &cpu, &cpu_len, 0, 0)) + if (::sysctl (mib, static_cast<u_int>(len), &cpu, &cpu_len, 0, 0)) cpu = 0; return cpu; } @@ -2389,43 +2425,6 @@ MachProcess::ForkChildForPTraceDebugging return pid; } -#if defined (WITH_SPRINGBOARD) || defined (WITH_BKS) -// This returns a CFRetained pointer to the Bundle ID for app_bundle_path, -// or NULL if there was some problem getting the bundle id. -static CFStringRef -CopyBundleIDForPath (const char *app_bundle_path, DNBError &err_str) -{ - CFBundle bundle(app_bundle_path); - CFStringRef bundleIDCFStr = bundle.GetIdentifier(); - std::string bundleID; - if (CFString::UTF8(bundleIDCFStr, bundleID) == NULL) - { - struct stat app_bundle_stat; - char err_msg[PATH_MAX]; - - if (::stat (app_bundle_path, &app_bundle_stat) < 0) - { - err_str.SetError(errno, DNBError::POSIX); - snprintf(err_msg, sizeof(err_msg), "%s: \"%s\"", err_str.AsString(), app_bundle_path); - err_str.SetErrorString(err_msg); - DNBLogThreadedIf(LOG_PROCESS, "%s() error: %s", __FUNCTION__, err_msg); - } - else - { - err_str.SetError(-1, DNBError::Generic); - snprintf(err_msg, sizeof(err_msg), "failed to extract CFBundleIdentifier from %s", app_bundle_path); - err_str.SetErrorString(err_msg); - DNBLogThreadedIf(LOG_PROCESS, "%s() error: failed to extract CFBundleIdentifier from '%s'", __FUNCTION__, app_bundle_path); - } - return NULL; - } - - DNBLogThreadedIf(LOG_PROCESS, "%s() extracted CFBundleIdentifier: %s", __FUNCTION__, bundleID.c_str()); - CFRetain (bundleIDCFStr); - - return bundleIDCFStr; -} -#endif // #if defined 9WITH_SPRINGBOARD) || defined (WITH_BKS) #ifdef WITH_SPRINGBOARD pid_t diff --git a/lldb/tools/debugserver/source/MacOSX/MachTask.mm b/lldb/tools/debugserver/source/MacOSX/MachTask.mm index 2cb456cff7c..4cb53afbeaf 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachTask.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachTask.mm @@ -202,7 +202,7 @@ MachTask::ReadMemory (nub_addr_t addr, nub_size_t size, void *buf) if (DNBLogCheckLogBit(LOG_MEMORY_DATA_LONG) || (DNBLogCheckLogBit(LOG_MEMORY_DATA_SHORT) && size <= 8)) { DNBDataRef data((uint8_t*)buf, n, false); - data.Dump(0, n, addr, DNBDataRef::TypeUInt8, 16); + data.Dump(0, static_cast<DNBDataRef::offset_t>(n), addr, DNBDataRef::TypeUInt8, 16); } } return n; @@ -224,7 +224,7 @@ MachTask::WriteMemory (nub_addr_t addr, nub_size_t size, const void *buf) if (DNBLogCheckLogBit(LOG_MEMORY_DATA_LONG) || (DNBLogCheckLogBit(LOG_MEMORY_DATA_SHORT) && size <= 8)) { DNBDataRef data((uint8_t*)buf, n, false); - data.Dump(0, n, addr, DNBDataRef::TypeUInt8, 16); + data.Dump(0, static_cast<DNBDataRef::offset_t>(n), addr, DNBDataRef::TypeUInt8, 16); } } return n; @@ -411,8 +411,8 @@ MachTask::GetProfileData (DNBProfileDataScanType scanType) if (scanType & eProfileThreadsCPU) { - int num_threads = threads_id.size(); - for (int i=0; i<num_threads; i++) + const size_t num_threads = threads_id.size(); + for (size_t i=0; i<num_threads; i++) { profile_data_stream << "thread_used_id:" << std::hex << threads_id[i] << std::dec << ';'; profile_data_stream << "thread_used_usec:" << threads_used_usec[i] << ';'; @@ -420,7 +420,7 @@ MachTask::GetProfileData (DNBProfileDataScanType scanType) if (scanType & eProfileThreadName) { profile_data_stream << "thread_used_name:"; - int len = threads_name[i].size(); + const size_t len = threads_name[i].size(); if (len) { const char *thread_name = threads_name[i].c_str(); @@ -890,7 +890,6 @@ MachTask::ExceptionThread (void *arg) // Our task has died, exit the thread. break; } - continue; } #if defined (WITH_SPRINGBOARD) && !defined (WITH_BKS) diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp index f0650d34783..5d123764683 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.cpp @@ -97,7 +97,7 @@ MachThread::SetSuspendCountBeforeResume(bool others_stopped) if (MachPortNumberIsValid(m_mach_port_number) == false) return false; - size_t times_to_resume; + integer_t times_to_resume; if (others_stopped) { @@ -538,7 +538,7 @@ MachThread::SetState(nub_state_t state) DNBLogThreadedIf(LOG_THREAD, "MachThread::SetState ( %s ) for tid = 0x%8.8" PRIx64 "", DNBStateAsString(state), m_unique_id); } -uint32_t +nub_size_t MachThread::GetNumRegistersInSet(int regSet) const { if (regSet < m_num_reg_sets) @@ -575,7 +575,7 @@ MachThread::DumpRegisterState(int regSet) if (m_arch_ap->RegisterSetStateIsValid(regSet)) { const size_t numRegisters = GetNumRegistersInSet(regSet); - size_t regIndex = 0; + uint32_t regIndex = 0; DNBRegisterValueClass reg; for (regIndex = 0; regIndex < numRegisters; ++regIndex) { diff --git a/lldb/tools/debugserver/source/MacOSX/MachThread.h b/lldb/tools/debugserver/source/MacOSX/MachThread.h index a4667603c44..c1c18bfb4d2 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThread.h +++ b/lldb/tools/debugserver/source/MacOSX/MachThread.h @@ -83,7 +83,7 @@ public: bool NotifyException(MachException::Data& exc); const MachException::Data& GetStopException() { return m_stop_exception; } - uint32_t GetNumRegistersInSet(int regSet) const; + nub_size_t GetNumRegistersInSet(int regSet) const; const char * GetRegisterSetName(int regSet) const; const DNBRegisterInfo * GetRegisterInfo(int regSet, int regIndex) const; diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp index d3c9a87a89a..8a7da6f4531 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp @@ -200,21 +200,21 @@ MachThreadList::GetMachPortNumberByThreadID (nub_thread_t globally_unique_id) co } bool -MachThreadList::GetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value ) const +MachThreadList::GetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, DNBRegisterValue *reg_value ) const { MachThreadSP thread_sp (GetThreadByID (tid)); if (thread_sp) - return thread_sp->GetRegisterValue(reg_set_idx, reg_idx, reg_value); + return thread_sp->GetRegisterValue(set, reg, reg_value); return false; } bool -MachThreadList::SetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, const DNBRegisterValue *reg_value ) const +MachThreadList::SetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, const DNBRegisterValue *reg_value ) const { MachThreadSP thread_sp (GetThreadByID (tid)); if (thread_sp) - return thread_sp->SetRegisterValue(reg_set_idx, reg_idx, reg_value); + return thread_sp->SetRegisterValue(set, reg, reg_value); return false; } @@ -387,7 +387,7 @@ MachThreadList::UpdateThreadList(MachProcess *process, bool update, MachThreadLi thread_list_size); } } - return m_threads.size(); + return static_cast<uint32_t>(m_threads.size()); } @@ -401,7 +401,7 @@ MachThreadList::CurrentThread (MachThreadSP& thread_sp) // Figure out which thread is going to be our current thread. // This is currently done by finding the first thread in the list // that has a valid exception. - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); for (uint32_t idx = 0; idx < num_threads; ++idx) { if (m_threads[idx]->GetStopException().IsValid()) @@ -418,7 +418,7 @@ void MachThreadList::Dump() const { PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); for (uint32_t idx = 0; idx < num_threads; ++idx) { m_threads[idx]->Dump(idx); @@ -463,8 +463,8 @@ MachThreadList::ProcessWillResume(MachProcess *process, const DNBThreadResumeAct if (run_one_thread) resume_new_threads.state = eStateSuspended; - const uint32_t num_new_threads = new_threads.size(); - const uint32_t num_threads = m_threads.size(); + const size_t num_new_threads = new_threads.size(); + const size_t num_threads = m_threads.size(); for (uint32_t idx = 0; idx < num_threads; ++idx) { MachThread *thread = m_threads[idx].get(); @@ -533,7 +533,7 @@ MachThreadList::ShouldStop(bool &step_more) { PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); uint32_t should_stop = false; - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); for (uint32_t idx = 0; !should_stop && idx < num_threads; ++idx) { should_stop = m_threads[idx]->ShouldStop(step_more); @@ -546,7 +546,7 @@ void MachThreadList::NotifyBreakpointChanged (const DNBBreakpoint *bp) { PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); for (uint32_t idx = 0; idx < num_threads; ++idx) { m_threads[idx]->NotifyBreakpointChanged(bp); @@ -559,7 +559,7 @@ MachThreadList::EnableHardwareBreakpoint (const DNBBreakpoint* bp) const { if (bp != NULL) { - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); for (uint32_t idx = 0; idx < num_threads; ++idx) m_threads[idx]->EnableHardwareBreakpoint(bp); } @@ -571,7 +571,7 @@ MachThreadList::DisableHardwareBreakpoint (const DNBBreakpoint* bp) const { if (bp != NULL) { - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); for (uint32_t idx = 0; idx < num_threads; ++idx) m_threads[idx]->DisableHardwareBreakpoint(bp); } @@ -587,7 +587,7 @@ MachThreadList::EnableHardwareWatchpoint (const DNBBreakpoint* wp) const if (wp != NULL) { PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); // On Mac OS X we have to prime the control registers for new threads. We do this // using the control register data for the first thread, for lack of a better way of choosing. bool also_set_on_task = true; @@ -616,7 +616,7 @@ MachThreadList::DisableHardwareWatchpoint (const DNBBreakpoint* wp) const if (wp != NULL) { PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); // On Mac OS X we have to prime the control registers for new threads. We do this // using the control register data for the first thread, for lack of a better way of choosing. @@ -645,7 +645,7 @@ uint32_t MachThreadList::NumSupportedHardwareWatchpoints () const { PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); // Use an arbitrary thread to retrieve the number of supported hardware watchpoints. if (num_threads) return m_threads[0]->NumSupportedHardwareWatchpoints(); @@ -657,7 +657,7 @@ MachThreadList::GetThreadIndexForThreadStoppedWithSignal (const int signo) const { PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); uint32_t should_stop = false; - const uint32_t num_threads = m_threads.size(); + const size_t num_threads = m_threads.size(); for (uint32_t idx = 0; !should_stop && idx < num_threads; ++idx) { if (m_threads[idx]->GetStopException().SoftSignal () == signo) diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.h b/lldb/tools/debugserver/source/MacOSX/MachThreadList.h index 5fac2c4b457..0ab550e83fc 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.h +++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.h @@ -27,8 +27,8 @@ public: void Clear (); void Dump () const; - bool GetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value) const; - bool SetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, const DNBRegisterValue *reg_value) const; + bool GetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, DNBRegisterValue *reg_value) const; + bool SetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, const DNBRegisterValue *reg_value) const; nub_size_t GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len); nub_size_t SetRegisterContext (nub_thread_t tid, const void *buf, size_t buf_len); uint32_t SaveRegisterState (nub_thread_t tid); diff --git a/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp b/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp index 76e3177bf59..ea36ea286c0 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp @@ -180,27 +180,39 @@ MachVMMemory::GetStolenPages(task_t task) /* These are all declared as QUAD/uint64_t sysctls in the kernel. */ - if(-1 == sysctl(mib_reserved, mib_reserved_len, &reserved, - &reserved_len, NULL, 0)) + if (sysctl (mib_reserved, + static_cast<u_int>(mib_reserved_len), + &reserved, + &reserved_len, + NULL, + 0)) { return 0; } - if(-1 == sysctl(mib_unusable, mib_unusable_len, &unusable, - &unusable_len, NULL, 0)) + if (sysctl (mib_unusable, + static_cast<u_int>(mib_unusable_len), + &unusable, + &unusable_len, + NULL, + 0)) { return 0; } - if(-1 == sysctl(mib_other, mib_other_len, &other, - &other_len, NULL, 0)) + if (sysctl (mib_other, + static_cast<u_int>(mib_other_len), + &other, + &other_len, + NULL, + 0)) { return 0; } - if(reserved_len == sizeof(reserved) - && unusable_len == sizeof(unusable) - && other_len == sizeof(other)) + if (reserved_len == sizeof(reserved) && + unusable_len == sizeof(unusable) && + other_len == sizeof(other)) { uint64_t stolen = reserved + unusable + other; uint64_t mb128 = 128 * 1024 * 1024ULL; @@ -546,7 +558,7 @@ MachVMMemory::WriteRegion(task_t task, const nub_addr_t address, const void *dat const uint8_t *curr_data = (const uint8_t*)data; while (total_bytes_written < data_count) { - mach_msg_type_number_t curr_data_count = MaxBytesLeftInPage(task, curr_addr, data_count - total_bytes_written); + mach_msg_type_number_t curr_data_count = static_cast<mach_msg_type_number_t>(MaxBytesLeftInPage(task, curr_addr, data_count - total_bytes_written)); m_err = ::mach_vm_write (task, curr_addr, (pointer_t) curr_data, curr_data_count); if (DNBLogCheckLogBit(LOG_MEMORY) || m_err.Fail()) m_err.LogThreaded("::mach_vm_write ( task = 0x%4.4x, addr = 0x%8.8llx, data = %8.8p, dataCnt = %u )", task, (uint64_t)curr_addr, curr_data, curr_data_count); diff --git a/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp b/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp index 5f9171f6f68..b3c7af5cac6 100644 --- a/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp +++ b/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp @@ -1738,7 +1738,7 @@ DNBArchMachARM::GetRegisterSetInfo(nub_size_t *num_reg_sets) } bool -DNBArchMachARM::GetRegisterValue(int set, int reg, DNBRegisterValue *value) +DNBArchMachARM::GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value) { if (set == REGISTER_SET_GENERIC) { @@ -1861,7 +1861,7 @@ DNBArchMachARM::GetRegisterValue(int set, int reg, DNBRegisterValue *value) } bool -DNBArchMachARM::SetRegisterValue(int set, int reg, const DNBRegisterValue *value) +DNBArchMachARM::SetRegisterValue(uint32_t set, uint32_t reg, const DNBRegisterValue *value) { if (set == REGISTER_SET_GENERIC) { diff --git a/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h b/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h index 3efad79badb..41b8d23f99f 100644 --- a/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h +++ b/lldb/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h @@ -53,8 +53,8 @@ public: static const DNBRegisterSetInfo * GetRegisterSetInfo(nub_size_t *num_reg_sets); - virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value); - virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *value); + virtual bool GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value); + virtual bool SetRegisterValue(uint32_t set, uint32_t reg, const DNBRegisterValue *value); virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len); virtual nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len); virtual uint32_t SaveRegisterState (); diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp index f6b53635018..54a65719721 100644 --- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp +++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp @@ -1722,7 +1722,7 @@ DNBArchMachARM64::FixGenericRegisterNumber (int &set, int ®) return true; } bool -DNBArchMachARM64::GetRegisterValue(int set, int reg, DNBRegisterValue *value) +DNBArchMachARM64::GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value) { if (!FixGenericRegisterNumber (set, reg)) return false; @@ -1821,7 +1821,7 @@ DNBArchMachARM64::GetRegisterValue(int set, int reg, DNBRegisterValue *value) } bool -DNBArchMachARM64::SetRegisterValue(int set, int reg, const DNBRegisterValue *value) +DNBArchMachARM64::SetRegisterValue(uint32_t set, uint32_t reg, const DNBRegisterValue *value) { if (!FixGenericRegisterNumber (set, reg)) return false; diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h index 8f09659c878..d00408c4185 100644 --- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h +++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h @@ -48,8 +48,8 @@ public: static const DNBRegisterSetInfo * GetRegisterSetInfo(nub_size_t *num_reg_sets); - virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value); - virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *value); + virtual bool GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value); + virtual bool SetRegisterValue(uint32_t set, uint32_t reg, const DNBRegisterValue *value); virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len); virtual nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len); virtual uint32_t SaveRegisterState (); diff --git a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp index 0be173991f1..d760d073729 100644 --- a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp +++ b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp @@ -295,7 +295,7 @@ DNBArchImplI386::SetPC(uint64_t value) kern_return_t err = GetGPRState(false); if (err == KERN_SUCCESS) { - m_state.context.gpr.__eip = value; + m_state.context.gpr.__eip = static_cast<uint32_t>(value); err = SetGPRState(); } return err == KERN_SUCCESS; @@ -670,7 +670,7 @@ DNBArchImplI386::NotifyException(MachException::Data& exc) // is at the address following the single byte trap instruction. if (m_state.context.gpr.__eip > 0) { - m_state.context.gpr.__eip = pc; + m_state.context.gpr.__eip = static_cast<uint32_t>(pc); // Write the new PC back out SetGPRState (); } @@ -1282,7 +1282,7 @@ DNBArchImplI386::Initialize() } bool -DNBArchImplI386::GetRegisterValue(int set, int reg, DNBRegisterValue *value) +DNBArchImplI386::GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value) { if (set == REGISTER_SET_GENERIC) { @@ -1429,7 +1429,7 @@ DNBArchImplI386::GetRegisterValue(int set, int reg, DNBRegisterValue *value) bool -DNBArchImplI386::SetRegisterValue(int set, int reg, const DNBRegisterValue *value) +DNBArchImplI386::SetRegisterValue(uint32_t set, uint32_t reg, const DNBRegisterValue *value) { if (set == REGISTER_SET_GENERIC) { @@ -1617,7 +1617,7 @@ DNBArchImplI386::GetRegisterContext (void *buf, nub_size_t buf_len) if (buf && buf_len) { if (size > buf_len) - size = buf_len; + size = static_cast<uint32_t>(buf_len); bool force = false; kern_return_t kret; diff --git a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h index 611aa48a160..f4475cdccda 100644 --- a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h +++ b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h @@ -42,8 +42,8 @@ public: static void Initialize(); - virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value); - virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *value); + virtual bool GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value); + virtual bool SetRegisterValue(uint32_t set, uint32_t reg, const DNBRegisterValue *value); virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len); virtual nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len); virtual uint32_t SaveRegisterState (); diff --git a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp index bd275188420..fa0bd3df12c 100644 --- a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp +++ b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp @@ -418,7 +418,7 @@ DNBArchMachPPC::GetRegisterSetInfo(nub_size_t *num_reg_sets) const } bool -DNBArchMachPPC::GetRegisterValue(int set, int reg, DNBRegisterValue *value) const +DNBArchMachPPC::GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value) const { if (set == REGISTER_SET_GENERIC) { diff --git a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h index a787d14d8d4..88fdbd7401d 100644 --- a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h +++ b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h @@ -35,7 +35,7 @@ public: virtual const DNBRegisterSetInfo * GetRegisterSetInfo(nub_size_t *num_reg_sets) const; - virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value) const; + virtual bool GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value) const; virtual kern_return_t GetRegisterState (int set, bool force); virtual kern_return_t SetRegisterState (int set); virtual bool RegisterSetStateIsValid (int set) const; diff --git a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp index da30f761341..735312e305f 100644 --- a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp +++ b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp @@ -1602,7 +1602,7 @@ DNBArchImplX86_64::Initialize() } bool -DNBArchImplX86_64::GetRegisterValue(int set, int reg, DNBRegisterValue *value) +DNBArchImplX86_64::GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value) { if (set == REGISTER_SET_GENERIC) { @@ -1781,7 +1781,7 @@ DNBArchImplX86_64::GetRegisterValue(int set, int reg, DNBRegisterValue *value) bool -DNBArchImplX86_64::SetRegisterValue(int set, int reg, const DNBRegisterValue *value) +DNBArchImplX86_64::SetRegisterValue(uint32_t set, uint32_t reg, const DNBRegisterValue *value) { if (set == REGISTER_SET_GENERIC) { @@ -2109,7 +2109,7 @@ DNBArchImplX86_64::SetRegisterContext (const void *buf, nub_size_t buf_len) if (size) { if (size > buf_len) - size = buf_len; + size = static_cast<uint32_t>(buf_len); uint8_t *p = (uint8_t *)buf; // Copy the GPR registers diff --git a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h index e9ba50f7ab6..9bc6045c88b 100644 --- a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h +++ b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h @@ -40,8 +40,8 @@ public: static void Initialize(); - virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value); - virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *value); + virtual bool GetRegisterValue(uint32_t set, uint32_t reg, DNBRegisterValue *value); + virtual bool SetRegisterValue(uint32_t set, uint32_t reg, const DNBRegisterValue *value); virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len); virtual nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len); virtual uint32_t SaveRegisterState (); diff --git a/lldb/tools/debugserver/source/RNBContext.cpp b/lldb/tools/debugserver/source/RNBContext.cpp index 960d6d99c9d..74ba5c45cb4 100644 --- a/lldb/tools/debugserver/source/RNBContext.cpp +++ b/lldb/tools/debugserver/source/RNBContext.cpp @@ -40,7 +40,7 @@ RNBContext::~RNBContext() //---------------------------------------------------------------------- const char * -RNBContext::EnvironmentAtIndex (int index) +RNBContext::EnvironmentAtIndex (size_t index) { if (index < m_env_vec.size()) return m_env_vec[index].c_str(); @@ -50,7 +50,7 @@ RNBContext::EnvironmentAtIndex (int index) const char * -RNBContext::ArgumentAtIndex (int index) +RNBContext::ArgumentAtIndex (size_t index) { if (index < m_arg_vec.size()) return m_arg_vec[index].c_str(); diff --git a/lldb/tools/debugserver/source/RNBContext.h b/lldb/tools/debugserver/source/RNBContext.h index 3ca01c1e53a..34fb9796ebe 100644 --- a/lldb/tools/debugserver/source/RNBContext.h +++ b/lldb/tools/debugserver/source/RNBContext.h @@ -85,13 +85,13 @@ public: nub_event_t StickyEventBits() const { return sticky_event_bits; } const char* EventsAsString (nub_event_t events, std::string& s); - int ArgumentCount () const { return m_arg_vec.size(); } - const char * ArgumentAtIndex (int index); + size_t ArgumentCount () const { return m_arg_vec.size(); } + const char * ArgumentAtIndex (size_t index); void PushArgument (const char *arg) { if (arg) m_arg_vec.push_back (arg); } void ClearArgv () { m_arg_vec.erase (m_arg_vec.begin(), m_arg_vec.end()); } - int EnvironmentCount () const { return m_env_vec.size(); } - const char * EnvironmentAtIndex (int index); + size_t EnvironmentCount () const { return m_env_vec.size(); } + const char * EnvironmentAtIndex (size_t index); void PushEnvironment (const char *arg) { if (arg) m_env_vec.push_back (arg); } void ClearEnvironment () { m_env_vec.erase (m_env_vec.begin(), m_env_vec.end()); } DNBError& LaunchStatus () { return m_launch_status; } diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index 8f419e7d6e0..3acf7b046d5 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -395,10 +395,10 @@ RNBRemote::GetPacketPayload (std::string &return_packet) case '$': { - int packet_checksum = 0; + long packet_checksum = 0; if (!m_noack_mode) { - for (int i = return_packet.size() - 2; i < return_packet.size(); ++i) + for (size_t i = return_packet.size() - 2; i < return_packet.size(); ++i) { char checksum_char = tolower (return_packet[i]); if (!isxdigit (checksum_char)) @@ -432,7 +432,7 @@ RNBRemote::GetPacketPayload (std::string &return_packet) } else { - DNBLogThreadedIf (LOG_RNB_MEDIUM, "%8u RNBRemote::%s sending ACK for '%s' (error: packet checksum mismatch (0x%2.2x != 0x%2.2x))", + DNBLogThreadedIf (LOG_RNB_MEDIUM, "%8u RNBRemote::%s sending ACK for '%s' (error: packet checksum mismatch (0x%2.2lx != 0x%2.2x))", (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__, return_packet.c_str(), @@ -615,7 +615,7 @@ RNBRemote::CommDataReceived(const std::string& new_data) data += new_data; // Parse up the packets into gdb remote packets - uint32_t idx = 0; + size_t idx = 0; const size_t data_size = data.size(); while (idx < data_size) @@ -1120,7 +1120,7 @@ RNBRemote::HandlePacket_A (const char *p) while (*buf != '\0') { - int arglen, argnum; + unsigned long arglen, argnum; std::string arg; char *c; @@ -1158,7 +1158,7 @@ RNBRemote::HandlePacket_A (const char *p) smallbuf[2] = '\0'; errno = 0; - int ch = strtoul (smallbuf, NULL, 16); + int ch = static_cast<int>(strtoul (smallbuf, NULL, 16)); if (errno != 0 && ch == 0) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in arg on 'A' pkt"); @@ -1424,7 +1424,7 @@ RNBRemote::HandlePacket_qRcmd (const char *p) { char smallbuf[3] = { c[0], c[1], '\0' }; errno = 0; - int ch = strtoul (smallbuf, NULL, 16); + int ch = static_cast<int>(strtoul (smallbuf, NULL, 16)); if (errno != 0 && ch == 0) return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in payload of qRcmd packet"); line.push_back(ch); @@ -1452,7 +1452,7 @@ RNBRemote::HandlePacket_qRcmd (const char *p) { char *end; errno = 0; - uint32_t logmask = strtoul (value.c_str(), &end, 0); + uint32_t logmask = static_cast<uint32_t>(strtoul (value.c_str(), &end, 0)); if (errno == 0 && end && *end == '\0') { DNBLogSetLogMask (logmask); @@ -1461,7 +1461,7 @@ RNBRemote::HandlePacket_qRcmd (const char *p) return SendPacket ("OK"); } errno = 0; - logmask = strtoul (value.c_str(), &end, 16); + logmask = static_cast<uint32_t>(strtoul (value.c_str(), &end, 16)); if (errno == 0 && end && *end == '\0') { DNBLogSetLogMask (logmask); @@ -1522,7 +1522,7 @@ RNBRemote::HandlePacket_qRegisterInfo (const char *p) nub_size_t num_reg_sets = 0; const DNBRegisterSetInfo *reg_set_info = DNBGetRegisterSetInfo (&num_reg_sets); - uint32_t reg_num = strtoul(p, 0, 16); + uint32_t reg_num = static_cast<uint32_t>(strtoul(p, 0, 16)); if (reg_num < g_num_reg_entries) { @@ -2087,7 +2087,7 @@ RNBRemote::HandlePacket_QSetMaxPayloadSize (const char *p) in this size. */ p += sizeof ("QSetMaxPayloadSize:") - 1; errno = 0; - uint32_t size = strtoul (p, NULL, 16); + uint32_t size = static_cast<uint32_t>(strtoul (p, NULL, 16)); if (errno != 0 && size == 0) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Invalid length in QSetMaxPayloadSize packet"); @@ -2104,7 +2104,7 @@ RNBRemote::HandlePacket_QSetMaxPacketSize (const char *p) QSetMaxPayloadSize is preferred because it is less ambiguous. */ p += sizeof ("QSetMaxPacketSize:") - 1; errno = 0; - uint32_t size = strtoul (p, NULL, 16); + uint32_t size = static_cast<uint32_t>(strtoul (p, NULL, 16)); if (errno != 0 && size == 0) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Invalid length in QSetMaxPacketSize packet"); @@ -2165,7 +2165,7 @@ RNBRemote::HandlePacket_QEnvironmentHexEncoded (const char *p) smallbuf[1] = *(c + 1); smallbuf[2] = '\0'; errno = 0; - int ch = strtoul (smallbuf, NULL, 16); + int ch = static_cast<int>(strtoul (smallbuf, NULL, 16)); if (errno != 0 && ch == 0) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in arg on 'QEnvironmentHexEncoded' pkt"); @@ -2217,7 +2217,7 @@ append_hex_value (std::ostream& ostrm, const uint8_t* buf, size_t buf_size, bool int i; if (swap) { - for (i = buf_size-1; i >= 0; i--) + for (i = static_cast<int>(buf_size)-1; i >= 0; i--) ostrm << RAWHEX8(buf[i]); } else @@ -2330,7 +2330,7 @@ RNBRemote::SendStopReplyPacketForThread (nub_thread_t tid) case EXC_SOFTWARE: if (tid_stop_info.details.exception.data_count == 2 && tid_stop_info.details.exception.data[0] == EXC_SOFT_SIGNAL) - signum = tid_stop_info.details.exception.data[1]; + signum = static_cast<int>(tid_stop_info.details.exception.data[1]); else signum = TARGET_EXC_SOFTWARE; break; @@ -2540,7 +2540,7 @@ RNBRemote::HandlePacket_M (const char *p) p += (c - p) + 1; errno = 0; - uint32_t length = strtoul (p, &c, 16); + unsigned long length = strtoul (p, &c, 16); if (errno != 0 && length == 0) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Invalid length in M packet"); @@ -2557,7 +2557,7 @@ RNBRemote::HandlePacket_M (const char *p) /* Advance 'p' to the data part of the packet. */ p += (c - p) + 1; - int datalen = strlen (p); + size_t datalen = strlen (p); if (datalen & 0x1) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Uneven # of hex chars for data in M packet"); @@ -2619,7 +2619,7 @@ RNBRemote::HandlePacket_m (const char *p) p += (c - p) + 1; errno = 0; - uint32_t length = strtoul (p, NULL, 16); + auto length = strtoul (p, NULL, 16); if (errno != 0 && length == 0) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Invalid length in m packet"); @@ -2634,7 +2634,7 @@ RNBRemote::HandlePacket_m (const char *p) { return SendPacket ("E78"); } - int bytes_read = DNBProcessMemoryRead (m_ctx.ProcessID(), addr, buf.size(), &buf[0]); + nub_size_t bytes_read = DNBProcessMemoryRead (m_ctx.ProcessID(), addr, buf.size(), &buf[0]); if (bytes_read == 0) { return SendPacket ("E08"); @@ -2686,7 +2686,7 @@ RNBRemote::HandlePacket_x (const char *p) p += (c - p) + 1; errno = 0; - int length = strtoul (p, NULL, 16); + auto length = strtoul (p, NULL, 16); if (errno != 0) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Invalid length in x packet"); @@ -2704,7 +2704,7 @@ RNBRemote::HandlePacket_x (const char *p) { return SendPacket ("E79"); } - int bytes_read = DNBProcessMemoryRead (m_ctx.ProcessID(), addr, buf.size(), &buf[0]); + nub_size_t bytes_read = DNBProcessMemoryRead (m_ctx.ProcessID(), addr, buf.size(), &buf[0]); if (bytes_read == 0) { return SendPacket ("E80"); @@ -2760,7 +2760,7 @@ RNBRemote::HandlePacket_X (const char *p) p += (c - p) + 1; errno = 0; - int length = strtoul (p, NULL, 16); + auto length = strtoul (p, NULL, 16); if (errno != 0 && length == 0) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Invalid length in X packet"); @@ -3067,7 +3067,7 @@ GetProcessNameFrom_vAttach (const char *&p, std::string &attach_name) smallbuf[2] = '\0'; errno = 0; - int ch = strtoul (smallbuf, NULL, 16); + int ch = static_cast<int>(strtoul (smallbuf, NULL, 16)); if (errno != 0 && ch == 0) { return_val = false; @@ -3145,7 +3145,7 @@ RNBRemote::HandlePacket_v (const char *p) { case 'C': errno = 0; - thread_action.signal = strtoul (c, &c, 16); + thread_action.signal = static_cast<int>(strtoul (c, &c, 16)); if (errno != 0) return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Could not parse signal in vCont packet"); // Fall through to next case... @@ -3157,7 +3157,7 @@ RNBRemote::HandlePacket_v (const char *p) case 'S': errno = 0; - thread_action.signal = strtoul (c, &c, 16); + thread_action.signal = static_cast<int>(strtoul (c, &c, 16)); if (errno != 0) return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Could not parse signal in vCont packet"); // Fall through to next case... @@ -3232,7 +3232,7 @@ RNBRemote::HandlePacket_v (const char *p) { p += strlen("vAttach;"); char *end = NULL; - attach_pid = strtoul (p, &end, 16); // PID will be in hex, so use base 16 to decode + attach_pid = static_cast<int>(strtoul (p, &end, 16)); // PID will be in hex, so use base 16 to decode if (p != end && *end == '\0') { // Wait at most 30 second for attach @@ -3331,7 +3331,7 @@ RNBRemote::HandlePacket_z (const char *p) return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Comma separator missing in z packet"); errno = 0; - uint32_t byte_size = strtoul (p, &c, 16); + auto byte_size = strtoul (p, &c, 16); if (errno != 0 && byte_size == 0) return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Invalid length in z packet"); @@ -3472,7 +3472,7 @@ RNBRemote::HandlePacket_p (const char *p) nub_process_t pid = m_ctx.ProcessID(); errno = 0; char *tid_cstr = NULL; - uint32_t reg = strtoul (p + 1, &tid_cstr, 16); + uint32_t reg = static_cast<uint32_t>(strtoul (p + 1, &tid_cstr, 16)); if (errno != 0 && reg == 0) { return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Could not parse register number in p packet"); @@ -3822,7 +3822,7 @@ RNBRemote::HandlePacket_C (const char *p) action.tid = GetContinueThread(); char *end = NULL; errno = 0; - process_signo = strtoul (p + 1, &end, 16); + process_signo = static_cast<int>(strtoul (p + 1, &end, 16)); if (errno != 0) return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Could not parse signal in C packet"); else if (*end == ';') @@ -3944,7 +3944,7 @@ RNBRemote::HandlePacket_S (const char *p) { char *end = NULL; errno = 0; - action.signal = strtoul (p + 1, &end, 16); + action.signal = static_cast<int>(strtoul (p + 1, &end, 16)); if (errno != 0) return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Could not parse signal in S packet"); else if (*end == ';') @@ -4059,10 +4059,11 @@ RNBRemote::HandlePacket_qGDBServerVersion (const char *p) { std::ostringstream strm; - if (DEBUGSERVER_PROGRAM_NAME) - strm << "name:" DEBUGSERVER_PROGRAM_NAME ";"; - else - strm << "name:debugserver;"; +#if defined(DEBUGSERVER_PROGRAM_NAME) + strm << "name:" DEBUGSERVER_PROGRAM_NAME ";"; +#else + strm << "name:debugserver;"; +#endif strm << "version:" << DEBUGSERVER_VERSION_STR << ";"; return SendPacket (strm.str()); @@ -4496,8 +4497,10 @@ RNBRemote::HandlePacket_qProcessInfo (const char *p) kern_return_t kr; x86_thread_state_t gp_regs; mach_msg_type_number_t gp_count = x86_THREAD_STATE_COUNT; - kr = thread_get_state (thread, x86_THREAD_STATE, - (thread_state_t) &gp_regs, &gp_count); + kr = thread_get_state (static_cast<thread_act_t>(thread), + x86_THREAD_STATE, + (thread_state_t) &gp_regs, + &gp_count); if (kr == KERN_SUCCESS) { if (gp_regs.tsh.flavor == x86_THREAD_STATE64) diff --git a/lldb/tools/debugserver/source/RNBSocket.cpp b/lldb/tools/debugserver/source/RNBSocket.cpp index 7772d6829b6..d4e838daa26 100644 --- a/lldb/tools/debugserver/source/RNBSocket.cpp +++ b/lldb/tools/debugserver/source/RNBSocket.cpp @@ -349,7 +349,7 @@ RNBSocket::Read (std::string &p) //DNBLogThreadedIf(LOG_RNB_COMM, "%8u RNBSocket::%s calling read()", (uint32_t)m_timer.ElapsedMicroSeconds(true), __FUNCTION__); DNBError err; - int bytesread = read (m_fd, buf, sizeof (buf)); + ssize_t bytesread = read (m_fd, buf, sizeof (buf)); if (bytesread <= 0) err.SetError(errno, DNBError::POSIX); else @@ -385,7 +385,7 @@ RNBSocket::Write (const void *buffer, size_t length) return rnb_err; DNBError err; - int bytessent = write (m_fd, buffer, length); + ssize_t bytessent = write (m_fd, buffer, length); if (bytessent < 0) err.SetError(errno, DNBError::POSIX); diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index 2c275111775..2f8c3dce117 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -684,7 +684,7 @@ PortWasBoundCallbackUnixSocket (const void *baton, in_port_t port) saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0'; saddr_un.sun_len = SUN_LEN (&saddr_un); - if (::connect (s, (struct sockaddr *)&saddr_un, SUN_LEN (&saddr_un)) < 0) + if (::connect (s, (struct sockaddr *)&saddr_un, static_cast<socklen_t>(SUN_LEN (&saddr_un))) < 0) { perror("error: connect (socket, &saddr_un, saddr_un_len)"); exit(1); @@ -699,7 +699,7 @@ PortWasBoundCallbackUnixSocket (const void *baton, in_port_t port) char pid_str[64]; const int pid_str_len = ::snprintf (pid_str, sizeof(pid_str), "%u", port); - const int bytes_sent = ::send (s, pid_str, pid_str_len, 0); + const ssize_t bytes_sent = ::send (s, pid_str, pid_str_len, 0); if (pid_str_len != bytes_sent) { @@ -1014,7 +1014,7 @@ main (int argc, char *argv[]) if (isdigit(optarg[0])) { char *end = NULL; - attach_pid = strtoul(optarg, &end, 0); + attach_pid = static_cast<int>(strtoul(optarg, &end, 0)); if (end == NULL || *end != '\0') { RNBLogSTDERR ("error: invalid pid option '%s'\n", optarg); @@ -1043,7 +1043,7 @@ main (int argc, char *argv[]) if (optarg && optarg[0]) { char *end = NULL; - waitfor_interval = strtoul(optarg, &end, 0); + waitfor_interval = static_cast<useconds_t>(strtoul(optarg, &end, 0)); if (end == NULL || *end != '\0') { RNBLogSTDERR ("error: invalid waitfor-interval option value '%s'.\n", optarg); @@ -1057,7 +1057,7 @@ main (int argc, char *argv[]) if (optarg && optarg[0]) { char *end = NULL; - waitfor_duration = strtoul(optarg, &end, 0); + waitfor_duration = static_cast<useconds_t>(strtoul(optarg, &end, 0)); if (end == NULL || *end != '\0') { RNBLogSTDERR ("error: invalid waitfor-duration option value '%s'.\n", optarg); @@ -1134,7 +1134,7 @@ main (int argc, char *argv[]) case 'f': // Log Flags if (optarg && optarg[0]) - log_flags = strtoul(optarg, NULL, 0); + log_flags = static_cast<uint32_t>(strtoul(optarg, NULL, 0)); break; case 'g': |

