aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-02-13 15:01:33 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-02-13 15:01:33 +0000
commit2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (patch)
tree525149683974afa86747b749d45f0425749e972e
parente195173fdf080138dbb42936dea88c605e4b9a56 (diff)
downloadsrc-2fc5d2d1dfaf623ce4e24cd8590565902f8c557c.tar.gz
src-2fc5d2d1dfaf623ce4e24cd8590565902f8c557c.zip
Vendor import of lldb release_38 branch r260756:vendor/lldb/lldb-release_380-r262564vendor/lldb/lldb-release_38-r260756
Notes
Notes: svn path=/vendor/lldb/dist/; revision=295598 svn path=/vendor/lldb/lldb-release_380-r262564/; revision=296366; tag=vendor/lldb/lldb-release_380-r262564
-rw-r--r--Makefile8
-rw-r--r--include/lldb/API/SBInstruction.h3
-rw-r--r--include/lldb/Core/RangeMap.h19
-rw-r--r--include/lldb/Symbol/Symtab.h1
-rw-r--r--packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py84
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/main.c21
-rw-r--r--packages/Python/lldbsuite/test/lldbtest.py15
-rw-r--r--packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py1
-rw-r--r--packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py4
-rw-r--r--scripts/interface/SBInstruction.i3
-rw-r--r--source/API/SBInstruction.cpp8
-rw-r--r--source/Core/Module.cpp13
-rw-r--r--source/Expression/IRDynamicChecks.cpp4
-rw-r--r--source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp15
-rw-r--r--source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp15
-rw-r--r--source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp21
-rw-r--r--source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h7
-rw-r--r--source/Plugins/Platform/MacOSX/Makefile19
-rw-r--r--source/Symbol/GoASTContext.cpp151
-rw-r--r--source/Symbol/Symtab.cpp20
-rw-r--r--source/Target/Target.cpp18
-rw-r--r--tools/lldb-server/CMakeLists.txt27
24 files changed, 427 insertions, 57 deletions
diff --git a/Makefile b/Makefile
index c2f41bb097a8..e794ae8e9a86 100644
--- a/Makefile
+++ b/Makefile
@@ -88,14 +88,6 @@ EXTRA_OPTIONS += -Wno-sign-compare
ifeq ($(IS_TOP_LEVEL),1)
-ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
-$(RecursiveTargets)::
- $(Verb) if [ ! -f test/Makefile ]; then \
- $(MKDIR) test; \
- $(CP) $(PROJ_SRC_DIR)/test/Makefile test/Makefile; \
- fi
-endif
-
test::
@ $(MAKE) -C test
diff --git a/include/lldb/API/SBInstruction.h b/include/lldb/API/SBInstruction.h
index c4bded595761..2bacc2b97746 100644
--- a/include/lldb/API/SBInstruction.h
+++ b/include/lldb/API/SBInstruction.h
@@ -60,6 +60,9 @@ public:
bool
DoesBranch ();
+ bool
+ HasDelaySlot ();
+
void
Print (FILE *out);
diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h
index b2e3f06f08a9..28d3083979d6 100644
--- a/include/lldb/Core/RangeMap.h
+++ b/include/lldb/Core/RangeMap.h
@@ -1216,6 +1216,25 @@ namespace lldb_private {
}
return UINT32_MAX;
}
+
+ uint32_t
+ FindEntryIndexesThatContain(B addr, std::vector<uint32_t> &indexes) const
+ {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert (IsSorted());
+#endif
+
+ if (!m_entries.empty())
+ {
+ typename Collection::const_iterator pos;
+ for (const auto &entry : m_entries)
+ {
+ if (entry.Contains(addr))
+ indexes.push_back(entry.data);
+ }
+ }
+ return indexes.size() ;
+ }
Entry *
FindEntryThatContains (B addr)
diff --git a/include/lldb/Symbol/Symtab.h b/include/lldb/Symbol/Symtab.h
index cf28c7e87ac5..130f02c0e68b 100644
--- a/include/lldb/Symbol/Symtab.h
+++ b/include/lldb/Symbol/Symtab.h
@@ -81,6 +81,7 @@ public:
Symbol * FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility);
Symbol * FindSymbolContainingFileAddress (lldb::addr_t file_addr, const uint32_t* indexes, uint32_t num_indexes);
Symbol * FindSymbolContainingFileAddress (lldb::addr_t file_addr);
+ void ForEachSymbolContainingFileAddress(lldb::addr_t file_addr, std::function<bool(Symbol *)> const &callback);
size_t FindFunctionSymbols (const ConstString &name, uint32_t name_type_mask, SymbolContextList& sc_list);
void CalculateSymbolSizes ();
diff --git a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py
index 90e847fd5fa2..5e1f307f622d 100644
--- a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py
+++ b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py
@@ -65,5 +65,6 @@ class ExprCharTestCase(TestBase):
@expectedFailurei386("llvm.org/pr23069")
@expectedFailurex86_64("llvm.org/pr23069")
@expectedFailureWindows("llvm.org/pr21765")
+ @expectedFailureAll(bugnumber="llvm.org/pr23069", triple = 'mips*')
def test_unsigned_char(self):
self.do_test(dictionary={'CFLAGS_EXTRAS': '-funsigned-char'})
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/Makefile
new file mode 100644
index 000000000000..77aa24afc0f7
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
+
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
new file mode 100644
index 000000000000..324401ff44e1
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
@@ -0,0 +1,84 @@
+"""
+Test specific to MIPS
+"""
+
+from __future__ import print_function
+
+import os, time
+import re
+import unittest2
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+class AvoidBreakpointInDelaySlotAPITestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessArch(archs=re.compile('mips*'))
+ def test(self):
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.expect("file " + exe,
+ patterns = [ "Current executable set to .*a.out.*" ])
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ breakpoint = target.BreakpointCreateByName('main', 'a.out')
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ list = target.FindFunctions('foo', lldb.eFunctionNameTypeAuto)
+ self.assertTrue(list.GetSize() == 1)
+ sc = list.GetContextAtIndex(0)
+ self.assertTrue(sc.GetSymbol().GetName() == "foo")
+ function = sc.GetFunction()
+ self.assertTrue(function)
+ self.function(function, target)
+
+ def function (self, function, target):
+ """Iterate over instructions in function and place a breakpoint on delay slot instruction"""
+ # Get the list of all instructions in the function
+ insts = function.GetInstructions(target)
+ print(insts)
+ i = 0
+ for inst in insts:
+ if (inst.HasDelaySlot()):
+ # Remember the address of branch instruction.
+ branchinstaddress = inst.GetAddress().GetLoadAddress(target)
+
+ # Get next instruction i.e delay slot instruction.
+ delayinst = insts.GetInstructionAtIndex(i+1)
+ delayinstaddr = delayinst.GetAddress().GetLoadAddress(target)
+
+ # Set breakpoint on delay slot instruction
+ breakpoint = target.BreakpointCreateByAddress(delayinstaddr)
+
+ # Verify the breakpoint.
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+ # Get the location from breakpoint
+ location = breakpoint.GetLocationAtIndex(0)
+
+ # Get the address where breakpoint is actually set.
+ bpaddr = location.GetLoadAddress()
+
+ # Breakpoint address should be adjusted to the address of branch instruction.
+ self.assertTrue(branchinstaddress == bpaddr)
+ i += 1
+ else:
+ i += 1
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/main.c
new file mode 100644
index 000000000000..bc3eceea7693
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/main.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+foo (int a, int b)
+{
+ int c;
+ if (a<=b)
+ c=b-a;
+ else
+ c=b+a;
+ return c;
+}
+
+int main()
+{
+ int a=7, b=8, c;
+
+ c = foo(a, b);
+
+return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/lldbtest.py b/packages/Python/lldbsuite/test/lldbtest.py
index 3ad6d29a1d7a..de8f57f63706 100644
--- a/packages/Python/lldbsuite/test/lldbtest.py
+++ b/packages/Python/lldbsuite/test/lldbtest.py
@@ -633,6 +633,14 @@ def check_list_or_lambda(list_or_lambda, value):
else:
return list_or_lambda is None or value is None or list_or_lambda == value
+def matchArchitectures(archs, actual_arch):
+ retype = type(re.compile('hello, world'))
+ list_passes = isinstance(archs, list) and actual_arch in archs
+ basestring_passes = isinstance(archs, six.string_types) and actual_arch == archs
+ regex_passes = isinstance(archs, retype) and re.match(archs, actual_arch)
+
+ return (list_passes or basestring_passes or regex_passes)
+
# provide a function to xfail on defined oslist, compiler version, and archs
# if none is specified for any argument, that argument won't be checked and thus means for all
# for example,
@@ -1026,7 +1034,7 @@ def skipUnlessHostPlatform(oslist):
return unittest2.skipUnless(getHostPlatform() in oslist,
"requires on of %s" % (", ".join(oslist)))
-def skipUnlessArch(archlist):
+def skipUnlessArch(archs):
"""Decorate the item to skip tests unless running on one of the listed architectures."""
def myImpl(func):
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
@@ -1035,9 +1043,8 @@ def skipUnlessArch(archlist):
@wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
- if self.getArchitecture() not in archlist:
- self.skipTest("skipping for architecture %s (requires one of %s)" %
- (self.getArchitecture(), ", ".join(archlist)))
+ if not matchArchitectures(archs, self.getArchitecture()):
+ self.skipTest("skipping for architecture %s" % (self.getArchitecture()))
else:
func(*args, **kwargs)
return wrapper
diff --git a/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py
index d45f5724f49c..187ba69def0e 100644
--- a/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py
+++ b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py
@@ -24,7 +24,6 @@ class SymbolAPITestCase(TestBase):
self.line2 = line_number('main.c', '// Find the line number for breakpoint 2 here.')
@add_test_categories(['pyapi'])
- @expectedFailureWindows("llvm.org/pr24778")
def test(self):
"""Exercise some SBSymbol and SBAddress APIs."""
self.build()
diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py
index b48ded4dd365..97bfa3956f6c 100644
--- a/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py
+++ b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py
@@ -22,6 +22,10 @@ class ThreadsStackTracesTestCase(TestBase):
self.line = line_number('main.cpp', '// Set break point at this line.')
@expectedFailureAll("llvm.org/pr23043", ["linux"], archs=["i386"]) # We are unable to produce a backtrace of the main thread when the thread is blocked in fgets
+
+ #The __thread_start function in libc doesn't contain any epilogue and prologue instructions
+ #hence unwinding fail when we are stopped in __thread_start
+ @expectedFailureAll(triple = 'mips*')
@expectedFailureWindows("llvm.org/pr24778")
@add_test_categories(['pyapi'])
def test_stack_traces(self):
diff --git a/scripts/interface/SBInstruction.i b/scripts/interface/SBInstruction.i
index 421990646a12..d5b60201e95e 100644
--- a/scripts/interface/SBInstruction.i
+++ b/scripts/interface/SBInstruction.i
@@ -51,6 +51,9 @@ public:
bool
DoesBranch ();
+ bool
+ HasDelaySlot ();
+
void
Print (FILE *out);
diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp
index 36be94801863..a17f3f8dbd5d 100644
--- a/source/API/SBInstruction.cpp
+++ b/source/API/SBInstruction.cpp
@@ -160,6 +160,14 @@ SBInstruction::DoesBranch ()
return false;
}
+bool
+SBInstruction::HasDelaySlot ()
+{
+ if (m_opaque_sp)
+ return m_opaque_sp->HasDelaySlot ();
+ return false;
+}
+
void
SBInstruction::SetOpaque (const lldb::InstructionSP &inst_sp)
{
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 833540e1a309..a29456f5b5a5 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -559,7 +559,18 @@ Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve
Symtab *symtab = sym_vendor->GetSymtab();
if (symtab && so_addr.IsSectionOffset())
{
- sc.symbol = symtab->FindSymbolContainingFileAddress(so_addr.GetFileAddress());
+ Symbol *matching_symbol = nullptr;
+
+ symtab->ForEachSymbolContainingFileAddress(so_addr.GetFileAddress(),
+ [&matching_symbol](Symbol *symbol) -> bool {
+ if (symbol->GetType() != eSymbolTypeInvalid)
+ {
+ matching_symbol = symbol;
+ return false; // Stop iterating
+ }
+ return true; // Keep iterating
+ });
+ sc.symbol = matching_symbol;
if (!sc.symbol &&
resolve_scope & eSymbolContextFunction && !(resolved_flags & eSymbolContextFunction))
{
diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp
index 30d7f6330f65..64fdb08157aa 100644
--- a/source/Expression/IRDynamicChecks.cpp
+++ b/source/Expression/IRDynamicChecks.cpp
@@ -35,12 +35,12 @@ using namespace lldb_private;
static char ID;
-#define VALID_POINTER_CHECK_NAME "$__lldb_valid_pointer_check"
+#define VALID_POINTER_CHECK_NAME "_$__lldb_valid_pointer_check"
#define VALID_OBJC_OBJECT_CHECK_NAME "$__lldb_objc_object_check"
static const char g_valid_pointer_check_text[] =
"extern \"C\" void\n"
-"$__lldb_valid_pointer_check (unsigned char *$__lldb_arg_ptr)\n"
+"_$__lldb_valid_pointer_check (unsigned char *$__lldb_arg_ptr)\n"
"{\n"
" unsigned char $__lldb_local_val = *$__lldb_arg_ptr;\n"
"}";
diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
index 3c7e9495d6ce..1b77946c1d1f 100644
--- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
+++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
@@ -242,16 +242,27 @@ ABISysV_mips::PrepareTrivialCall (Thread &thread,
const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0);
+ const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", 0);
if (log)
- log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp);
+ log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0);
+
+ /* Write r0 with 0, in case we are stopped in syscall,
+ * such setting prevents automatic decrement of the PC.
+ * This clears the bug 23659 for MIPS.
+ */
+ if (!reg_ctx->WriteRegisterFromUnsigned (r0_info, (uint64_t)0))
+ return false;
+
+ if (log)
+ log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp);
// Set "sp" to the requested value
if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_info, sp))
return false;
if (log)
- log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
+ log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
// Set "ra" to the return address
if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_info, return_addr))
diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
index e3da3631723e..8226ef15f494 100644
--- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
+++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
@@ -207,16 +207,27 @@ ABISysV_mips64::PrepareTrivialCall (Thread &thread,
const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0);
+ const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", 0);
if (log)
- log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp);
+ log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0);
+
+ /* Write r0 with 0, in case we are stopped in syscall,
+ * such setting prevents automatic decrement of the PC.
+ * This clears the bug 23659 for MIPS.
+ */
+ if (!reg_ctx->WriteRegisterFromUnsigned (r0_info, (uint64_t)0))
+ return false;
+
+ if (log)
+ log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp);
// Set "sp" to the requested value
if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_info, sp))
return false;
if (log)
- log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
+ log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
// Set "ra" to the return address
if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_info, return_addr))
diff --git a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index b66244813240..ccd4400995c7 100644
--- a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -169,6 +169,18 @@ ObjectFilePECOFF::MagicBytesMatch (DataBufferSP& data_sp)
return magic == IMAGE_DOS_SIGNATURE;
}
+lldb::SymbolType
+ObjectFilePECOFF::MapSymbolType(uint16_t coff_symbol_type)
+{
+ // TODO: We need to complete this mapping of COFF symbol types to LLDB ones.
+ // For now, here's a hack to make sure our function have types.
+ const auto complex_type = coff_symbol_type >> llvm::COFF::SCT_COMPLEX_TYPE_SHIFT;
+ if (complex_type == llvm::COFF::IMAGE_SYM_DTYPE_FUNCTION)
+ {
+ return lldb::eSymbolTypeCode;
+ }
+ return lldb::eSymbolTypeInvalid;
+}
ObjectFilePECOFF::ObjectFilePECOFF (const lldb::ModuleSP &module_sp,
DataBufferSP& data_sp,
@@ -534,8 +546,8 @@ ObjectFilePECOFF::GetSymtab()
{
const uint32_t symbol_size = 18;
const uint32_t addr_byte_size = GetAddressByteSize ();
- const size_t symbol_data_size = num_syms * symbol_size;
- // Include the 4 bytes string table size at the end of the symbols
+ const size_t symbol_data_size = num_syms * symbol_size;
+ // Include the 4-byte string table size at the end of the symbols
DataBufferSP symtab_data_sp(m_file.ReadFileContents (m_coff_header.symoff, symbol_data_size + 4));
DataExtractor symtab_data (symtab_data_sp, GetByteOrder(), addr_byte_size);
lldb::offset_t offset = symbol_data_size;
@@ -556,8 +568,8 @@ ObjectFilePECOFF::GetSymtab()
coff_symbol_t symbol;
const uint32_t symbol_offset = offset;
const char *symbol_name_cstr = NULL;
- // If the first 4 bytes of the symbol string are zero, then we
- // it is followed by a 4 byte string table offset. Else these
+ // If the first 4 bytes of the symbol string are zero, then they
+ // are followed by a 4-byte string table offset. Else these
// 8 bytes contain the symbol name
if (symtab_data.GetU32 (&offset) == 0)
{
@@ -586,6 +598,7 @@ ObjectFilePECOFF::GetSymtab()
{
Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value);
symbols[i].GetAddressRef() = symbol_addr;
+ symbols[i].SetType(MapSymbolType(symbol.type));
}
if (symbol.naux > 0)
diff --git a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
index fd33cd3d32f8..44e5ee1b044b 100644
--- a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -101,7 +101,10 @@ public:
static bool
MagicBytesMatch (lldb::DataBufferSP& data_sp);
-
+
+ static lldb::SymbolType
+ MapSymbolType(uint16_t coff_symbol_type);
+
bool
ParseHeader() override;
@@ -116,7 +119,7 @@ public:
uint32_t
GetAddressByteSize() const override;
-
+
// virtual lldb_private::AddressClass
// GetAddressClass (lldb::addr_t file_addr);
diff --git a/source/Plugins/Platform/MacOSX/Makefile b/source/Plugins/Platform/MacOSX/Makefile
index 3e61dc982bd6..4377d369bc19 100644
--- a/source/Plugins/Platform/MacOSX/Makefile
+++ b/source/Plugins/Platform/MacOSX/Makefile
@@ -8,6 +8,25 @@
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../../../..
+LEVEL := $(LLDB_LEVEL)/../..
+
+include $(LEVEL)/Makefile.config
+
+SOURCES += PlatformDarwin.cpp \
+ PlatformDarwinKernel.cpp \
+ PlatformMacOSX.cpp \
+ PlatformRemoteiOS.cpp \
+ PlatformRemoteAppleTV.cpp \
+ PlatformRemoteAppleWatch.cpp
+
+ifeq ($(HOST_OS),Darwin)
+SOURCES += PlatformAppleSimulator.cpp \
+ PlatformiOSSimulator.cpp \
+ PlatformiOSSimulatorCoreSimulatorSupport.mm \
+ PlatformAppleTVSimulator.cpp \
+ PlatformAppleWatchSimulator.cpp
+endif
+
LIBRARYNAME := lldbPluginPlatformMacOSX
BUILD_ARCHIVE = 1
diff --git a/source/Symbol/GoASTContext.cpp b/source/Symbol/GoASTContext.cpp
index 4ba51f7580d7..1993f2331058 100644
--- a/source/Symbol/GoASTContext.cpp
+++ b/source/Symbol/GoASTContext.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamFile.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/StringPrinter.h"
@@ -1268,13 +1269,115 @@ GoASTContext::ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, const
//----------------------------------------------------------------------
// Dumping types
//----------------------------------------------------------------------
+#define DEPTH_INCREMENT 2
+
void
GoASTContext::DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
- const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size,
+ const DataExtractor &data, lldb::offset_t data_byte_offset, size_t data_byte_size,
uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, bool show_summary,
bool verbose, uint32_t depth)
{
- assert(false);
+ if (IsTypedefType(type))
+ type = GetTypedefedType(type).GetOpaqueQualType();
+ if (!type)
+ return;
+ GoType *t = static_cast<GoType *>(type);
+
+ if (GoStruct *st = t->GetStruct())
+ {
+ if (GetCompleteType(type))
+ {
+ uint32_t field_idx = 0;
+ for (auto* field = st->GetField(field_idx); field != nullptr; field_idx++)
+ {
+ // Print the starting squiggly bracket (if this is the
+ // first member) or comma (for member 2 and beyond) for
+ // the struct/union/class member.
+ if (field_idx == 0)
+ s->PutChar('{');
+ else
+ s->PutChar(',');
+
+ // Indent
+ s->Printf("\n%*s", depth + DEPTH_INCREMENT, "");
+
+ // Print the member type if requested
+ if (show_types)
+ {
+ ConstString field_type_name = field->m_type.GetTypeName();
+ s->Printf("(%s) ", field_type_name.AsCString());
+ }
+ // Print the member name and equal sign
+ s->Printf("%s = ", field->m_name.AsCString());
+
+
+ // Dump the value of the member
+ CompilerType field_type = field->m_type;
+ field_type.DumpValue (exe_ctx,
+ s, // Stream to dump to
+ field_type.GetFormat(), // The format with which to display the member
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset + field->m_byte_offset,// Offset into "data" where to grab value from
+ field->m_type.GetByteSize(exe_ctx->GetBestExecutionContextScope()), // Size of this type in bytes
+ 0, // Bitfield bit size
+ 0, // Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children
+ }
+
+ // Indent the trailing squiggly bracket
+ if (field_idx > 0)
+ s->Printf("\n%*s}", depth, "");
+
+ }
+ }
+
+ if (GoArray *a = t->GetArray()) {
+ CompilerType element_clang_type = a->GetElementType();
+ lldb::Format element_format = element_clang_type.GetFormat();
+ uint32_t element_byte_size = element_clang_type.GetByteSize(exe_ctx->GetBestExecutionContextScope());
+
+ uint64_t element_idx;
+ for (element_idx = 0; element_idx < a->GetLength(); ++element_idx)
+ {
+ // Print the starting squiggly bracket (if this is the
+ // first member) or comman (for member 2 and beyong) for
+ // the struct/union/class member.
+ if (element_idx == 0)
+ s->PutChar('{');
+ else
+ s->PutChar(',');
+
+ // Indent and print the index
+ s->Printf("\n%*s[%" PRIu64 "] ", depth + DEPTH_INCREMENT, "", element_idx);
+
+ // Figure out the field offset within the current struct/union/class type
+ uint64_t element_offset = element_idx * element_byte_size;
+
+ // Dump the value of the member
+ element_clang_type.DumpValue (exe_ctx,
+ s, // Stream to dump to
+ element_format, // The format with which to display the element
+ data, // Data buffer containing all bytes for this type
+ data_byte_offset + element_offset,// Offset into "data" where to grab value from
+ element_byte_size, // Size of this type in bytes
+ 0, // Bitfield bit size
+ 0, // Bitfield bit offset
+ show_types, // Boolean indicating if we should show the variable types
+ show_summary, // Boolean indicating if we should show a summary for the current type
+ verbose, // Verbose output?
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children
+ }
+
+ // Indent the trailing squiggly bracket
+ if (element_idx > 0)
+ s->Printf("\n%*s}", depth, "");
+ }
+
+ if (show_summary)
+ DumpSummary (type, exe_ctx, s, data, data_byte_offset, data_byte_size);
}
bool
@@ -1371,19 +1474,55 @@ void
GoASTContext::DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data,
lldb::offset_t data_offset, size_t data_byte_size)
{
- assert(false);
+ if (type && GoType::KIND_STRING == static_cast<GoType *>(type)->GetGoKind())
+ {
+ // TODO(ribrdb): read length and data
+ }
}
void
GoASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type)
{
- assert(false);
-} // Dump to stdout
+ // Dump to stdout
+ StreamFile s (stdout, false);
+ DumpTypeDescription (type, &s);
+}
void
GoASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type, Stream *s)
{
- assert(false);
+ if (!type)
+ return;
+ ConstString name = GetTypeName(type);
+ GoType *t = static_cast<GoType *>(type);
+
+ if (GoStruct *st = t->GetStruct())
+ {
+ if (GetCompleteType(type))
+ {
+ if (NULL == strchr(name.AsCString(), '{'))
+ s->Printf("type %s ", name.AsCString());
+ s->PutCString("struct {");
+ if (st->GetNumFields() == 0) {
+ s->PutChar('}');
+ return;
+ }
+ s->IndentMore();
+ uint32_t field_idx = 0;
+ for (auto* field = st->GetField(field_idx); field != nullptr; field_idx++)
+ {
+ s->PutChar('\n');
+ s->Indent();
+ s->Printf("%s %s", field->m_name.AsCString(), field->m_type.GetTypeName().AsCString());
+ }
+ s->IndentLess();
+ s->PutChar('\n');
+ s->Indent("}");
+ return;
+ }
+ }
+
+ s->PutCString(name.AsCString());
}
CompilerType
diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp
index b20504addec9..709d899075a4 100644
--- a/source/Symbol/Symtab.cpp
+++ b/source/Symbol/Symtab.cpp
@@ -1071,6 +1071,26 @@ Symtab::FindSymbolContainingFileAddress (addr_t file_addr)
}
void
+Symtab::ForEachSymbolContainingFileAddress(addr_t file_addr, std::function<bool(Symbol *)> const &callback)
+{
+ Mutex::Locker locker (m_mutex);
+
+ if (!m_file_addr_to_index_computed)
+ InitAddressIndexes();
+
+ std::vector<uint32_t> all_addr_indexes;
+
+ // Get all symbols with file_addr
+ const size_t addr_match_count = m_file_addr_to_index.FindEntryIndexesThatContain(file_addr, all_addr_indexes);
+
+ for (size_t i = 0; i < addr_match_count; ++i)
+ {
+ if (!callback(SymbolAtIndex(all_addr_indexes[i])))
+ break;
+ }
+}
+
+void
Symtab::SymbolIndicesToSymbolContextList (std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list)
{
// No need to protect this call using m_mutex all other method calls are
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index d2aa1bac49f6..21e42916bae9 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -2442,18 +2442,18 @@ Target::GetBreakableLoadAddress (lldb::addr_t addr)
SymbolContext sc;
uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol;
temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, resolve_scope, sc);
+ Address sym_addr;
if (sc.function)
- {
- function_start = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress(this);
- if (function_start == LLDB_INVALID_ADDRESS)
- function_start = sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
- }
+ sym_addr = sc.function->GetAddressRange().GetBaseAddress();
else if (sc.symbol)
- {
- Address sym_addr = sc.symbol->GetAddress();
+ sym_addr = sc.symbol->GetAddress();
+
+ function_start = sym_addr.GetLoadAddress(this);
+ if (function_start == LLDB_INVALID_ADDRESS)
function_start = sym_addr.GetFileAddress();
- }
- current_offset = addr - function_start;
+
+ if (function_start)
+ current_offset = addr - function_start;
}
// If breakpoint address is start of function then we dont have to do anything.
diff --git a/tools/lldb-server/CMakeLists.txt b/tools/lldb-server/CMakeLists.txt
index c82be8a2beb3..28360914a51c 100644
--- a/tools/lldb-server/CMakeLists.txt
+++ b/tools/lldb-server/CMakeLists.txt
@@ -33,24 +33,19 @@ add_lldb_executable(lldb-server
LLDBServerUtilities.cpp
)
-if (BUILD_SHARED_LIBS )
- target_link_libraries(lldb-server liblldb)
- target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})
+# The Darwin linker doesn't understand --start-group/--end-group.
+if (LLDB_LINKER_SUPPORTS_GROUPS)
+ target_link_libraries(lldb-server
+ -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
+ target_link_libraries(lldb-server
+ -Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group)
else()
- # The Darwin linker doesn't understand --start-group/--end-group.
- if (LLDB_LINKER_SUPPORTS_GROUPS)
- target_link_libraries(lldb-server
- -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
- target_link_libraries(lldb-server
- -Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group)
- else()
- target_link_libraries(lldb-server ${LLDB_USED_LIBS})
- target_link_libraries(lldb-server ${CLANG_USED_LIBS})
- endif()
- llvm_config(lldb-server ${LLVM_LINK_COMPONENTS})
-
- target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})
+ target_link_libraries(lldb-server ${LLDB_USED_LIBS})
+ target_link_libraries(lldb-server ${CLANG_USED_LIBS})
endif()
+llvm_config(lldb-server ${LLVM_LINK_COMPONENTS})
+
+target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})
set_target_properties(lldb-server PROPERTIES VERSION ${LLDB_VERSION})