Changeset View
Changeset View
Standalone View
Standalone View
source/Commands/CommandObjectTarget.cpp
Show First 20 Lines • Show All 2,231 Lines • ▼ Show 20 Lines | if (command.GetArgumentCount() == 0) { | ||||
// Dump all ASTs for all modules images | // Dump all ASTs for all modules images | ||||
result.GetOutputStream().Printf("Dumping clang ast for %" PRIu64 | result.GetOutputStream().Printf("Dumping clang ast for %" PRIu64 | ||||
" modules.\n", | " modules.\n", | ||||
(uint64_t)num_modules); | (uint64_t)num_modules); | ||||
for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { | for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { | ||||
if (m_interpreter.WasInterrupted()) | if (m_interpreter.WasInterrupted()) | ||||
break; | break; | ||||
Module *m = target->GetImages().GetModulePointerAtIndex(image_idx); | Module *m = target->GetImages().GetModulePointerAtIndex(image_idx); | ||||
SymbolFile *sf = m->GetSymbolVendor()->GetSymbolFile(); | m->GetSymbolFile()->DumpClangAST(result.GetOutputStream()); | ||||
clayborg: check m->GetSymbolFile() for NULL | |||||
sf->DumpClangAST(result.GetOutputStream()); | |||||
} | } | ||||
result.SetStatus(eReturnStatusSuccessFinishResult); | result.SetStatus(eReturnStatusSuccessFinishResult); | ||||
return true; | return true; | ||||
} | } | ||||
// Dump specified ASTs (by basename or fullpath) | // Dump specified ASTs (by basename or fullpath) | ||||
for (const Args::ArgEntry &arg : command.entries()) { | for (const Args::ArgEntry &arg : command.entries()) { | ||||
ModuleList module_list; | ModuleList module_list; | ||||
const size_t num_matches = | const size_t num_matches = | ||||
FindModulesByName(target, arg.c_str(), module_list, true); | FindModulesByName(target, arg.c_str(), module_list, true); | ||||
if (num_matches == 0) { | if (num_matches == 0) { | ||||
// Check the global list | // Check the global list | ||||
std::lock_guard<std::recursive_mutex> guard( | std::lock_guard<std::recursive_mutex> guard( | ||||
Module::GetAllocationModuleCollectionMutex()); | Module::GetAllocationModuleCollectionMutex()); | ||||
result.AppendWarningWithFormat( | result.AppendWarningWithFormat( | ||||
"Unable to find an image that matches '%s'.\n", arg.c_str()); | "Unable to find an image that matches '%s'.\n", arg.c_str()); | ||||
continue; | continue; | ||||
} | } | ||||
for (size_t i = 0; i < num_matches; ++i) { | for (size_t i = 0; i < num_matches; ++i) { | ||||
if (m_interpreter.WasInterrupted()) | if (m_interpreter.WasInterrupted()) | ||||
break; | break; | ||||
Module *m = module_list.GetModulePointerAtIndex(i); | Module *m = module_list.GetModulePointerAtIndex(i); | ||||
SymbolFile *sf = m->GetSymbolVendor()->GetSymbolFile(); | m->GetSymbolFile()->DumpClangAST(result.GetOutputStream()); | ||||
clayborgUnsubmitted Not Done ReplyInline Actionscheck m->GetSymbolFile() for NULL clayborg: check m->GetSymbolFile() for NULL | |||||
sf->DumpClangAST(result.GetOutputStream()); | |||||
} | } | ||||
} | } | ||||
result.SetStatus(eReturnStatusSuccessFinishResult); | result.SetStatus(eReturnStatusSuccessFinishResult); | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
#pragma mark CommandObjectTargetModulesDumpSymfile | #pragma mark CommandObjectTargetModulesDumpSymfile | ||||
▲ Show 20 Lines • Show All 969 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < num_entries; ++i) { | ||||
if (width) | if (width) | ||||
strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count); | strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count); | ||||
else | else | ||||
strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count); | strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count); | ||||
} break; | } break; | ||||
case 's': | case 's': | ||||
case 'S': { | case 'S': { | ||||
const SymbolVendor *symbol_vendor = module->GetSymbolVendor(); | if (const SymbolFile *symbol_file = module->GetSymbolFile()) { | ||||
if (symbol_vendor) { | const FileSpec symfile_spec = | ||||
const FileSpec symfile_spec = symbol_vendor->GetMainFileSpec(); | symbol_file->GetObjectFile()->GetFileSpec(); | ||||
if (format_char == 'S') { | if (format_char == 'S') { | ||||
// Dump symbol file only if different from module file | // Dump symbol file only if different from module file | ||||
if (!symfile_spec || symfile_spec == module->GetFileSpec()) { | if (!symfile_spec || symfile_spec == module->GetFileSpec()) { | ||||
print_space = false; | print_space = false; | ||||
break; | break; | ||||
} | } | ||||
// Add a newline and indent past the index | // Add a newline and indent past the index | ||||
strm.Printf("\n%*s", indent, ""); | strm.Printf("\n%*s", indent, ""); | ||||
▲ Show 20 Lines • Show All 916 Lines • ▼ Show 20 Lines | if (symbol_fspec) { | ||||
} else if (num_matches == 1) { | } else if (num_matches == 1) { | ||||
ModuleSP module_sp(matching_module_list.GetModuleAtIndex(0)); | ModuleSP module_sp(matching_module_list.GetModuleAtIndex(0)); | ||||
// The module has not yet created its symbol vendor, we can just give | // The module has not yet created its symbol vendor, we can just give | ||||
// the existing target module the symfile path to use for when it | // the existing target module the symfile path to use for when it | ||||
// decides to create it! | // decides to create it! | ||||
module_sp->SetSymbolFileFileSpec(symbol_fspec); | module_sp->SetSymbolFileFileSpec(symbol_fspec); | ||||
SymbolVendor *symbol_vendor = | SymbolFile *symbol_file = | ||||
module_sp->GetSymbolVendor(true, &result.GetErrorStream()); | module_sp->GetSymbolFile(true, &result.GetErrorStream()); | ||||
if (symbol_vendor) { | |||||
SymbolFile *symbol_file = symbol_vendor->GetSymbolFile(); | |||||
if (symbol_file) { | if (symbol_file) { | ||||
ObjectFile *object_file = symbol_file->GetObjectFile(); | ObjectFile *object_file = symbol_file->GetObjectFile(); | ||||
if (object_file && object_file->GetFileSpec() == symbol_fspec) { | if (object_file && object_file->GetFileSpec() == symbol_fspec) { | ||||
// Provide feedback that the symfile has been successfully added. | // Provide feedback that the symfile has been successfully added. | ||||
const FileSpec &module_fs = module_sp->GetFileSpec(); | const FileSpec &module_fs = module_sp->GetFileSpec(); | ||||
result.AppendMessageWithFormat( | result.AppendMessageWithFormat( | ||||
"symbol file '%s' has been added to '%s'\n", symfile_path, | "symbol file '%s' has been added to '%s'\n", symfile_path, | ||||
module_fs.GetPath().c_str()); | module_fs.GetPath().c_str()); | ||||
// Let clients know something changed in the module if it is | // Let clients know something changed in the module if it is | ||||
// currently loaded | // currently loaded | ||||
ModuleList module_list; | ModuleList module_list; | ||||
module_list.Append(module_sp); | module_list.Append(module_sp); | ||||
target->SymbolsDidLoad(module_list); | target->SymbolsDidLoad(module_list); | ||||
// Make sure we load any scripting resources that may be embedded | // Make sure we load any scripting resources that may be embedded | ||||
// in the debug info files in case the platform supports that. | // in the debug info files in case the platform supports that. | ||||
Status error; | Status error; | ||||
StreamString feedback_stream; | StreamString feedback_stream; | ||||
module_sp->LoadScriptingResourceInTarget(target, error, | module_sp->LoadScriptingResourceInTarget(target, error, | ||||
&feedback_stream); | &feedback_stream); | ||||
if (error.Fail() && error.AsCString()) | if (error.Fail() && error.AsCString()) | ||||
result.AppendWarningWithFormat( | result.AppendWarningWithFormat( | ||||
"unable to load scripting data for module %s - error " | "unable to load scripting data for module %s - error " | ||||
"reported was %s", | "reported was %s", | ||||
module_sp->GetFileSpec() | module_sp->GetFileSpec() | ||||
.GetFileNameStrippingExtension() | .GetFileNameStrippingExtension() | ||||
.GetCString(), | .GetCString(), | ||||
error.AsCString()); | error.AsCString()); | ||||
else if (feedback_stream.GetSize()) | else if (feedback_stream.GetSize()) | ||||
result.AppendWarningWithFormat("%s", feedback_stream.GetData()); | result.AppendWarningWithFormat("%s", feedback_stream.GetData()); | ||||
flush = true; | flush = true; | ||||
result.SetStatus(eReturnStatusSuccessFinishResult); | result.SetStatus(eReturnStatusSuccessFinishResult); | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
} | |||||
// Clear the symbol file spec if anything went wrong | // Clear the symbol file spec if anything went wrong | ||||
module_sp->SetSymbolFileFileSpec(FileSpec()); | module_sp->SetSymbolFileFileSpec(FileSpec()); | ||||
} | } | ||||
namespace fs = llvm::sys::fs; | namespace fs = llvm::sys::fs; | ||||
if (module_spec.GetUUID().IsValid()) { | if (module_spec.GetUUID().IsValid()) { | ||||
StreamString ss_symfile_uuid; | StreamString ss_symfile_uuid; | ||||
module_spec.GetUUID().Dump(&ss_symfile_uuid); | module_spec.GetUUID().Dump(&ss_symfile_uuid); | ||||
▲ Show 20 Lines • Show All 743 Lines • Show Last 20 Lines |
check m->GetSymbolFile() for NULL