diff options
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/ModuleList.cpp | 24 | ||||
-rw-r--r-- | lldb/source/Core/UUID.cpp | 18 |
2 files changed, 21 insertions, 21 deletions
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index ff5d22537c4..376d046eb61 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -651,17 +651,15 @@ ModuleList::LogUUIDAndPaths (Log *log, const char *prefix_cstr) if (log) { Mutex::Locker locker(m_modules_mutex); - char uuid_cstr[256]; collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end(); for (pos = begin; pos != end; ++pos) { Module *module = pos->get(); - module->GetUUID().GetAsCString (uuid_cstr, sizeof(uuid_cstr)); const FileSpec &module_file_spec = module->GetFileSpec(); log->Printf ("%s[%u] %s (%s) \"%s\"", prefix_cstr ? prefix_cstr : "", (uint32_t)std::distance (begin, pos), - uuid_cstr, + module->GetUUID().GetAsString().c_str(), module->GetArchitecture().GetArchitectureName(), module_file_spec.GetPath().c_str()); } @@ -806,7 +804,6 @@ ModuleList::GetSharedModule ModuleList &shared_module_list = GetSharedModuleList (); Mutex::Locker locker(shared_module_list.m_modules_mutex); char path[PATH_MAX]; - char uuid_cstr[64]; Error error; @@ -906,16 +903,14 @@ ModuleList::GetSharedModule module_file_spec.GetPath(path, sizeof(path)); if (file_spec.Exists()) { + std::string uuid_str; if (uuid_ptr && uuid_ptr->IsValid()) - uuid_ptr->GetAsCString(uuid_cstr, sizeof (uuid_cstr)); - else - uuid_cstr[0] = '\0'; - + uuid_str = uuid_ptr->GetAsString(); if (arch.IsValid()) { - if (uuid_cstr[0]) - error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s", path, arch.GetArchitectureName(), uuid_cstr); + if (!uuid_str.empty()) + error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s", path, arch.GetArchitectureName(), uuid_str.c_str()); else error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.", path, arch.GetArchitectureName()); } @@ -985,13 +980,12 @@ ModuleList::GetSharedModule } else { + std::string uuid_str; if (uuid_ptr && uuid_ptr->IsValid()) - uuid_ptr->GetAsCString(uuid_cstr, sizeof (uuid_cstr)); - else - uuid_cstr[0] = '\0'; + uuid_str = uuid_ptr->GetAsString(); - if (uuid_cstr[0]) - error.SetErrorStringWithFormat("cannot locate a module for UUID '%s'", uuid_cstr); + if (!uuid_str.empty()) + error.SetErrorStringWithFormat("cannot locate a module for UUID '%s'", uuid_str.c_str()); else error.SetErrorStringWithFormat("cannot locate a module"); } diff --git a/lldb/source/Core/UUID.cpp b/lldb/source/Core/UUID.cpp index bfd6c189032..e84c13ef02b 100644 --- a/lldb/source/Core/UUID.cpp +++ b/lldb/source/Core/UUID.cpp @@ -14,6 +14,8 @@ #include <ctype.h> // C++ Includes +#include <string> + // Other libraries and framework includes // Project includes #include "lldb/Core/Stream.h" @@ -62,16 +64,20 @@ UUID::GetBytes() const return m_uuid; } -char * -UUID::GetAsCString (char *dst, size_t dst_len) const +std::string +UUID::GetAsString () const { + std::string result; + char buf[64]; const uint8_t *u = (const uint8_t *)GetBytes(); - if (dst_len > snprintf (dst, - dst_len, + if (sizeof (buf) > snprintf (buf, + sizeof (buf), "%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X", u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15])) - return dst; - return NULL; + { + result.append (buf); + } + return result; } void |