svn commit: r293283 - in projects/clang380-import/contrib/llvm/tools/lldb: include/lldb/Core source/API source/Commands source/Core source/Interpreter source/Plugins/Instruction/MIPS source/Plugins...
Dimitry Andric
dim at FreeBSD.org
Wed Jan 6 22:02:10 UTC 2016
Author: dim
Date: Wed Jan 6 22:02:08 2016
New Revision: 293283
URL: https://svnweb.freebsd.org/changeset/base/293283
Log:
Update lldb to trunk r256945.
Modified:
projects/clang380-import/contrib/llvm/tools/lldb/include/lldb/Core/StringList.h
projects/clang380-import/contrib/llvm/tools/lldb/source/API/SBProcess.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Core/StringList.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Interpreter/CommandHistory.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
projects/clang380-import/contrib/llvm/tools/lldb/source/Target/Process.cpp
projects/clang380-import/contrib/llvm/tools/lldb/tools/lldb-mi/MICmdCmdSymbol.cpp
Directory Properties:
projects/clang380-import/contrib/llvm/tools/lldb/ (props changed)
Modified: projects/clang380-import/contrib/llvm/tools/lldb/include/lldb/Core/StringList.h
==============================================================================
--- projects/clang380-import/contrib/llvm/tools/lldb/include/lldb/Core/StringList.h Wed Jan 6 21:58:45 2016 (r293282)
+++ projects/clang380-import/contrib/llvm/tools/lldb/include/lldb/Core/StringList.h Wed Jan 6 22:02:08 2016 (r293283)
@@ -133,8 +133,15 @@ public:
operator << (const char* str);
StringList&
+ operator << (const std::string &s);
+
+ StringList&
operator << (StringList strings);
+ // Copy assignment for a vector of strings
+ StringList&
+ operator = (const std::vector<std::string> &rhs);
+
// This string list contains a list of valid auto completion
// strings, and the "s" is passed in. "matches" is filled in
// with zero or more string values that start with "s", and
@@ -147,6 +154,23 @@ public:
StringList &matches,
size_t &exact_matches_idx) const;
+ // Dump the StringList to the given lldb_private::Log, `log`, one item per line.
+ // If given, `name` will be used to identify the start and end of the list in the output.
+ virtual void LogDump(Log *log, const char *name = nullptr);
+
+ // Static helper to convert an iterable of strings to a StringList, and then
+ // dump it with the semantics of the `LogDump` method.
+ template<typename T> static void LogDump(Log *log, T s_iterable, const char *name = nullptr)
+ {
+ if (!log)
+ return;
+ // Make a copy of the iterable as a StringList
+ StringList l{};
+ for (const auto &s : s_iterable)
+ l << s;
+
+ l.LogDump(log, name);
+ }
private:
STLStringArray m_strings;
};
Modified: projects/clang380-import/contrib/llvm/tools/lldb/source/API/SBProcess.cpp
==============================================================================
--- projects/clang380-import/contrib/llvm/tools/lldb/source/API/SBProcess.cpp Wed Jan 6 21:58:45 2016 (r293282)
+++ projects/clang380-import/contrib/llvm/tools/lldb/source/API/SBProcess.cpp Wed Jan 6 22:02:08 2016 (r293283)
@@ -995,7 +995,14 @@ SBProcess::GetStateFromEvent (const SBEv
bool
SBProcess::GetRestartedFromEvent (const SBEvent &event)
{
- return Process::ProcessEventData::GetRestartedFromEvent (event.get());
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ bool ret_val = Process::ProcessEventData::GetRestartedFromEvent (event.get());
+
+ if (log)
+ log->Printf ("SBProcess::%s (event.sp=%p) => %d", __FUNCTION__, event.get(), ret_val);
+
+ return ret_val;
}
size_t
Modified: projects/clang380-import/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp
==============================================================================
--- projects/clang380-import/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp Wed Jan 6 21:58:45 2016 (r293282)
+++ projects/clang380-import/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp Wed Jan 6 22:02:08 2016 (r293283)
@@ -89,7 +89,7 @@ PyInit__lldb(void);
#define LLDBSwigPyInit PyInit__lldb
#else
-extern "C" void
+extern "C" void
init_lldb(void);
#define LLDBSwigPyInit init_lldb
@@ -286,7 +286,7 @@ SystemInitializerFull::Initialize()
EmulateInstructionARM64::Initialize();
SymbolFileDWARFDebugMap::Initialize();
ItaniumABILanguageRuntime::Initialize();
-
+
CPlusPlusLanguage::Initialize();
#if defined(_MSC_VER)
@@ -394,7 +394,7 @@ SystemInitializerFull::Terminate()
ItaniumABILanguageRuntime::Terminate();
CPlusPlusLanguage::Terminate();
-
+
#if defined(__APPLE__)
ProcessMachCore::Terminate();
ProcessKDP::Terminate();
Modified: projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp
==============================================================================
--- projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp Wed Jan 6 21:58:45 2016 (r293282)
+++ projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectSource.cpp Wed Jan 6 22:02:08 2016 (r293283)
@@ -27,6 +27,7 @@
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/StackFrame.h"
#include "lldb/Target/TargetList.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/Options.h"
@@ -34,9 +35,11 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
-// CommandObjectSourceInfo
-//-------------------------------------------------------------------------
+
+#pragma mark CommandObjectSourceInfo
+//----------------------------------------------------------------------
+// CommandObjectSourceInfo - debug line entries dumping command
+//----------------------------------------------------------------------
class CommandObjectSourceInfo : public CommandObjectParsed
{
@@ -44,14 +47,9 @@ class CommandObjectSourceInfo : public C
class CommandOptions : public Options
{
public:
- CommandOptions (CommandInterpreter &interpreter) :
- Options(interpreter)
- {
- }
+ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) {}
- ~CommandOptions () override
- {
- }
+ ~CommandOptions () override {}
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
@@ -60,19 +58,44 @@ class CommandObjectSourceInfo : public C
const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
- case 'l':
- start_line = StringConvert::ToUInt32 (option_arg, 0);
- if (start_line == 0)
- error.SetErrorStringWithFormat("invalid line number: '%s'", option_arg);
- break;
+ case 'l':
+ start_line = StringConvert::ToUInt32(option_arg, 0);
+ if (start_line == 0)
+ error.SetErrorStringWithFormat("invalid line number: '%s'", option_arg);
+ break;
+
+ case 'e':
+ end_line = StringConvert::ToUInt32(option_arg, 0);
+ if (end_line == 0)
+ error.SetErrorStringWithFormat("invalid line number: '%s'", option_arg);
+ break;
+
+ case 'c':
+ num_lines = StringConvert::ToUInt32(option_arg, 0);
+ if (num_lines == 0)
+ error.SetErrorStringWithFormat("invalid line count: '%s'", option_arg);
+ break;
+
+ case 'f':
+ file_name = option_arg;
+ break;
+
+ case 'n':
+ symbol_name = option_arg;
+ break;
- case 'f':
- file_name = option_arg;
- break;
-
- default:
- error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
+ case 'a':
+ {
+ ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
+ address = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+ }
break;
+ case 's':
+ modules.push_back(std::string(option_arg));
+ break;
+ default:
+ error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
+ break;
}
return error;
@@ -83,10 +106,15 @@ class CommandObjectSourceInfo : public C
{
file_spec.Clear();
file_name.clear();
+ symbol_name.clear();
+ address = LLDB_INVALID_ADDRESS;
start_line = 0;
+ end_line = 0;
+ num_lines = 0;
+ modules.clear();
}
- const OptionDefinition*
+ const OptionDefinition *
GetDefinitions () override
{
return g_option_table;
@@ -96,24 +124,24 @@ class CommandObjectSourceInfo : public C
// Instance variables to hold the values for command options.
FileSpec file_spec;
std::string file_name;
+ std::string symbol_name;
+ lldb::addr_t address;
uint32_t start_line;
-
+ uint32_t end_line;
+ uint32_t num_lines;
+ STLStringArray modules;
};
-
-public:
- CommandObjectSourceInfo(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "source info",
- "Display information about the source lines from the current executable's debug info.",
- "source info [<cmd-options>]"),
- m_options (interpreter)
- {
- }
- ~CommandObjectSourceInfo () override
+public:
+ CommandObjectSourceInfo (CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "source info", "Display source line information (as specified) based "
+ "on the current executable's debug info.",
+ NULL, eCommandRequiresTarget),
+ m_options(interpreter)
{
}
+ ~CommandObjectSourceInfo () override {}
Options *
GetOptions () override
@@ -122,25 +150,576 @@ public:
}
protected:
+
+ // Dump the line entries in each symbol context.
+ // Return the number of entries found.
+ // If module_list is set, only dump lines contained in one of the modules.
+ // If file_spec is set, only dump lines in the file.
+ // If the start_line option was specified, don't print lines less than start_line.
+ // If the end_line option was specified, don't print lines greater than end_line.
+ // If the num_lines option was specified, dont print more than num_lines entries.
+ uint32_t
+ DumpLinesInSymbolContexts (Stream &strm, const SymbolContextList &sc_list,
+ const ModuleList &module_list, const FileSpec &file_spec)
+ {
+ uint32_t start_line = m_options.start_line;
+ uint32_t end_line = m_options.end_line;
+ uint32_t num_lines = m_options.num_lines;
+ Target *target = m_exe_ctx.GetTargetPtr();
+
+ uint32_t num_matches = 0;
+ bool has_path = false;
+ if (file_spec)
+ {
+ assert(file_spec.GetFilename().AsCString());
+ has_path = (file_spec.GetDirectory().AsCString() != 0);
+ }
+
+ // Dump all the line entries for the file in the list.
+ ConstString last_module_file_name;
+ uint32_t num_scs = sc_list.GetSize();
+ for (uint32_t i = 0; i < num_scs; ++i)
+ {
+ SymbolContext sc;
+ sc_list.GetContextAtIndex(i, sc);
+ if (sc.comp_unit)
+ {
+ Module *module = sc.module_sp.get();
+ CompileUnit *cu = sc.comp_unit;
+ const LineEntry &line_entry = sc.line_entry;
+ assert(module && cu);
+
+ // Are we looking for specific modules, files or lines?
+ if (module_list.GetSize() && module_list.GetIndexForModule(module) == LLDB_INVALID_INDEX32)
+ continue;
+ if (file_spec && !lldb_private::FileSpec::Equal(file_spec, line_entry.file, has_path))
+ continue;
+ if (start_line > 0 && line_entry.line < start_line)
+ continue;
+ if (end_line > 0 && line_entry.line > end_line)
+ continue;
+ if (num_lines > 0 && num_matches > num_lines)
+ continue;
+
+ // Print a new header if the module changed.
+ const ConstString &module_file_name = module->GetFileSpec().GetFilename();
+ assert(module_file_name);
+ if (module_file_name != last_module_file_name)
+ {
+ if (num_matches > 0)
+ strm << "\n\n";
+ strm << "Lines found in module `" << module_file_name << "\n";
+ }
+ // Dump the line entry.
+ line_entry.GetDescription(&strm, lldb::eDescriptionLevelBrief, cu,
+ target, /*show_address_only=*/false);
+ strm << "\n";
+ last_module_file_name = module_file_name;
+ num_matches++;
+ }
+ }
+ return num_matches;
+ }
+
+ // Dump the requested line entries for the file in the compilation unit.
+ // Return the number of entries found.
+ // If module_list is set, only dump lines contained in one of the modules.
+ // If the start_line option was specified, don't print lines less than start_line.
+ // If the end_line option was specified, don't print lines greater than end_line.
+ // If the num_lines option was specified, dont print more than num_lines entries.
+ uint32_t
+ DumpFileLinesInCompUnit (Stream &strm, Module *module, CompileUnit *cu, const FileSpec &file_spec)
+ {
+ uint32_t start_line = m_options.start_line;
+ uint32_t end_line = m_options.end_line;
+ uint32_t num_lines = m_options.num_lines;
+ Target *target = m_exe_ctx.GetTargetPtr();
+
+ uint32_t num_matches = 0;
+ assert(module);
+ if (cu)
+ {
+ assert(file_spec.GetFilename().AsCString());
+ bool has_path = (file_spec.GetDirectory().AsCString() != 0);
+ const FileSpecList &cu_file_list = cu->GetSupportFiles();
+ size_t file_idx = cu_file_list.FindFileIndex(0, file_spec, has_path);
+ if (file_idx != UINT32_MAX)
+ {
+ // Update the file to how it appears in the CU.
+ const FileSpec &cu_file_spec = cu_file_list.GetFileSpecAtIndex(file_idx);
+
+ // Dump all matching lines at or above start_line for the file in the CU.
+ const ConstString &file_spec_name = file_spec.GetFilename();
+ const ConstString &module_file_name = module->GetFileSpec().GetFilename();
+ bool cu_header_printed = false;
+ uint32_t line = start_line;
+ while (true)
+ {
+ LineEntry line_entry;
+
+ // Find the lowest index of a line entry with a line equal to
+ // or higher than 'line'.
+ uint32_t start_idx = 0;
+ start_idx = cu->FindLineEntry(start_idx, line, &cu_file_spec,
+ /*exact=*/false, &line_entry);
+ if (start_idx == UINT32_MAX)
+ // No more line entries for our file in this CU.
+ break;
+
+ if (end_line > 0 && line_entry.line > end_line)
+ break;
+
+ // Loop through to find any other entries for this line, dumping each.
+ line = line_entry.line;
+ do
+ {
+ num_matches++;
+ if (num_lines > 0 && num_matches > num_lines)
+ break;
+ assert(lldb_private::FileSpec::Equal(cu_file_spec, line_entry.file, has_path));
+ if (!cu_header_printed)
+ {
+ if (num_matches > 0)
+ strm << "\n\n";
+ strm << "Lines found for file " << file_spec_name
+ << " in compilation unit " << cu->GetFilename()
+ << " in `" << module_file_name << "\n";
+ cu_header_printed = true;
+ }
+ line_entry.GetDescription(&strm, lldb::eDescriptionLevelBrief, cu,
+ target, /*show_address_only=*/false);
+ strm << "\n";
+
+ // Anymore after this one?
+ start_idx++;
+ start_idx = cu->FindLineEntry(start_idx, line, &cu_file_spec,
+ /*exact=*/true, &line_entry);
+ } while (start_idx != UINT32_MAX);
+
+ // Try the next higher line, starting over at start_idx 0.
+ line++;
+ }
+ }
+ }
+ return num_matches;
+ }
+
+ // Dump the requested line entries for the file in the module.
+ // Return the number of entries found.
+ // If module_list is set, only dump lines contained in one of the modules.
+ // If the start_line option was specified, don't print lines less than start_line.
+ // If the end_line option was specified, don't print lines greater than end_line.
+ // If the num_lines option was specified, dont print more than num_lines entries.
+ uint32_t
+ DumpFileLinesInModule (Stream &strm, Module *module, const FileSpec &file_spec)
+ {
+ uint32_t num_matches = 0;
+ if (module)
+ {
+ // Look through all the compilation units (CUs) in this module for ones that
+ // contain lines of code from this source file.
+ for (size_t i = 0; i < module->GetNumCompileUnits(); i++)
+ {
+ // Look for a matching source file in this CU.
+ CompUnitSP cu_sp(module->GetCompileUnitAtIndex(i));
+ if (cu_sp)
+ {
+ num_matches += DumpFileLinesInCompUnit(strm, module, cu_sp.get(), file_spec);
+ }
+ }
+ }
+ return num_matches;
+ }
+
+ // Given an address and a list of modules, append the symbol contexts of all line entries
+ // containing the address found in the modules and return the count of matches. If none
+ // is found, return an error in 'error_strm'.
+ size_t
+ GetSymbolContextsForAddress (const ModuleList &module_list, lldb::addr_t addr,
+ SymbolContextList &sc_list, StreamString &error_strm)
+ {
+ Address so_addr;
+ size_t num_matches = 0;
+ assert(module_list.GetSize() > 0);
+ Target *target = m_exe_ctx.GetTargetPtr();
+ if (target->GetSectionLoadList().IsEmpty())
+ {
+ // The target isn't loaded yet, we need to lookup the file address in
+ // all modules. Note: the module list option does not apply to addresses.
+ const size_t num_modules = module_list.GetSize();
+ for (size_t i = 0; i < num_modules; ++i)
+ {
+ ModuleSP module_sp(module_list.GetModuleAtIndex(i));
+ if (!module_sp)
+ continue;
+ if (module_sp->ResolveFileAddress(addr, so_addr))
+ {
+ SymbolContext sc;
+ sc.Clear(true);
+ if (module_sp->ResolveSymbolContextForAddress(so_addr, eSymbolContextEverything, sc) &
+ eSymbolContextLineEntry)
+ {
+ sc_list.AppendIfUnique(sc, /*merge_symbol_into_function=*/false);
+ ++num_matches;
+ }
+ }
+ }
+ if (num_matches == 0)
+ error_strm.Printf("Source information for file address 0x%" PRIx64
+ " not found in any modules.\n", addr);
+ }
+ else
+ {
+ // The target has some things loaded, resolve this address to a
+ // compile unit + file + line and display
+ if (target->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
+ {
+ ModuleSP module_sp(so_addr.GetModule());
+ // Check to make sure this module is in our list.
+ if (module_sp &&
+ module_list.GetIndexForModule(module_sp.get()) != LLDB_INVALID_INDEX32)
+ {
+ SymbolContext sc;
+ sc.Clear(true);
+ if (module_sp->ResolveSymbolContextForAddress(so_addr, eSymbolContextEverything, sc) &
+ eSymbolContextLineEntry)
+ {
+ sc_list.AppendIfUnique(sc, /*merge_symbol_into_function=*/false);
+ ++num_matches;
+ }
+ else
+ {
+ StreamString addr_strm;
+ so_addr.Dump(&addr_strm, NULL, Address::DumpStyleModuleWithFileAddress);
+ error_strm.Printf("Address 0x%" PRIx64 " resolves to %s, but there is"
+ " no source information available for this address.\n",
+ addr, addr_strm.GetData());
+ }
+ }
+ else
+ {
+ StreamString addr_strm;
+ so_addr.Dump(&addr_strm, NULL, Address::DumpStyleModuleWithFileAddress);
+ error_strm.Printf("Address 0x%" PRIx64 " resolves to %s, but it cannot"
+ " be found in any modules.\n",
+ addr, addr_strm.GetData());
+ }
+ }
+ else
+ error_strm.Printf("Unable to resolve address 0x%" PRIx64 ".\n", addr);
+ }
+ return num_matches;
+ }
+
+ // Dump the line entries found in functions matching the name specified in the option.
bool
- DoExecute (Args& command, CommandReturnObject &result) override
+ DumpLinesInFunctions (CommandReturnObject &result)
{
- result.AppendError ("Not yet implemented");
- result.SetStatus (eReturnStatusFailed);
- return false;
+ SymbolContextList sc_list_funcs;
+ ConstString name(m_options.symbol_name.c_str());
+ SymbolContextList sc_list_lines;
+ Target *target = m_exe_ctx.GetTargetPtr();
+ uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize();
+
+ // Note: module_list can't be const& because FindFunctionSymbols isn't const.
+ ModuleList module_list = (m_module_list.GetSize() > 0) ?
+ m_module_list : target->GetImages();
+ size_t num_matches = module_list.FindFunctions(name,
+ eFunctionNameTypeAuto,
+ /*include_symbols=*/false,
+ /*include_inlines=*/true,
+ /*append=*/true,
+ sc_list_funcs);
+ if (!num_matches)
+ {
+ // If we didn't find any functions with that name, try searching for
+ // symbols that line up exactly with function addresses.
+ SymbolContextList sc_list_symbols;
+ size_t num_symbol_matches = module_list.FindFunctionSymbols(name,
+ eFunctionNameTypeAuto,
+ sc_list_symbols);
+ for (size_t i = 0; i < num_symbol_matches; i++)
+ {
+ SymbolContext sc;
+ sc_list_symbols.GetContextAtIndex(i, sc);
+ if (sc.symbol && sc.symbol->ValueIsAddress())
+ {
+ const Address &base_address = sc.symbol->GetAddressRef();
+ Function *function = base_address.CalculateSymbolContextFunction();
+ if (function)
+ {
+ sc_list_funcs.Append(SymbolContext(function));
+ num_matches++;
+ }
+ }
+ }
+ }
+ if (num_matches == 0)
+ {
+ result.AppendErrorWithFormat("Could not find function named \'%s\'.\n",
+ m_options.symbol_name.c_str());
+ return false;
+ }
+ for (size_t i = 0; i < num_matches; i++)
+ {
+ SymbolContext sc;
+ sc_list_funcs.GetContextAtIndex(i, sc);
+ bool context_found_for_symbol = false;
+ // Loop through all the ranges in the function.
+ AddressRange range;
+ for (uint32_t r = 0;
+ sc.GetAddressRange(eSymbolContextEverything,
+ r,
+ /*use_inline_block_range=*/true,
+ range);
+ ++r)
+ {
+ // Append the symbol contexts for each address in the range to sc_list_lines.
+ const Address &base_address = range.GetBaseAddress();
+ const addr_t size = range.GetByteSize();
+ lldb::addr_t start_addr = base_address.GetLoadAddress(target);
+ if (start_addr == LLDB_INVALID_ADDRESS)
+ start_addr = base_address.GetFileAddress();
+ lldb::addr_t end_addr = start_addr + size;
+ for (lldb::addr_t addr = start_addr; addr < end_addr; addr += addr_byte_size)
+ {
+ StreamString error_strm;
+ if (!GetSymbolContextsForAddress(module_list, addr, sc_list_lines, error_strm))
+ result.AppendWarningWithFormat("in symbol '%s': %s",
+ sc.GetFunctionName().AsCString(),
+ error_strm.GetData());
+ else
+ context_found_for_symbol = true;
+ }
+ }
+ if (!context_found_for_symbol)
+ result.AppendWarningWithFormat("Unable to find line information"
+ " for matching symbol '%s'.\n",
+ sc.GetFunctionName().AsCString());
+ }
+ if (sc_list_lines.GetSize() == 0)
+ {
+ result.AppendErrorWithFormat("No line information could be found"
+ " for any symbols matching '%s'.\n",
+ name.AsCString());
+ return false;
+ }
+ FileSpec file_spec;
+ if (!DumpLinesInSymbolContexts(result.GetOutputStream(),
+ sc_list_lines, module_list, file_spec))
+ {
+ result.AppendErrorWithFormat("Unable to dump line information for symbol '%s'.\n",
+ name.AsCString());
+ return false;
+ }
+ return true;
+ }
+
+ // Dump the line entries found for the address specified in the option.
+ bool
+ DumpLinesForAddress (CommandReturnObject &result)
+ {
+ Target *target = m_exe_ctx.GetTargetPtr();
+ SymbolContextList sc_list;
+
+ StreamString error_strm;
+ if (!GetSymbolContextsForAddress(target->GetImages(), m_options.address, sc_list, error_strm))
+ {
+ result.AppendErrorWithFormat("%s.\n", error_strm.GetData());
+ return false;
+ }
+ ModuleList module_list;
+ FileSpec file_spec;
+ if (!DumpLinesInSymbolContexts(result.GetOutputStream(),
+ sc_list, module_list, file_spec))
+ {
+ result.AppendErrorWithFormat("No modules contain load address 0x%" PRIx64 ".\n",
+ m_options.address);
+ return false;
+ }
+ return true;
+ }
+
+ // Dump the line entries found in the file specified in the option.
+ bool
+ DumpLinesForFile (CommandReturnObject &result)
+ {
+ FileSpec file_spec(m_options.file_name, false);
+ const char *filename = m_options.file_name.c_str();
+ Target *target = m_exe_ctx.GetTargetPtr();
+ const ModuleList &module_list = (m_module_list.GetSize() > 0) ?
+ m_module_list : target->GetImages();
+
+ bool displayed_something = false;
+ const size_t num_modules = module_list.GetSize();
+ for (uint32_t i = 0; i < num_modules; ++i)
+ {
+ // Dump lines for this module.
+ Module *module = module_list.GetModulePointerAtIndex(i);
+ assert(module);
+ if (DumpFileLinesInModule(result.GetOutputStream(), module, file_spec))
+ displayed_something = true;
+ }
+ if (!displayed_something)
+ {
+ result.AppendErrorWithFormat("No source filenames matched '%s'.\n", filename);
+ return false;
+ }
+ return true;
+ }
+
+ // Dump the line entries for the current frame.
+ bool
+ DumpLinesForFrame (CommandReturnObject &result)
+ {
+ StackFrame *cur_frame = m_exe_ctx.GetFramePtr();
+ if (cur_frame == NULL)
+ {
+ result.AppendError("No selected frame to use to find the default source.");
+ return false;
+ }
+ else if (!cur_frame->HasDebugInformation())
+ {
+ result.AppendError("No debug info for the selected frame.");
+ return false;
+ }
+ else
+ {
+ const SymbolContext &sc = cur_frame->GetSymbolContext(eSymbolContextLineEntry);
+ SymbolContextList sc_list;
+ sc_list.Append(sc);
+ ModuleList module_list;
+ FileSpec file_spec;
+ if (!DumpLinesInSymbolContexts(result.GetOutputStream(), sc_list, module_list, file_spec))
+ {
+ result.AppendError("No source line info available for the selected frame.");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ bool
+ DoExecute (Args &command, CommandReturnObject &result) override
+ {
+ const size_t argc = command.GetArgumentCount();
+
+ if (argc != 0)
+ {
+ result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n",
+ GetCommandName());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ Target *target = m_exe_ctx.GetTargetPtr();
+ if (target == NULL)
+ {
+ target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ if (target == NULL)
+ {
+ result.AppendError("invalid target, create a debug target using the "
+ "'target create' command.");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+
+ uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize();
+ result.GetOutputStream().SetAddressByteSize(addr_byte_size);
+ result.GetErrorStream().SetAddressByteSize(addr_byte_size);
+
+ // Collect the list of modules to search.
+ m_module_list.Clear();
+ if (m_options.modules.size() > 0)
+ {
+ for (size_t i = 0, e = m_options.modules.size(); i < e; ++i)
+ {
+ FileSpec module_file_spec(m_options.modules[i].c_str(), false);
+ if (module_file_spec)
+ {
+ ModuleSpec module_spec(module_file_spec);
+ if (target->GetImages().FindModules(module_spec, m_module_list) == 0)
+ result.AppendWarningWithFormat("No module found for '%s'.\n",
+ m_options.modules[i].c_str());
+ }
+ }
+ if (!m_module_list.GetSize())
+ {
+ result.AppendError("No modules match the input.");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+ else if (target->GetImages().GetSize() == 0)
+ {
+ result.AppendError("The target has no associated executable images.");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ // Check the arguments to see what lines we should dump.
+ if (!m_options.symbol_name.empty())
+ {
+ // Print lines for symbol.
+ if (DumpLinesInFunctions(result))
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ else
+ result.SetStatus(eReturnStatusFailed);
+ }
+ else if (m_options.address != LLDB_INVALID_ADDRESS)
+ {
+ // Print lines for an address.
+ if (DumpLinesForAddress(result))
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ else
+ result.SetStatus(eReturnStatusFailed);
+ }
+ else if (!m_options.file_name.empty())
+ {
+ // Dump lines for a file.
+ if (DumpLinesForFile(result))
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ else
+ result.SetStatus(eReturnStatusFailed);
+ }
+ else
+ {
+ // Dump the line for the current frame.
+ if (DumpLinesForFrame(result))
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ else
+ result.SetStatus(eReturnStatusFailed);
+ }
+ return result.Succeeded();
}
CommandOptions m_options;
+ ModuleList m_module_list;
};
-OptionDefinition
-CommandObjectSourceInfo::CommandOptions::g_option_table[] =
-{
-{ LLDB_OPT_SET_1, false, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum, "The line number at which to start the display source."},
-{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "The file from which to display source."},
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+OptionDefinition CommandObjectSourceInfo::CommandOptions::g_option_table[] = {
+ {LLDB_OPT_SET_ALL, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount,
+ "The number of line entries to display."},
+ {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "shlib", 's', OptionParser::eRequiredArgument, NULL, NULL,
+ CommandCompletions::eModuleCompletion, eArgTypeShlibName,
+ "Look up the source in the given module or shared library (can be "
+ "specified more than once)."},
+ {LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL,
+ CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "The file from which to display source."},
+ {LLDB_OPT_SET_1, false, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,
+ "The line number at which to start the displaying lines."},
+ {LLDB_OPT_SET_1, false, "end-line", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,
+ "The line number at which to stop displaying lines."},
+ {LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL,
+ CommandCompletions::eSymbolCompletion, eArgTypeSymbol, "The name of a function whose source to display."},
+ {LLDB_OPT_SET_3, false, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression,
+ "Lookup the address and display the source information for the "
+ "corresponding file and line."},
+ {0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL}
};
+
#pragma mark CommandObjectSourceList
//-------------------------------------------------------------------------
// CommandObjectSourceList
@@ -906,7 +1485,6 @@ CommandObjectSourceList::CommandOptions:
};
#pragma mark CommandObjectMultiwordSource
-
//-------------------------------------------------------------------------
// CommandObjectMultiwordSource
//-------------------------------------------------------------------------
@@ -917,8 +1495,7 @@ CommandObjectMultiwordSource::CommandObj
"A set of commands for accessing source file information",
"source <subcommand> [<subcommand-options>]")
{
- // "source info" isn't implemented yet...
- //LoadSubCommand ("info", CommandObjectSP (new CommandObjectSourceInfo (interpreter)));
+ LoadSubCommand ("info", CommandObjectSP (new CommandObjectSourceInfo (interpreter)));
LoadSubCommand ("list", CommandObjectSP (new CommandObjectSourceList (interpreter)));
}
Modified: projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp
==============================================================================
--- projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp Wed Jan 6 21:58:45 2016 (r293282)
+++ projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectTarget.cpp Wed Jan 6 22:02:08 2016 (r293283)
@@ -2577,8 +2577,9 @@ protected:
if (command.GetArgumentCount() == 0)
{
- result.AppendErrorWithFormat ("\nSyntax: %s\n", m_cmd_syntax.c_str());
+ result.AppendError ("file option must be specified.");
result.SetStatus (eReturnStatusFailed);
+ return result.Succeeded();
}
else
{
Modified: projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp
==============================================================================
--- projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp Wed Jan 6 21:58:45 2016 (r293282)
+++ projects/clang380-import/contrib/llvm/tools/lldb/source/Commands/CommandObjectType.cpp Wed Jan 6 22:02:08 2016 (r293283)
@@ -1396,11 +1396,6 @@ protected:
auto category_closure = [&result, &formatter_regex] (const lldb::TypeCategoryImplSP& category) -> void {
result.GetOutputStream().Printf("-----------------------\nCategory: %s\n-----------------------\n", category->GetName());
-
- typedef const std::shared_ptr<FormatterType> Bar;
- typedef std::function<bool(ConstString,Bar)> Func1Type;
- typedef std::function<bool(RegularExpressionSP,Bar)> Func2Type;
-
TypeCategoryImpl::ForEachCallbacks<FormatterType> foreach;
foreach.SetExact([&result, &formatter_regex] (ConstString name, const FormatterSharedPointer& format_sp) -> bool {
if (formatter_regex)
Modified: projects/clang380-import/contrib/llvm/tools/lldb/source/Core/StringList.cpp
==============================================================================
--- projects/clang380-import/contrib/llvm/tools/lldb/source/Core/StringList.cpp Wed Jan 6 21:58:45 2016 (r293282)
+++ projects/clang380-import/contrib/llvm/tools/lldb/source/Core/StringList.cpp Wed Jan 6 22:02:08 2016 (r293283)
@@ -11,6 +11,8 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/StreamString.h"
#include <string>
@@ -305,12 +307,29 @@ StringList::operator << (const char* str
}
StringList&
+StringList::operator << (const std::string& str)
+{
+ AppendString(str);
+ return *this;
+}
+
+StringList&
StringList::operator << (StringList strings)
{
AppendList(strings);
return *this;
}
+StringList&
+StringList::operator = (const std::vector<std::string> &rhs)
+{
+ Clear();
+ for (const auto &s : rhs)
+ m_strings.push_back(s);
+
+ return *this;
+}
+
size_t
StringList::AutoComplete (const char *s, StringList &matches, size_t &exact_idx) const
{
@@ -339,3 +358,21 @@ StringList::AutoComplete (const char *s,
return matches.GetSize();
}
+void
+StringList::LogDump(Log *log, const char *name)
+{
+ if (!log)
+ return;
+
+ StreamString strm;
+ if (name)
+ strm.Printf("Begin %s:\n", name);
+ for (const auto &s : m_strings) {
+ strm.Indent();
+ strm.Printf("%s\n", s.c_str());
+ }
+ if (name)
+ strm.Printf("End %s.\n", name);
+
+ log->Debug("%s", strm.GetData());
+}
Modified: projects/clang380-import/contrib/llvm/tools/lldb/source/Interpreter/CommandHistory.cpp
==============================================================================
--- projects/clang380-import/contrib/llvm/tools/lldb/source/Interpreter/CommandHistory.cpp Wed Jan 6 21:58:45 2016 (r293282)
+++ projects/clang380-import/contrib/llvm/tools/lldb/source/Interpreter/CommandHistory.cpp Wed Jan 6 22:02:08 2016 (r293283)
@@ -130,9 +130,9 @@ CommandHistory::Dump (Stream& stream,
size_t stop_idx) const
{
Mutex::Locker locker(m_mutex);
- stop_idx = std::min(stop_idx, m_history.size() - 1);
+ stop_idx = std::min(stop_idx + 1, m_history.size());
for (size_t counter = start_idx;
- counter <= stop_idx;
+ counter < stop_idx;
counter++)
{
const std::string hist_item = m_history[counter];
Modified: projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
==============================================================================
--- projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp Wed Jan 6 21:58:45 2016 (r293282)
+++ projects/clang380-import/contrib/llvm/tools/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp Wed Jan 6 22:02:08 2016 (r293283)
@@ -591,45 +591,45 @@ EmulateInstructionMIPS::GetOpcodeForInst
//----------------------------------------------------------------------
// Branch instructions
//----------------------------------------------------------------------
- { "BEQ", &EmulateInstructionMIPS::Emulate_BEQ, "BEQ rs,rt,offset" },
- { "BNE", &EmulateInstructionMIPS::Emulate_BNE, "BNE rs,rt,offset" },
- { "BEQL", &EmulateInstructionMIPS::Emulate_BEQL, "BEQL rs,rt,offset" },
- { "BNEL", &EmulateInstructionMIPS::Emulate_BNEL, "BNEL rs,rt,offset" },
- { "BGEZALL", &EmulateInstructionMIPS::Emulate_BGEZALL, "BGEZALL rt,offset" },
+ { "BEQ", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BEQ rs,rt,offset" },
+ { "BNE", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BNE rs,rt,offset" },
+ { "BEQL", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BEQL rs,rt,offset" },
+ { "BNEL", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BNEL rs,rt,offset" },
+ { "BGEZALL", &EmulateInstructionMIPS::Emulate_Bcond_Link, "BGEZALL rt,offset" },
{ "BAL", &EmulateInstructionMIPS::Emulate_BAL, "BAL offset" },
- { "BGEZAL", &EmulateInstructionMIPS::Emulate_BGEZAL, "BGEZAL rs,offset" },
+ { "BGEZAL", &EmulateInstructionMIPS::Emulate_Bcond_Link, "BGEZAL rs,offset" },
{ "BALC", &EmulateInstructionMIPS::Emulate_BALC, "BALC offset" },
{ "BC", &EmulateInstructionMIPS::Emulate_BC, "BC offset" },
- { "BGEZ", &EmulateInstructionMIPS::Emulate_BGEZ, "BGEZ rs,offset" },
- { "BLEZALC", &EmulateInstructionMIPS::Emulate_BLEZALC, "BLEZALC rs,offset" },
- { "BGEZALC", &EmulateInstructionMIPS::Emulate_BGEZALC, "BGEZALC rs,offset" },
- { "BLTZALC", &EmulateInstructionMIPS::Emulate_BLTZALC, "BLTZALC rs,offset" },
- { "BGTZALC", &EmulateInstructionMIPS::Emulate_BGTZALC, "BGTZALC rs,offset" },
- { "BEQZALC", &EmulateInstructionMIPS::Emulate_BEQZALC, "BEQZALC rs,offset" },
- { "BNEZALC", &EmulateInstructionMIPS::Emulate_BNEZALC, "BNEZALC rs,offset" },
- { "BEQC", &EmulateInstructionMIPS::Emulate_BEQC, "BEQC rs,rt,offset" },
- { "BNEC", &EmulateInstructionMIPS::Emulate_BNEC, "BNEC rs,rt,offset" },
- { "BLTC", &EmulateInstructionMIPS::Emulate_BLTC, "BLTC rs,rt,offset" },
- { "BGEC", &EmulateInstructionMIPS::Emulate_BGEC, "BGEC rs,rt,offset" },
- { "BLTUC", &EmulateInstructionMIPS::Emulate_BLTUC, "BLTUC rs,rt,offset" },
- { "BGEUC", &EmulateInstructionMIPS::Emulate_BGEUC, "BGEUC rs,rt,offset" },
- { "BLTZC", &EmulateInstructionMIPS::Emulate_BLTZC, "BLTZC rt,offset" },
- { "BLEZC", &EmulateInstructionMIPS::Emulate_BLEZC, "BLEZC rt,offset" },
- { "BGEZC", &EmulateInstructionMIPS::Emulate_BGEZC, "BGEZC rt,offset" },
- { "BGTZC", &EmulateInstructionMIPS::Emulate_BGTZC, "BGTZC rt,offset" },
- { "BEQZC", &EmulateInstructionMIPS::Emulate_BEQZC, "BEQZC rt,offset" },
- { "BNEZC", &EmulateInstructionMIPS::Emulate_BNEZC, "BNEZC rt,offset" },
- { "BGEZL", &EmulateInstructionMIPS::Emulate_BGEZL, "BGEZL rt,offset" },
- { "BGTZ", &EmulateInstructionMIPS::Emulate_BGTZ, "BGTZ rt,offset" },
- { "BGTZL", &EmulateInstructionMIPS::Emulate_BGTZL, "BGTZL rt,offset" },
- { "BLEZ", &EmulateInstructionMIPS::Emulate_BLEZ, "BLEZ rt,offset" },
- { "BLEZL", &EmulateInstructionMIPS::Emulate_BLEZL, "BLEZL rt,offset" },
- { "BLTZ", &EmulateInstructionMIPS::Emulate_BLTZ, "BLTZ rt,offset" },
- { "BLTZAL", &EmulateInstructionMIPS::Emulate_BLTZAL, "BLTZAL rt,offset" },
- { "BLTZALL", &EmulateInstructionMIPS::Emulate_BLTZALL, "BLTZALL rt,offset" },
- { "BLTZL", &EmulateInstructionMIPS::Emulate_BLTZL, "BLTZL rt,offset" },
- { "BOVC", &EmulateInstructionMIPS::Emulate_BOVC, "BOVC rs,rt,offset" },
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-projects
mailing list