mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 18:11:19 +00:00
Remove the UUID::GetAsCString() method which required a buffer to save the
UUID string in; added UUID::GetAsString() which returns the uuid string in a std::string. Updated callers to use the new method. llvm-svn: 181078
This commit is contained in:
parent
47752e489e
commit
c16b4af0d7
@ -54,8 +54,8 @@ public:
|
||||
void
|
||||
SetBytes (const void *uuid_bytes);
|
||||
|
||||
char *
|
||||
GetAsCString (char *dst, size_t dst_len) const;
|
||||
std::string
|
||||
GetAsString () const;
|
||||
|
||||
size_t
|
||||
SetFromCString (const char *c_str);
|
||||
|
@ -180,15 +180,22 @@ SBModule::GetUUIDString () const
|
||||
{
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
||||
|
||||
static char uuid_string[80];
|
||||
const char * uuid_c_string = NULL;
|
||||
static char uuid_string_buffer[80];
|
||||
const char *uuid_c_string = NULL;
|
||||
std::string uuid_string;
|
||||
ModuleSP module_sp (GetSP ());
|
||||
if (module_sp)
|
||||
uuid_c_string = (const char *)module_sp->GetUUID().GetAsCString(uuid_string, sizeof(uuid_string));
|
||||
uuid_string = module_sp->GetUUID().GetAsString();
|
||||
|
||||
if (!uuid_string.empty())
|
||||
{
|
||||
strncpy (uuid_string_buffer, uuid_string.c_str(), sizeof (uuid_string_buffer));
|
||||
uuid_c_string = uuid_string_buffer;
|
||||
}
|
||||
|
||||
if (log)
|
||||
{
|
||||
if (uuid_c_string)
|
||||
if (!uuid_string.empty())
|
||||
{
|
||||
StreamString s;
|
||||
module_sp->GetUUID().Dump (&s);
|
||||
|
@ -2928,7 +2928,7 @@ protected:
|
||||
}
|
||||
else
|
||||
{
|
||||
char uuid_cstr[64];
|
||||
std::string uuid_str;
|
||||
|
||||
if (module_spec.GetFileSpec())
|
||||
module_spec.GetFileSpec().GetPath (path, sizeof(path));
|
||||
@ -2936,16 +2936,14 @@ protected:
|
||||
path[0] = '\0';
|
||||
|
||||
if (module_spec.GetUUIDPtr())
|
||||
module_spec.GetUUID().GetAsCString(uuid_cstr, sizeof(uuid_cstr));
|
||||
else
|
||||
uuid_cstr[0] = '\0';
|
||||
uuid_str = module_spec.GetUUID().GetAsString();
|
||||
if (num_matches > 1)
|
||||
{
|
||||
result.AppendErrorWithFormat ("multiple modules match%s%s%s%s:\n",
|
||||
path[0] ? " file=" : "",
|
||||
path,
|
||||
uuid_cstr[0] ? " uuid=" : "",
|
||||
uuid_cstr);
|
||||
!uuid_str.empty() ? " uuid=" : "",
|
||||
uuid_str.c_str());
|
||||
for (size_t i=0; i<num_matches; ++i)
|
||||
{
|
||||
if (matching_modules.GetModulePointerAtIndex(i)->GetFileSpec().GetPath (path, sizeof(path)))
|
||||
@ -2957,8 +2955,8 @@ protected:
|
||||
result.AppendErrorWithFormat ("no modules were found that match%s%s%s%s.\n",
|
||||
path[0] ? " file=" : "",
|
||||
path,
|
||||
uuid_cstr[0] ? " uuid=" : "",
|
||||
uuid_cstr);
|
||||
!uuid_str.empty() ? " uuid=" : "",
|
||||
uuid_str.c_str());
|
||||
}
|
||||
result.SetStatus (eReturnStatusFailed);
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -364,9 +364,7 @@ LocateMacOSXFilesUsingDebugSymbols
|
||||
CFDictionaryRef uuid_dict = NULL;
|
||||
if (dict.get())
|
||||
{
|
||||
char uuid_cstr_buf[64];
|
||||
const char *uuid_cstr = uuid->GetAsCString (uuid_cstr_buf, sizeof(uuid_cstr_buf));
|
||||
CFCString uuid_cfstr (uuid_cstr);
|
||||
CFCString uuid_cfstr (uuid->GetAsString().c_str());
|
||||
uuid_dict = static_cast<CFDictionaryRef>(::CFDictionaryGetValue (dict.get(), uuid_cfstr.get()));
|
||||
if (uuid_dict)
|
||||
{
|
||||
@ -719,21 +717,19 @@ Symbols::DownloadObjectAndSymbolFile (ModuleSpec &module_spec, bool force_lookup
|
||||
}
|
||||
if (g_dsym_for_uuid_exe_exists)
|
||||
{
|
||||
char uuid_cstr_buffer[64];
|
||||
std::string uuid_str;
|
||||
char file_path[PATH_MAX];
|
||||
uuid_cstr_buffer[0] = '\0';
|
||||
file_path[0] = '\0';
|
||||
const char *uuid_cstr = NULL;
|
||||
|
||||
if (uuid_ptr)
|
||||
uuid_cstr = uuid_ptr->GetAsCString(uuid_cstr_buffer, sizeof(uuid_cstr_buffer));
|
||||
uuid_str = uuid_ptr->GetAsString();
|
||||
|
||||
if (file_spec_ptr)
|
||||
file_spec_ptr->GetPath(file_path, sizeof(file_path));
|
||||
|
||||
StreamString command;
|
||||
if (uuid_cstr)
|
||||
command.Printf("%s --ignoreNegativeCache --copyExecutable %s", g_dsym_for_uuid_exe_path, uuid_cstr);
|
||||
if (!uuid_str.empty())
|
||||
command.Printf("%s --ignoreNegativeCache --copyExecutable %s", g_dsym_for_uuid_exe_path, uuid_str.c_str());
|
||||
else if (file_path && file_path[0])
|
||||
command.Printf("%s --ignoreNegativeCache --copyExecutable %s", g_dsym_for_uuid_exe_path, file_path);
|
||||
|
||||
@ -760,9 +756,9 @@ Symbols::DownloadObjectAndSymbolFile (ModuleSpec &module_spec, bool force_lookup
|
||||
|
||||
if (plist.get() && CFGetTypeID (plist.get()) == CFDictionaryGetTypeID ())
|
||||
{
|
||||
if (uuid_cstr)
|
||||
if (!uuid_str.empty())
|
||||
{
|
||||
CFCString uuid_cfstr(uuid_cstr);
|
||||
CFCString uuid_cfstr(uuid_str.c_str());
|
||||
CFDictionaryRef uuid_dict = (CFDictionaryRef)CFDictionaryGetValue (plist.get(), uuid_cfstr.get());
|
||||
success = GetModuleSpecInfoFromUUIDDictionary (uuid_dict, module_spec);
|
||||
}
|
||||
|
@ -91,7 +91,6 @@ OptionValueUUID::AutoComplete (CommandInterpreter &interpreter,
|
||||
const size_t num_modules = target->GetImages().GetSize();
|
||||
if (num_modules > 0)
|
||||
{
|
||||
char uuid_cstr[64];
|
||||
UUID::ValueType uuid_bytes;
|
||||
const size_t num_bytes_decoded = UUID::DecodeUUIDBytesFromCString(s, uuid_bytes, NULL);
|
||||
for (size_t i=0; i<num_modules; ++i)
|
||||
@ -109,8 +108,10 @@ OptionValueUUID::AutoComplete (CommandInterpreter &interpreter,
|
||||
add_uuid = ::memcmp(module_uuid.GetBytes(), uuid_bytes, num_bytes_decoded) == 0;
|
||||
if (add_uuid)
|
||||
{
|
||||
if (module_uuid.GetAsCString(uuid_cstr, sizeof(uuid_cstr)))
|
||||
matches.AppendString(uuid_cstr);
|
||||
std::string uuid_str;
|
||||
uuid_str = module_uuid.GetAsString();
|
||||
if (!uuid_str.empty())
|
||||
matches.AppendString(uuid_str.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -720,11 +720,9 @@ DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule (Process *process)
|
||||
Stream *s = &process->GetTarget().GetDebugger().GetOutputStream();
|
||||
if (s)
|
||||
{
|
||||
char memory_module_uuidbuf[64];
|
||||
char exe_module_uuidbuf[64];
|
||||
s->Printf ("warning: Host-side kernel file has Mach-O UUID of %s but remote kernel has a UUID of %s -- a mismatched kernel file will result in a poor debugger experience.\n",
|
||||
exe_module->GetUUID().GetAsCString(exe_module_uuidbuf, sizeof (exe_module_uuidbuf)),
|
||||
m_uuid.GetAsCString(memory_module_uuidbuf, sizeof (memory_module_uuidbuf)));
|
||||
exe_module->GetUUID().GetAsString().c_str(),
|
||||
m_uuid.GetAsString().c_str());
|
||||
s->Flush ();
|
||||
}
|
||||
}
|
||||
@ -770,8 +768,7 @@ DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule (Process *p
|
||||
Stream *s = &target.GetDebugger().GetOutputStream();
|
||||
if (s)
|
||||
{
|
||||
char uuidbuf[64];
|
||||
s->Printf ("Kernel UUID: %s\n", m_memory_module_sp->GetUUID().GetAsCString(uuidbuf, sizeof (uuidbuf)));
|
||||
s->Printf ("Kernel UUID: %s\n", m_memory_module_sp->GetUUID().GetAsString().c_str());
|
||||
s->Printf ("Load Address: 0x%" PRIx64 "\n", m_load_address);
|
||||
}
|
||||
}
|
||||
@ -872,9 +869,8 @@ DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule (Process *p
|
||||
Stream *s = &target.GetDebugger().GetOutputStream();
|
||||
if (s)
|
||||
{
|
||||
char uuidbuf[64];
|
||||
s->Printf ("warning: Can't find binary/dSYM for %s (%s)\n",
|
||||
m_name.c_str(), m_uuid.GetAsCString(uuidbuf, sizeof (uuidbuf)));
|
||||
m_name.c_str(), m_uuid.GetAsString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,16 +208,15 @@ SymbolVendorMacOSX::CreateInstance (const lldb::ModuleSP &module_sp, lldb_privat
|
||||
lldb_private::UUID dsym_uuid;
|
||||
if (dsym_objfile_sp->GetUUID(&dsym_uuid))
|
||||
{
|
||||
char uuid_cstr_buf[64];
|
||||
const char *uuid_cstr = dsym_uuid.GetAsCString (uuid_cstr_buf, sizeof(uuid_cstr_buf));
|
||||
if (uuid_cstr)
|
||||
std::string uuid_str = dsym_uuid.GetAsString ();
|
||||
if (!uuid_str.empty())
|
||||
{
|
||||
char *resources = strstr (dsym_path, "/Contents/Resources/");
|
||||
if (resources)
|
||||
{
|
||||
char dsym_uuid_plist_path[PATH_MAX];
|
||||
resources[strlen("/Contents/Resources/")] = '\0';
|
||||
snprintf(dsym_uuid_plist_path, sizeof(dsym_uuid_plist_path), "%s%s.plist", dsym_path, uuid_cstr);
|
||||
snprintf(dsym_uuid_plist_path, sizeof(dsym_uuid_plist_path), "%s%s.plist", dsym_path, uuid_str.c_str());
|
||||
FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path, false);
|
||||
if (dsym_uuid_plist_spec.Exists())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user