From 7fed546d1996271dabc7cf71d4d033125c4da4ee Mon Sep 17 00:00:00 2001
From: Dimitry Andric
Date: Wed, 13 Jan 2016 20:06:56 +0000
Subject: [PATCH] Vendor import of lldb trunk r257626:
https://llvm.org/svn/llvm-project/lldb/trunk@257626
---
include/lldb/Core/LoadedModuleInfoList.h | 152 ++
.../lldb/Interpreter/CommandReturnObject.h | 20 +-
include/lldb/Symbol/ClangASTContext.h | 3 +
include/lldb/Symbol/CompilerDeclContext.h | 3 +
include/lldb/Symbol/GoASTContext.h | 6 +
include/lldb/Symbol/SymbolFile.h | 1 +
include/lldb/Symbol/TypeSystem.h | 3 +
include/lldb/Target/CPPLanguageRuntime.h | 3 -
include/lldb/Target/Process.h | 35 +
include/lldb/Target/SystemRuntime.h | 17 +
include/lldb/Target/Thread.h | 89 +-
include/lldb/Target/ThreadPlanStepOut.h | 3 +-
.../Python/lldbsuite/test/README-TestSuite | 7 +
.../api/multithreaded/TestMultithreaded.py | 2 +-
packages/Python/lldbsuite/test/dosep.py | 5 -
.../test/driver/batch_mode/TestBatchMode.py | 105 +-
.../lldbsuite/test/driver/batch_mode/main.c | 28 +-
.../functionalities/attach_resume/main.cpp | 17 +-
.../breakpoint/debugbreak/Makefile | 5 +
.../breakpoint/debugbreak/TestDebugBreak.py | 51 +
.../breakpoint/debugbreak/main.c | 29 +
...estDataFormatterLanguageCategoryUpdates.py | 1 -
.../inferior-assert/TestInferiorAssert.py | 4 +
.../inline-stepping/TestInlineStepping.py | 1 -
.../postmortem/minidump/TestMiniDump.py | 6 +-
.../postmortem/minidump/fizzbuzz.cpp | 62 +-
.../functionalities/process_attach/main.cpp | 19 +-
.../test/functionalities/process_group/main.c | 17 +-
.../test/functionalities/register/main.cpp | 17 +-
.../thread/create_after_attach/main.cpp | 19 +-
.../thread/jump/TestThreadJump.py | 4 +-
.../thread/state/TestThreadStates.py | 1 -
.../TestThreadSpecificBpPlusCondition.py | 1 -
.../unwind/noreturn/TestNoreturnUnwind.py | 2 +-
.../TestStepOverWatchpoint.py | 1 +
.../TestWatchLocationWithWatchSet.py | 1 +
.../test/lang/objc/global_ptrs/Makefile | 6 +
.../objc/global_ptrs/TestGlobalObjects.py | 53 +
.../test/lang/objc/global_ptrs/main.m | 11 +
packages/Python/lldbsuite/test/lldbinline.py | 8 +-
packages/Python/lldbsuite/test/lldbtest.py | 7 +-
.../Python/lldbsuite/test/make/test_common.h | 63 +-
.../TestDisassembleRawData.py | 24 +-
.../test/python_api/event/TestEvents.py | 4 +-
.../test/python_api/hello_world/main.c | 23 +-
.../module_section/TestModuleAndSection.py | 2 +
.../value/change_values/TestChangeValueAPI.py | 1 +
.../linked_list/TestValueAPILinkedList.py | 2 +
.../Python/lldbsuite/test/test_categories.py | 3 +-
.../lldbsuite/test/tools/lldb-server/main.cpp | 15 +-
scripts/Python/python-typemaps.swig | 20 +-
source/Commands/CommandObjectProcess.cpp | 1 +
source/Core/StringList.cpp | 1 -
source/Host/common/HostInfoBase.cpp | 2 +-
source/Interpreter/CommandInterpreter.cpp | 5 +-
source/Interpreter/CommandReturnObject.cpp | 3 +-
.../ABI/SysV-mips64/ABISysV_mips64.cpp | 8 +
.../POSIX-DYLD/DYLDRendezvous.cpp | 177 +-
.../DynamicLoader/POSIX-DYLD/DYLDRendezvous.h | 29 +-
.../Clang/ClangExpressionDeclMap.cpp | 76 +-
.../ExpressionParser/Clang/IRForTarget.cpp | 31 -
.../MIPS64/EmulateInstructionMIPS64.cpp | 2024 +++--------------
.../MIPS64/EmulateInstructionMIPS64.h | 136 +-
.../Language/CPlusPlus/CPlusPlusLanguage.cpp | 16 +
.../Language/CPlusPlus/CPlusPlusLanguage.h | 3 +
.../ItaniumABI/ItaniumABILanguageRuntime.cpp | 51 -
.../ItaniumABI/ItaniumABILanguageRuntime.h | 3 -
.../AppleObjCRuntime/AppleObjCRuntime.cpp | 15 +-
.../AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 13 +-
.../RenderScriptRuntime.cpp | 180 +-
.../RenderScriptRuntime/RenderScriptRuntime.h | 7 +-
.../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 10 +-
.../Linux/NativeRegisterContextLinux_arm.cpp | 88 +-
.../Linux/NativeRegisterContextLinux_arm.h | 16 +-
.../NativeRegisterContextLinux_arm64.cpp | 16 +-
.../NativeRegisterContextLinux_mips64.cpp | 10 +-
.../Process/Utility/InferiorCallPOSIX.cpp | 6 +-
.../Process/Utility/InferiorCallPOSIX.h | 3 +-
.../Process/Utility/RegisterContextLLDB.cpp | 29 +-
.../Process/Windows/Live/IDebugDelegate.h | 92 +-
.../Windows/Live/ProcessWindowsLive.cpp | 96 +-
.../GDBRemoteCommunicationClient.cpp | 61 +-
.../gdb-remote/GDBRemoteCommunicationClient.h | 2 +
.../Process/gdb-remote/ProcessGDBRemote.cpp | 198 +-
.../Process/gdb-remote/ProcessGDBRemote.h | 10 +-
.../Process/gdb-remote/ThreadGDBRemote.cpp | 107 +-
.../Process/gdb-remote/ThreadGDBRemote.h | 21 +-
.../Python/PythonDataObjects.cpp | 104 +
.../Python/PythonDataObjects.h | 37 +
.../Python/ScriptInterpreterPython.cpp | 6 +-
source/Plugins/SymbolFile/DWARF/DIERef.h | 12 +
.../SymbolFile/DWARF/DWARFASTParserClang.cpp | 2 +-
.../SymbolFile/DWARF/SymbolFileDWARF.cpp | 69 +-
.../SymbolFile/DWARF/SymbolFileDWARF.h | 7 +
.../MacOSX/SystemRuntimeMacOSX.cpp | 24 +-
.../MacOSX/SystemRuntimeMacOSX.h | 4 +-
.../UnwindAssembly/x86/UnwindAssembly-x86.cpp | 45 +-
source/Symbol/ClangASTContext.cpp | 15 +
source/Symbol/CompilerDeclContext.cpp | 9 +
source/Symbol/LineTable.cpp | 7 +
source/Symbol/SymbolFile.cpp | 6 +
source/Target/Process.cpp | 62 +
source/Target/Thread.cpp | 10 +-
source/Target/ThreadPlanShouldStopHere.cpp | 3 +-
source/Target/ThreadPlanStepOut.cpp | 29 +-
source/Target/ThreadPlanStepOverRange.cpp | 3 +-
tools/debugserver/source/RNBRemote.cpp | 59 +-
tools/debugserver/source/RNBRemote.h | 1 +
.../Python/PythonDataObjectsTests.cpp | 21 +
www/lldb-coding-conventions.html | 28 +-
www/lldb-gdb.html | 9 +
www/source.html | 80 +-
112 files changed, 2632 insertions(+), 2548 deletions(-)
create mode 100644 include/lldb/Core/LoadedModuleInfoList.h
create mode 100644 packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/Makefile
create mode 100644 packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py
create mode 100644 packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/main.c
create mode 100644 packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile
create mode 100644 packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py
create mode 100644 packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m
diff --git a/include/lldb/Core/LoadedModuleInfoList.h b/include/lldb/Core/LoadedModuleInfoList.h
new file mode 100644
index 000000000000..6ba5c2813ec4
--- /dev/null
+++ b/include/lldb/Core/LoadedModuleInfoList.h
@@ -0,0 +1,152 @@
+//===-- LoadedModuleInfoList.h ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_LoadedModuleInfoList_h_
+#define liblldb_LoadedModuleInfoList_h_
+
+// C Includes
+
+// C++ Includes
+#include
+
+// Other libraries and framework includes
+#include "lldb/lldb-private-forward.h"
+
+namespace lldb_private {
+class LoadedModuleInfoList
+{
+public:
+
+ class LoadedModuleInfo
+ {
+ public:
+
+ enum e_data_point
+ {
+ e_has_name = 0,
+ e_has_base ,
+ e_has_dynamic ,
+ e_has_link_map ,
+ e_num
+ };
+
+ LoadedModuleInfo ()
+ {
+ for (uint32_t i = 0; i < e_num; ++i)
+ m_has[i] = false;
+ };
+
+ void set_name (const std::string & name)
+ {
+ m_name = name;
+ m_has[e_has_name] = true;
+ }
+ bool get_name (std::string & out) const
+ {
+ out = m_name;
+ return m_has[e_has_name];
+ }
+
+ void set_base (const lldb::addr_t base)
+ {
+ m_base = base;
+ m_has[e_has_base] = true;
+ }
+ bool get_base (lldb::addr_t & out) const
+ {
+ out = m_base;
+ return m_has[e_has_base];
+ }
+
+ void set_base_is_offset (bool is_offset)
+ {
+ m_base_is_offset = is_offset;
+ }
+ bool get_base_is_offset(bool & out) const
+ {
+ out = m_base_is_offset;
+ return m_has[e_has_base];
+ }
+
+ void set_link_map (const lldb::addr_t addr)
+ {
+ m_link_map = addr;
+ m_has[e_has_link_map] = true;
+ }
+ bool get_link_map (lldb::addr_t & out) const
+ {
+ out = m_link_map;
+ return m_has[e_has_link_map];
+ }
+
+ void set_dynamic (const lldb::addr_t addr)
+ {
+ m_dynamic = addr;
+ m_has[e_has_dynamic] = true;
+ }
+ bool get_dynamic (lldb::addr_t & out) const
+ {
+ out = m_dynamic;
+ return m_has[e_has_dynamic];
+ }
+
+ bool has_info (e_data_point datum) const
+ {
+ assert (datum < e_num);
+ return m_has[datum];
+ }
+
+ bool
+ operator == (LoadedModuleInfo const &rhs) const
+ {
+ if (e_num != rhs.e_num)
+ return false;
+
+ for (size_t i = 0; i < e_num; ++i)
+ {
+ if (m_has[i] != rhs.m_has[i])
+ return false;
+ }
+
+ return (m_base == rhs.m_base) &&
+ (m_link_map == rhs.m_link_map) &&
+ (m_dynamic == rhs.m_dynamic) &&
+ (m_name == rhs.m_name);
+ }
+ protected:
+
+ bool m_has[e_num];
+ std::string m_name;
+ lldb::addr_t m_link_map;
+ lldb::addr_t m_base;
+ bool m_base_is_offset;
+ lldb::addr_t m_dynamic;
+ };
+
+ LoadedModuleInfoList ()
+ : m_list ()
+ , m_link_map (LLDB_INVALID_ADDRESS)
+ {}
+
+ void add (const LoadedModuleInfo & mod)
+ {
+ m_list.push_back (mod);
+ }
+
+ void clear ()
+ {
+ m_list.clear ();
+ }
+
+ std::vector m_list;
+ lldb::addr_t m_link_map;
+};
+} // namespace lldb_private
+
+#endif // liblldb_LoadedModuleInfoList_h_
diff --git a/include/lldb/Interpreter/CommandReturnObject.h b/include/lldb/Interpreter/CommandReturnObject.h
index 424ac800d14c..e3a1d9f657cb 100644
--- a/include/lldb/Interpreter/CommandReturnObject.h
+++ b/include/lldb/Interpreter/CommandReturnObject.h
@@ -169,6 +169,18 @@ class CommandReturnObject
void
SetInteractive (bool b);
+
+ bool
+ GetAbnormalStopWasExpected() const
+ {
+ return m_abnormal_stop_was_expected;
+ }
+
+ void
+ SetAbnormalStopWasExpected(bool signal_was_expected)
+ {
+ m_abnormal_stop_was_expected = signal_was_expected;
+ }
private:
enum
@@ -182,7 +194,13 @@ class CommandReturnObject
lldb::ReturnStatus m_status;
bool m_did_change_process_state;
- bool m_interactive; // If true, then the input handle from the debugger will be hooked up
+ bool m_interactive; // If true, then the input handle from the debugger will be hooked up
+ bool m_abnormal_stop_was_expected; // This is to support eHandleCommandFlagStopOnCrash vrs. attach.
+ // The attach command often ends up with the process stopped due to a signal.
+ // Normally that would mean stop on crash should halt batch execution, but we
+ // obviously don't want that for attach. Using this flag, the attach command
+ // (and anything else for which this is relevant) can say that the signal is
+ // expected, and batch command execution can continue.
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h
index 0314ce060e38..bd3a113e6cc5 100644
--- a/include/lldb/Symbol/ClangASTContext.h
+++ b/include/lldb/Symbol/ClangASTContext.h
@@ -573,6 +573,9 @@ class ClangASTContext : public TypeSystem
ConstString
DeclContextGetName (void *opaque_decl_ctx) override;
+ ConstString
+ DeclContextGetScopeQualifiedName (void *opaque_decl_ctx) override;
+
bool
DeclContextIsClassMethod (void *opaque_decl_ctx,
lldb::LanguageType *language_ptr,
diff --git a/include/lldb/Symbol/CompilerDeclContext.h b/include/lldb/Symbol/CompilerDeclContext.h
index 70399b2dbb37..9135b44323b5 100644
--- a/include/lldb/Symbol/CompilerDeclContext.h
+++ b/include/lldb/Symbol/CompilerDeclContext.h
@@ -128,6 +128,9 @@ class CompilerDeclContext
ConstString
GetName () const;
+ ConstString
+ GetScopeQualifiedName() const;
+
bool
IsStructUnionOrClass () const;
diff --git a/include/lldb/Symbol/GoASTContext.h b/include/lldb/Symbol/GoASTContext.h
index 3de98da59958..09d79bacc585 100644
--- a/include/lldb/Symbol/GoASTContext.h
+++ b/include/lldb/Symbol/GoASTContext.h
@@ -112,6 +112,12 @@ class GoASTContext : public TypeSystem
return ConstString();
}
+ ConstString
+ DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override
+ {
+ return ConstString();
+ }
+
bool
DeclContextIsClassMethod(void *opaque_decl_ctx, lldb::LanguageType *language_ptr, bool *is_instance_method_ptr,
ConstString *language_object_name_ptr) override
diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h
index e27b32d01f68..fe74ad4f933e 100644
--- a/include/lldb/Symbol/SymbolFile.h
+++ b/include/lldb/Symbol/SymbolFile.h
@@ -144,6 +144,7 @@ class SymbolFile :
virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, TypeMap& types);
virtual size_t FindTypes (const std::vector &context, bool append, TypeMap& types);
+ virtual void GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector &mangled_names);
// virtual uint32_t FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0;
virtual TypeList * GetTypeList ();
virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope,
diff --git a/include/lldb/Symbol/TypeSystem.h b/include/lldb/Symbol/TypeSystem.h
index d367bcdc0b14..9b43b9dec37b 100644
--- a/include/lldb/Symbol/TypeSystem.h
+++ b/include/lldb/Symbol/TypeSystem.h
@@ -151,6 +151,9 @@ class TypeSystem : public PluginInterface
virtual ConstString
DeclContextGetName (void *opaque_decl_ctx) = 0;
+ virtual ConstString
+ DeclContextGetScopeQualifiedName (void *opaque_decl_ctx) = 0;
+
virtual bool
DeclContextIsClassMethod (void *opaque_decl_ctx,
lldb::LanguageType *language_ptr,
diff --git a/include/lldb/Target/CPPLanguageRuntime.h b/include/lldb/Target/CPPLanguageRuntime.h
index ac537d0ad1e5..788f4e60a493 100644
--- a/include/lldb/Target/CPPLanguageRuntime.h
+++ b/include/lldb/Target/CPPLanguageRuntime.h
@@ -42,9 +42,6 @@ class CPPLanguageRuntime :
bool
GetObjectDescription(Stream &str, Value &value, ExecutionContextScope *exe_scope) override;
- virtual size_t
- GetAlternateManglings(const ConstString &mangled, std::vector &alternates) = 0;
-
protected:
//------------------------------------------------------------------
diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h
index 2e063c5bbccc..6bb7a3d783de 100644
--- a/include/lldb/Target/Process.h
+++ b/include/lldb/Target/Process.h
@@ -30,6 +30,7 @@
#include "lldb/Core/Communication.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Event.h"
+#include "lldb/Core/LoadedModuleInfoList.h"
#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/StructuredData.h"
@@ -1152,6 +1153,12 @@ class Process :
return 0;
}
+ virtual size_t
+ LoadModules (LoadedModuleInfoList &)
+ {
+ return 0;
+ }
+
protected:
virtual JITLoaderList &
GetJITLoaders ();
@@ -3149,6 +3156,34 @@ class Process :
void
ResetImageToken(size_t token);
+ //------------------------------------------------------------------
+ /// Find the next branch instruction to set a breakpoint on
+ ///
+ /// When instruction stepping through a source line, instead of
+ /// stepping through each instruction, we can put a breakpoint on
+ /// the next branch instruction (within the range of instructions
+ /// we are stepping through) and continue the process to there,
+ /// yielding significant performance benefits over instruction
+ /// stepping.
+ ///
+ /// @param[in] default_stop_addr
+ /// The address of the instruction where lldb would put a
+ /// breakpoint normally.
+ ///
+ /// @param[in] range_bounds
+ /// The range which the breakpoint must be contained within.
+ /// Typically a source line.
+ ///
+ /// @return
+ /// The address of the next branch instruction, or the end of
+ /// the range provided in range_bounds. If there are any
+ /// problems with the disassembly or getting the instructions,
+ /// the original default_stop_addr will be returned.
+ //------------------------------------------------------------------
+ Address
+ AdvanceAddressToNextBranchInstruction (Address default_stop_addr,
+ AddressRange range_bounds);
+
protected:
void
SetState (lldb::EventSP &event_sp);
diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h
index 54fde88c8d12..cefd72400450 100644
--- a/include/lldb/Target/SystemRuntime.h
+++ b/include/lldb/Target/SystemRuntime.h
@@ -275,6 +275,23 @@ class SystemRuntime :
return LLDB_INVALID_ADDRESS;
}
+
+ //------------------------------------------------------------------
+ /// Retrieve the Queue kind for the queue at a thread's dispatch_qaddr.
+ ///
+ /// Retrieve the Queue kind - either eQueueKindSerial or
+ /// eQueueKindConcurrent, indicating that this queue processes work
+ /// items serially or concurrently.
+ ///
+ /// @return
+ /// The Queue kind, if it could be read, else eQueueKindUnknown.
+ //------------------------------------------------------------------
+ virtual lldb::QueueKind
+ GetQueueKind (lldb::addr_t dispatch_qaddr)
+ {
+ return lldb::eQueueKindUnknown;
+ }
+
//------------------------------------------------------------------
/// Get the pending work items for a libdispatch Queue
///
diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h
index 7aff77bd16f4..ba73e0b49da8 100644
--- a/include/lldb/Target/Thread.h
+++ b/include/lldb/Target/Thread.h
@@ -366,6 +366,35 @@ class Thread :
{
}
+ //------------------------------------------------------------------
+ /// Whether this thread can be associated with a libdispatch queue
+ ///
+ /// The Thread may know if it is associated with a libdispatch queue,
+ /// it may know definitively that it is NOT associated with a libdispatch
+ /// queue, or it may be unknown whether it is associated with a libdispatch
+ /// queue.
+ ///
+ /// @return
+ /// eLazyBoolNo if this thread is definitely not associated with a
+ /// libdispatch queue (e.g. on a non-Darwin system where GCD aka
+ /// libdispatch is not available).
+ ///
+ /// eLazyBoolYes this thread is associated with a libdispatch queue.
+ ///
+ /// eLazyBoolCalculate this thread may be associated with a libdispatch
+ /// queue but the thread doesn't know one way or the other.
+ //------------------------------------------------------------------
+ virtual lldb_private::LazyBool
+ GetAssociatedWithLibdispatchQueue ()
+ {
+ return eLazyBoolNo;
+ }
+
+ virtual void
+ SetAssociatedWithLibdispatchQueue (lldb_private::LazyBool associated_with_libdispatch_queue)
+ {
+ }
+
//------------------------------------------------------------------
/// Retrieve the Queue ID for the queue currently using this Thread
///
@@ -413,6 +442,29 @@ class Thread :
{
}
+ //------------------------------------------------------------------
+ /// Retrieve the Queue kind for the queue currently using this Thread
+ ///
+ /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
+ /// retrieve the Queue kind - either eQueueKindSerial or
+ /// eQueueKindConcurrent, indicating that this queue processes work
+ /// items serially or concurrently.
+ ///
+ /// @return
+ /// The Queue kind, if the Thread subclass implements this, else
+ /// eQueueKindUnknown.
+ //------------------------------------------------------------------
+ virtual lldb::QueueKind
+ GetQueueKind ()
+ {
+ return lldb::eQueueKindUnknown;
+ }
+
+ virtual void
+ SetQueueKind (lldb::QueueKind kind)
+ {
+ }
+
//------------------------------------------------------------------
/// Retrieve the Queue for this thread, if any.
///
@@ -451,6 +503,30 @@ class Thread :
return LLDB_INVALID_ADDRESS;
}
+ virtual void
+ SetQueueLibdispatchQueueAddress (lldb::addr_t dispatch_queue_t)
+ {
+ }
+
+ //------------------------------------------------------------------
+ /// Whether this Thread already has all the Queue information cached or not
+ ///
+ /// A Thread may be associated with a libdispatch work Queue at a given
+ /// public stop event. If so, the thread can satisify requests like
+ /// GetQueueLibdispatchQueueAddress, GetQueueKind, GetQueueName, and GetQueueID
+ /// either from information from the remote debug stub when it is initially
+ /// created, or it can query the SystemRuntime for that information.
+ ///
+ /// This method allows the SystemRuntime to discover if a thread has this
+ /// information already, instead of calling the thread to get the information
+ /// and having the thread call the SystemRuntime again.
+ //------------------------------------------------------------------
+ virtual bool
+ ThreadHasQueueInformation () const
+ {
+ return false;
+ }
+
virtual uint32_t
GetStackFrameCount()
{
@@ -888,6 +964,16 @@ class Thread :
/// @param[in] run_vote
/// See standard meanings for the stop & run votes in ThreadPlan.h.
///
+ /// @param[in] continue_to_next_branch
+ /// Normally this will enqueue a plan that will put a breakpoint on the return address and continue
+ /// to there. If continue_to_next_branch is true, this is an operation not involving the user --
+ /// e.g. stepping "next" in a source line and we instruction stepped into another function --
+ /// so instead of putting a breakpoint on the return address, advance the breakpoint to the
+ /// end of the source line that is doing the call, or until the next flow control instruction.
+ /// If the return value from the function call is to be retrieved / displayed to the user, you must stop
+ /// on the return address. The return value may be stored in volatile registers which are overwritten
+ /// before the next branch instruction.
+ ///
/// @return
/// A shared pointer to the newly queued thread plan, or nullptr if the plan could not be queued.
//------------------------------------------------------------------
@@ -898,7 +984,8 @@ class Thread :
bool stop_other_threads,
Vote stop_vote, // = eVoteYes,
Vote run_vote, // = eVoteNoOpinion);
- uint32_t frame_idx);
+ uint32_t frame_idx,
+ bool continue_to_next_branch = false);
//------------------------------------------------------------------
/// Gets the plan used to step through the code that steps from a function
diff --git a/include/lldb/Target/ThreadPlanStepOut.h b/include/lldb/Target/ThreadPlanStepOut.h
index ac5696357e9b..ccf829f636df 100644
--- a/include/lldb/Target/ThreadPlanStepOut.h
+++ b/include/lldb/Target/ThreadPlanStepOut.h
@@ -31,7 +31,8 @@ class ThreadPlanStepOut : public ThreadPlan,
Vote stop_vote,
Vote run_vote,
uint32_t frame_idx,
- LazyBool step_out_avoids_code_without_debug_info);
+ LazyBool step_out_avoids_code_without_debug_info,
+ bool continue_to_next_branch = false);
~ThreadPlanStepOut() override;
diff --git a/packages/Python/lldbsuite/test/README-TestSuite b/packages/Python/lldbsuite/test/README-TestSuite
index 6df4d7bd7be7..70e4c91b8894 100644
--- a/packages/Python/lldbsuite/test/README-TestSuite
+++ b/packages/Python/lldbsuite/test/README-TestSuite
@@ -157,3 +157,10 @@ o Writing test cases:
then use SBInterpreter::HandleCommand to run the command. You get the full result text
from the command in the command return object, and all the part where you are driving the
debugger to the point you want to test will be more robust.
+
+o Attaching in test cases:
+
+ If you need to attach to inferiors in your tests, you must make sure the inferior calls
+ lldb_enable_attach(), before the debugger attempts to attach. This function performs any
+ platform-specific processing needed to enable attaching to this process (e.g., on Linux, we
+ execute prctl(PR_SET_TRACER) syscall to disable protections present in some Linux systems).
diff --git a/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py b/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
index 0b405091ebd1..9963cf23a8c6 100644
--- a/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
+++ b/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
@@ -51,7 +51,7 @@ def test_sb_api_listener_event_process_state(self):
@skipIfNoSBHeaders
@skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538)
@expectedFlakeyFreeBSD
- @expectedFlakeyLinux
+ @expectedFailureLinux
def test_sb_api_listener_resume(self):
""" Test that a process can be resumed from a non-main thread. """
self.build_and_test('driver.cpp listener_test.cpp test_listener_resume.cpp',
diff --git a/packages/Python/lldbsuite/test/dosep.py b/packages/Python/lldbsuite/test/dosep.py
index 51275d55c178..87a410fa090f 100644
--- a/packages/Python/lldbsuite/test/dosep.py
+++ b/packages/Python/lldbsuite/test/dosep.py
@@ -1149,11 +1149,6 @@ def getExpectedTimeouts(platform_name):
"TestExitDuringStep.py",
"TestHelloWorld.py",
}
- if host.startswith("win32"):
- expected_timeout |= {
- "TestEvents.py",
- "TestThreadStates.py",
- }
elif target.startswith("freebsd"):
expected_timeout |= {
"TestBreakpointConditions.py",
diff --git a/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py b/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
index b5ff88c3bba1..0a9edd2755c9 100644
--- a/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
+++ b/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
@@ -14,21 +14,12 @@ class DriverBatchModeTest (TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfRemote # test not remote-ready llvm.org/pr24813
- @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
- @expectedFlakeyLinux("llvm.org/pr25172")
- @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
- def test_driver_batch_mode(self):
- """Test that the lldb driver's batch mode works correctly."""
- self.build()
- self.setTearDownCleanup()
- self.batch_mode()
-
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
# Our simple source filename.
self.source = 'main.c'
+ self.victim = None
def expect_string (self, string):
import pexpect
@@ -40,12 +31,20 @@ def expect_string (self, string):
except pexpect.TIMEOUT:
self.fail ("Timed out waiting for '%s'"%(string))
- def batch_mode (self):
+ @skipIfRemote # test not remote-ready llvm.org/pr24813
+ @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
+ @expectedFlakeyLinux("llvm.org/pr25172")
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ def test_batch_mode_run_crash (self):
+ """Test that the lldb driver's batch mode works correctly."""
+ self.build()
+ self.setTearDownCleanup()
+
import pexpect
exe = os.path.join(os.getcwd(), "a.out")
prompt = "(lldb) "
- # First time through, pass CRASH so the process will crash and stop in batch mode.
+ # Pass CRASH so the process will crash and stop in batch mode.
run_commands = ' -b -o "break set -n main" -o "run" -o "continue" -k "frame var touch_me_not"'
self.child = pexpect.spawn('%s %s %s %s -- CRASH' % (lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
child = self.child
@@ -68,7 +67,21 @@ def batch_mode (self):
self.deletePexpectChild()
- # Now do it again, and see make sure if we don't crash, we quit:
+
+ @skipIfRemote # test not remote-ready llvm.org/pr24813
+ @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
+ @expectedFlakeyLinux("llvm.org/pr25172")
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ def test_batch_mode_run_exit (self):
+ """Test that the lldb driver's batch mode works correctly."""
+ self.build()
+ self.setTearDownCleanup()
+
+ import pexpect
+ exe = os.path.join(os.getcwd(), "a.out")
+ prompt = "(lldb) "
+
+ # Now do it again, and make sure if we don't crash, we quit:
run_commands = ' -b -o "break set -n main" -o "run" -o "continue" '
self.child = pexpect.spawn('%s %s %s %s -- NOCRASH' % (lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
child = self.child
@@ -87,3 +100,69 @@ def batch_mode (self):
index = self.child.expect([pexpect.EOF, pexpect.TIMEOUT])
self.assertTrue(index == 0, "lldb didn't close on successful batch completion.")
+ def closeVictim(self):
+ if self.victim != None:
+ self.victim.close()
+ self.victim = None
+
+ @skipIfRemote # test not remote-ready llvm.org/pr24813
+ @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
+ @expectedFlakeyLinux("llvm.org/pr25172")
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ def test_batch_mode_attach_exit (self):
+ """Test that the lldb driver's batch mode works correctly."""
+ self.build()
+ self.setTearDownCleanup()
+
+ import pexpect
+ exe = os.path.join(os.getcwd(), "a.out")
+ prompt = "(lldb) "
+
+ # Finally, start up the process by hand, attach to it, and wait for its completion.
+ # Attach is funny, since it looks like it stops with a signal on most Unixen so
+ # care must be taken not to treat that as a reason to exit batch mode.
+
+ # Start up the process by hand and wait for it to get to the wait loop.
+
+ self.victim = pexpect.spawn('%s WAIT' %(exe))
+ if self.victim == None:
+ self.fail("Could not spawn ", exe, ".")
+
+ self.addTearDownHook (self.closeVictim)
+
+ if self.TraceOn():
+ self.victim.logfile_read = sys.stdout
+
+ self.victim.expect("PID: ([0-9]+) END")
+ if self.victim.match == None:
+ self.fail("Couldn't get the target PID.")
+
+ victim_pid = int(self.victim.match.group(1))
+
+ self.victim.expect("Waiting")
+
+ run_commands = ' -b -o "process attach -p %d" -o "breakpoint set --file %s -p \'Stop here to unset keep_waiting\' -N keep_waiting" -o "continue" -o "break delete keep_waiting" -o "expr keep_waiting = 0" -o "continue" ' % (victim_pid, self.source)
+ self.child = pexpect.spawn('%s %s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
+
+ child = self.child
+ # Turn on logging for what the child sends back.
+ if self.TraceOn():
+ child.logfile_read = sys.stdout
+
+ # We should see the "run":
+ self.expect_string ("attach")
+
+ self.expect_string(prompt + "continue")
+
+ self.expect_string(prompt + "continue")
+
+ # Then we should see the process exit:
+ self.expect_string ("Process %d exited with status"%(victim_pid))
+
+ victim_index = self.victim.expect([pexpect.EOF, pexpect.TIMEOUT])
+ self.assertTrue(victim_index == 0, "Victim didn't really exit.")
+
+ index = self.child.expect([pexpect.EOF, pexpect.TIMEOUT])
+ self.assertTrue(index == 0, "lldb didn't close on successful batch completion.")
+
+
diff --git a/packages/Python/lldbsuite/test/driver/batch_mode/main.c b/packages/Python/lldbsuite/test/driver/batch_mode/main.c
index 418160eaa36d..c85a0f272d2c 100644
--- a/packages/Python/lldbsuite/test/driver/batch_mode/main.c
+++ b/packages/Python/lldbsuite/test/driver/batch_mode/main.c
@@ -1,10 +1,36 @@
#include
#include
+#include
int
main (int argc, char **argv)
{
- if (argc >= 2 && strcmp (argv[1], "CRASH") == 0)
+ lldb_enable_attach();
+
+ int do_crash = 0;
+ int do_wait = 0;
+
+ int idx;
+ for (idx = 1; idx < argc; idx++)
+ {
+ if (strcmp(argv[idx], "CRASH") == 0)
+ do_crash = 1;
+ if (strcmp(argv[idx], "WAIT") == 0)
+ do_wait = 1;
+ }
+ printf("PID: %d END\n", getpid());
+
+ if (do_wait)
+ {
+ int keep_waiting = 1;
+ while (keep_waiting)
+ {
+ printf ("Waiting\n");
+ sleep(1); // Stop here to unset keep_waiting
+ }
+ }
+
+ if (do_crash)
{
char *touch_me_not = (char *) 0;
printf ("About to crash.\n");
diff --git a/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp b/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp
index 7cf360258546..82aad70eed56 100644
--- a/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp
@@ -4,10 +4,6 @@
#include
#include
-#if defined(__linux__)
-#include
-#endif
-
volatile bool debugger_flag = true; // The debugger will flip this to false
void *start(void *data)
@@ -25,18 +21,7 @@ void *start(void *data)
int main(int argc, char const *argv[])
{
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- static_cast (prctl_result);
-#endif
-#endif
+ lldb_enable_attach();
static const size_t nthreads = 16;
std::thread threads[nthreads];
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/Makefile
new file mode 100644
index 000000000000..b09a579159d4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py
new file mode 100644
index 000000000000..b32c970301c9
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py
@@ -0,0 +1,51 @@
+"""
+Test embedded breakpoints, like `asm int 3;` in x86 or or `__debugbreak` on Windows.
+"""
+
+from __future__ import print_function
+
+import os
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class DebugBreakTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIf(archs=not_in(["i386", "i686"]))
+ @no_debug_info_test
+ def test_asm_int_3(self):
+ """Test that intrinsics like `__debugbreak();` and `asm {"int3"}` are treated like breakpoints."""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Run the program.
+ target = self.dbg.CreateTarget(exe)
+ process = target.LaunchSimple(None, None, self.get_process_working_directory())
+
+ # We've hit the first stop, so grab the frame.
+ self.assertEqual(process.GetState(), lldb.eStateStopped)
+ thread = process.GetThreadAtIndex(0)
+ frame = thread.GetFrameAtIndex(0)
+
+ # We should be in funciton 'bar'.
+ self.assertTrue(frame.IsValid())
+ function_name = frame.GetFunctionName()
+ self.assertTrue('bar' in function_name)
+
+ # We should be able to evaluate the parameter foo.
+ value = frame.EvaluateExpression('*foo')
+ self.assertEqual(value.GetValueAsSigned(), 42)
+
+ # The counter should be 1 at the first stop and increase by 2 for each
+ # subsequent stop.
+ counter = 1
+ while counter < 20:
+ value = frame.EvaluateExpression('count')
+ self.assertEqual(value.GetValueAsSigned(), counter)
+ counter += 2
+ process.Continue()
+
+ # The inferior should exit after the last iteration.
+ self.assertEqual(process.GetState(), lldb.eStateExited)
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/main.c
new file mode 100644
index 000000000000..5f936327e4ea
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/main.c
@@ -0,0 +1,29 @@
+#ifdef _MSC_VER
+#include
+#define BREAKPOINT_INTRINSIC() __debugbreak()
+#else
+#define BREAKPOINT_INTRINSIC() __asm__ __volatile__ ("int3")
+#endif
+
+int
+bar(int const *foo)
+{
+ int count = 0, i = 0;
+ for (; i < 10; ++i)
+ {
+ count += 1;
+ BREAKPOINT_INTRINSIC();
+ count += 1;
+ }
+ return *foo;
+}
+
+int
+main(int argc, char **argv)
+{
+ int foo = 42;
+ bar(&foo);
+ return 0;
+}
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py
index b7562c4336a6..f30733d2d81a 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py
@@ -21,7 +21,6 @@ def setUp(self):
# Find the line number to break at.
self.line = line_number('main.cpp', '// break here')
- @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows
def test_with_run_command(self):
"""Test that LLDB correctly cleans caches when language categories change."""
# This is the function to remove the custom formats in order to have a
diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py b/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
index 69e977e6343f..950b021b69ce 100644
--- a/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
+++ b/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
@@ -16,6 +16,7 @@ class AssertingInferiorTestCase(TestBase):
@expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
@expectedFailurei386("llvm.org/pr25338")
+ @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
def test_inferior_asserting(self):
"""Test that lldb reliably catches the inferior asserting (command)."""
self.build()
@@ -30,6 +31,7 @@ def test_inferior_asserting_register(self):
@expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
@expectedFailurei386("llvm.org/pr25338")
+ @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
def test_inferior_asserting_disassemble(self):
"""Test that lldb reliably disassembles frames after asserting (command)."""
self.build()
@@ -44,6 +46,7 @@ def test_inferior_asserting_python(self):
@expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
@expectedFailurei386("llvm.org/pr25338")
+ @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
def test_inferior_asserting_expr(self):
"""Test that the lldb expression interpreter can read from the inferior after asserting (command)."""
self.build()
@@ -51,6 +54,7 @@ def test_inferior_asserting_expr(self):
@expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
@expectedFailurei386("llvm.org/pr25338")
+ @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
def test_inferior_asserting_step(self):
"""Test that lldb functions correctly after stepping through a call to assert()."""
self.build()
diff --git a/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py b/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py
index 3bdf6ec70e34..023f6f31e395 100644
--- a/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py
+++ b/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py
@@ -16,7 +16,6 @@ class TestInlineStepping(TestBase):
@add_test_categories(['pyapi'])
@expectedFailureFreeBSD('llvm.org/pr17214')
@expectedFailureIcc # Not really a bug. ICC combines two inlined functions.
- @expectedFailureWindows("llvm.org/pr24778")
# failed 1/365 dosep runs, (i386-clang), TestInlineStepping.py:237 failed to stop at first breakpoint in main
@expectedFailureAll(oslist=["linux"], archs=["i386"])
def test_with_python_api(self):
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
index 53888502a3aa..1dda59ac374b 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
@@ -3,7 +3,7 @@
"""
from __future__ import print_function
-
+from six import iteritems
import lldb
@@ -83,8 +83,8 @@ def test_deeper_stack_in_mini_dump(self):
thread = process.GetThreadAtIndex(0)
expected_stack = { 0: 'bar', 1: 'foo', 2: 'main' }
- self.assertEqual(thread.GetNumFrames(), len(expected_stack))
- for index, name in expected_stack.iteritems():
+ self.assertGreaterEqual(thread.GetNumFrames(), len(expected_stack))
+ for index, name in iteritems(expected_stack):
frame = thread.GetFrameAtIndex(index)
self.assertTrue(frame.IsValid())
function_name = frame.GetFunctionName()
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp
index eb6476bfd9a9..295d4a1f24db 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp
@@ -1,31 +1,31 @@
-// A sample program for getting minidumps on Windows.
-
-#include
-
-bool
-fizz(int x)
-{
- return x % 3 == 0;
-}
-
-bool
-buzz(int x)
-{
- return x % 5 == 0;
-}
-
-int
-main()
-{
- int *buggy = 0;
-
- for (int i = 1; i <= 100; ++i)
- {
- if (fizz(i)) std::cout << "fizz";
- if (buzz(i)) std::cout << "buzz";
- if (!fizz(i) && !buzz(i)) std::cout << i;
- std::cout << '\n';
- }
-
- return *buggy;
-}
+// A sample program for getting minidumps on Windows.
+
+#include
+
+bool
+fizz(int x)
+{
+ return x % 3 == 0;
+}
+
+bool
+buzz(int x)
+{
+ return x % 5 == 0;
+}
+
+int
+main()
+{
+ int *buggy = 0;
+
+ for (int i = 1; i <= 100; ++i)
+ {
+ if (fizz(i)) std::cout << "fizz";
+ if (buzz(i)) std::cout << "buzz";
+ if (!fizz(i) && !buzz(i)) std::cout << i;
+ std::cout << '\n';
+ }
+
+ return *buggy;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/process_attach/main.cpp b/packages/Python/lldbsuite/test/functionalities/process_attach/main.cpp
index 8021feac5c71..46ffacc0a840 100644
--- a/packages/Python/lldbsuite/test/functionalities/process_attach/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/process_attach/main.cpp
@@ -1,28 +1,11 @@
#include
-#if defined(__linux__)
-#include
-#endif
-
#include
#include
int main(int argc, char const *argv[]) {
int temp;
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- int prctl_result;
-
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- (void) prctl_result;
-#endif
-#endif
+ lldb_enable_attach();
// Waiting to be attached by the debugger.
temp = 0;
diff --git a/packages/Python/lldbsuite/test/functionalities/process_group/main.c b/packages/Python/lldbsuite/test/functionalities/process_group/main.c
index c730c629e8b0..7e986bbac65d 100644
--- a/packages/Python/lldbsuite/test/functionalities/process_group/main.c
+++ b/packages/Python/lldbsuite/test/functionalities/process_group/main.c
@@ -2,10 +2,6 @@
#include
#include
-#if defined(__linux__)
-#include
-#endif
-
volatile int release_child_flag = 0;
int main(int argc, char const *argv[])
@@ -61,18 +57,7 @@ int main(int argc, char const *argv[])
}
else
{ // child
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- (void) prctl_result;
-#endif
-#endif
+ lldb_enable_attach();
while (! release_child_flag) // Wait for debugger to attach
sleep(1);
diff --git a/packages/Python/lldbsuite/test/functionalities/register/main.cpp b/packages/Python/lldbsuite/test/functionalities/register/main.cpp
index 876dd0833e54..156515768ddb 100644
--- a/packages/Python/lldbsuite/test/functionalities/register/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/register/main.cpp
@@ -8,10 +8,6 @@
//===----------------------------------------------------------------------===//
#include
-#if defined(__linux__)
-#include
-#endif
-
#include
#include
@@ -19,18 +15,7 @@ long double outermost_return_long_double (long double my_long_double);
int main (int argc, char const *argv[])
{
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- static_cast (prctl_result);
-#endif
-#endif
+ lldb_enable_attach();
char my_string[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 0};
double my_double = 1234.5678;
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/main.cpp
index 8434458f0648..d8f06e55a2dd 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/main.cpp
@@ -4,10 +4,6 @@
using std::chrono::microseconds;
-#if defined(__linux__)
-#include
-#endif
-
volatile int g_thread_2_continuing = 0;
void *
@@ -42,20 +38,7 @@ thread_2_func (void *input)
int main(int argc, char const *argv[])
{
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- int prctl_result;
-
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- (void) prctl_result;
-#endif
-#endif
+ lldb_enable_attach();
// Create a new thread
std::thread thread_1(thread_1_func, nullptr);
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
index be49a210f0f0..768e2fe4f87a 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
+++ b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
@@ -33,9 +33,7 @@ def test(self):
# The stop reason of the thread should be breakpoint 1.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 1",
- substrs = ['stopped',
- '* thread #1',
- 'stop reason = breakpoint 1'])
+ substrs=['stopped', 'main.cpp:{}'.format(self.mark3), 'stop reason = breakpoint 1'])
self.do_min_test(self.mark3, self.mark1, "i", "4"); # Try the int path, force it to return 'a'
self.do_min_test(self.mark3, self.mark2, "i", "5"); # Try the int path, force it to return 'b'
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
index 623c659ffa5c..4938ec50453e 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
+++ b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
@@ -19,7 +19,6 @@ class ThreadStateTestCase(TestBase):
@expectedFailureDarwin("rdar://15367566")
@expectedFailureFreeBSD('llvm.org/pr15824')
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
- @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly
def test_state_after_breakpoint(self):
"""Test thread state after breakpoint."""
self.build(dictionary=self.getBuildFlags(use_cpp11=False))
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
index b4a0b7a5dd4e..68c96a0fba75 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
+++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
@@ -20,7 +20,6 @@ class ThreadSpecificBreakPlusConditionTestCase(TestBase):
@skipIfFreeBSD # test frequently times out or hangs
@expectedFailureFreeBSD('llvm.org/pr18522') # hits break in another thread in testrun
@add_test_categories(['pyapi'])
- @expectedFailureWindows # Thread specific breakpoints cause the inferior to crash.
@expectedFlakeyLinux # this test fails 6/100 dosep runs
def test_python(self):
"""Test that we obey thread conditioned breakpoints."""
diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
index a419500f7a17..c0a311f7ac9e 100644
--- a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
+++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
@@ -14,7 +14,7 @@
class NoreturnUnwind(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @expectedFailurei386 #xfail to get buildbot green, failing config: i386 binary running on ubuntu 14.04 x86_64
+ @expectedFailurei386("llvm.org/pr25338")
@skipIfWindows # clang-cl does not support gcc style attributes.
def test (self):
"""Test that we can backtrace correctly with 'noreturn' functions on the stack"""
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
index dd18a6482066..f51da36b72d7 100644
--- a/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
@@ -17,6 +17,7 @@ def getCategories(self):
return ['basic_process']
@expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureLinux(bugnumber="llvm.org/pr26031", archs=['arm'])
@expectedFailureWindows("llvm.org/pr24446")
def test(self):
"""Test stepping over watchpoints."""
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py
index 6bdac7024847..9301a6f9fd00 100644
--- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py
@@ -27,6 +27,7 @@ def setUp(self):
# Build dictionary to have unique executable names for each test method.
@expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureLinux(bugnumber="llvm.org/pr26031", archs=['arm'])
@expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
def test_watchlocation_using_watchpoint_set(self):
"""Test watching a location with 'watchpoint set expression -w write -s size' option."""
diff --git a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile
new file mode 100644
index 000000000000..a1608fe5a664
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+LDFLAGS = $(CFLAGS) -lobjc -framework Foundation
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py
new file mode 100644
index 000000000000..c4c581b9240f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py
@@ -0,0 +1,53 @@
+"""Test that a global ObjC object found before the process is started updates correctly."""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+class TestObjCGlobalVar(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ self.main_source = lldb.SBFileSpec("main.m")
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test that a global ObjC object found before the process is started updates correctly."""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bkpt = target.BreakpointCreateBySourceRegex ('NSLog', self.main_source)
+ self.assertTrue(bkpt, VALID_BREAKPOINT)
+
+ # Before we launch, make an SBValue for our global object pointer:
+ g_obj_ptr = target.FindFirstGlobalVariable("g_obj_ptr")
+ self.assertTrue(g_obj_ptr.GetError().Success(), "Made the g_obj_ptr")
+ self.assertTrue(g_obj_ptr.GetValueAsUnsigned(10) == 0, "g_obj_ptr is initially null")
+
+ # 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)
+
+ # The stop reason of the thread should be breakpoint.
+ threads = lldbutil.get_threads_stopped_at_breakpoint (process, bkpt)
+ if len(threads) != 1:
+ self.fail ("Failed to stop at breakpoint 1.")
+
+ thread = threads[0]
+
+ dyn_value = g_obj_ptr.GetDynamicValue(lldb.eDynamicCanRunTarget)
+ self.assertTrue(dyn_value.GetError().Success(), "Dynamic value is valid")
+ self.assertTrue(dyn_value.GetObjectDescription() == "Some NSString")
diff --git a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m
new file mode 100644
index 000000000000..977a984e06e0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m
@@ -0,0 +1,11 @@
+#import
+
+id g_obj_ptr = nil;
+
+int
+main()
+{
+ g_obj_ptr = @"Some NSString";
+ NSLog(@"My string was %@.", g_obj_ptr);
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/lldbinline.py b/packages/Python/lldbsuite/test/lldbinline.py
index 691a3fba6dc2..abde6e790ded 100644
--- a/packages/Python/lldbsuite/test/lldbinline.py
+++ b/packages/Python/lldbsuite/test/lldbinline.py
@@ -3,7 +3,6 @@
# System modules
import os
-import sys
# Third-party modules
@@ -23,6 +22,7 @@ def source_type(filename):
'.mm' : 'OBJCXX_SOURCES'
}.get(extension, None)
+
class CommandParser:
def __init__(self):
self.breakpoints = []
@@ -34,7 +34,7 @@ def parse_one_command(self, line):
new_breakpoint = True
if len(parts) == 2:
- command = parts[1].strip() # take off whitespace
+ command = parts[1].strip() # take off whitespace
new_breakpoint = parts[0].strip() != ""
return (command, new_breakpoint)
@@ -85,7 +85,7 @@ def getRerunArgs(self):
return "-N dwarf %s" % (self.mydir)
else:
return "-N dsym %s" % (self.mydir)
-
+
def BuildMakefile(self):
if os.path.exists("Makefile"):
return
@@ -116,11 +116,11 @@ def BuildMakefile(self):
if ('CXX_SOURCES' in list(categories.keys())):
makefile.write("CXXFLAGS += -std=c++11\n")
+ makefile.write("\ncleanup:\n\trm -f Makefile *.d\n\n")
makefile.write("include $(LEVEL)/Makefile.rules\n")
makefile.flush()
makefile.close()
-
@skipUnlessDarwin
def __test_with_dsym(self):
self.using_dsym = True
diff --git a/packages/Python/lldbsuite/test/lldbtest.py b/packages/Python/lldbsuite/test/lldbtest.py
index 43d02c521d18..3ad6d29a1d7a 100644
--- a/packages/Python/lldbsuite/test/lldbtest.py
+++ b/packages/Python/lldbsuite/test/lldbtest.py
@@ -696,10 +696,11 @@ def expectedFailurei386(bugnumber=None):
def expectedFailurex86_64(bugnumber=None):
return expectedFailureArch('x86_64', bugnumber)
-def expectedFailureOS(oslist, bugnumber=None, compilers=None, debug_info=None):
+def expectedFailureOS(oslist, bugnumber=None, compilers=None, debug_info=None, archs=None):
def fn(self):
return (self.getPlatform() in oslist and
self.expectedCompiler(compilers) and
+ (archs is None or self.getArchitecture() in archs) and
(debug_info is None or self.debug_info in debug_info))
return expectedFailure(fn, bugnumber)
@@ -716,8 +717,8 @@ def expectedFailureDarwin(bugnumber=None, compilers=None, debug_info=None):
def expectedFailureFreeBSD(bugnumber=None, compilers=None, debug_info=None):
return expectedFailureOS(['freebsd'], bugnumber, compilers, debug_info=debug_info)
-def expectedFailureLinux(bugnumber=None, compilers=None, debug_info=None):
- return expectedFailureOS(['linux'], bugnumber, compilers, debug_info=debug_info)
+def expectedFailureLinux(bugnumber=None, compilers=None, debug_info=None, archs=None):
+ return expectedFailureOS(['linux'], bugnumber, compilers, debug_info=debug_info, archs=archs)
def expectedFailureNetBSD(bugnumber=None, compilers=None, debug_info=None):
return expectedFailureOS(['netbsd'], bugnumber, compilers, debug_info=debug_info)
diff --git a/packages/Python/lldbsuite/test/make/test_common.h b/packages/Python/lldbsuite/test/make/test_common.h
index 6f819706366e..a1ed364574e3 100644
--- a/packages/Python/lldbsuite/test/make/test_common.h
+++ b/packages/Python/lldbsuite/test/make/test_common.h
@@ -1,19 +1,44 @@
-// This header is included in all the test programs (C and C++) and provides a
-// hook for dealing with platform-specifics.
-#if defined(_WIN32) || defined(_WIN64)
-#ifdef COMPILING_LLDB_TEST_DLL
-#define LLDB_TEST_API __declspec(dllexport)
-#else
-#define LLDB_TEST_API __declspec(dllimport)
-#endif
-#else
-#define LLDB_TEST_API
-#endif
-
-#if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all
-// calls to __uncaught_exception. Unfortunately, it does seem to eliminate
-// the delcaration of __uncaught_excpeiton. Including ensures that it is
-// declared. This may not be necessary after MSVC 12.
-#include
-#endif
+// This header is included in all the test programs (C and C++) and provides a
+// hook for dealing with platform-specifics.
+#if defined(_WIN32) || defined(_WIN64)
+#ifdef COMPILING_LLDB_TEST_DLL
+#define LLDB_TEST_API __declspec(dllexport)
+#else
+#define LLDB_TEST_API __declspec(dllimport)
+#endif
+#else
+#define LLDB_TEST_API
+#endif
+
+#if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
+// Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all
+// calls to __uncaught_exception. Unfortunately, it does seem to eliminate
+// the delcaration of __uncaught_excpeiton. Including ensures that it is
+// declared. This may not be necessary after MSVC 12.
+#include
+#endif
+
+
+// On some systems (e.g., some versions of linux) it is not possible to attach to a process
+// without it giving us special permissions. This defines the lldb_enable_attach macro, which
+// should perform any such actions, if needed by the platform. This is a macro instead of a
+// function to avoid the need for complex linking of the test programs.
+#if defined(__linux__)
+#include
+
+#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
+// For now we execute on best effort basis. If this fails for some reason, so be it.
+#define lldb_enable_attach() \
+ do \
+ { \
+ const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0); \
+ (void)prctl_result; \
+ } while (0)
+
+#endif
+
+#else // not linux
+
+#define lldb_enable_attach()
+
+#endif
diff --git a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
index 20333abc57af..31ba44928794 100644
--- a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
+++ b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -21,11 +21,18 @@ class DisassembleRawDataTestCase(TestBase):
def test_disassemble_raw_data(self):
"""Test disassembling raw bytes with the API."""
# Create a target from the debugger.
- target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "x86_64")
+ arch = self.getArchitecture()
+ if re.match("mips*el",arch):
+ target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "mipsel")
+ raw_bytes = bytearray([0x21,0xf0, 0xa0, 0x03])
+ elif re.match("mips",arch):
+ target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "mips")
+ raw_bytes = bytearray([0x03,0xa0, 0xf0, 0x21])
+ else:
+ target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "x86_64")
+ raw_bytes = bytearray([0x48, 0x89, 0xe5])
+
self.assertTrue(target, VALID_TARGET)
-
- raw_bytes = bytearray([0x48, 0x89, 0xe5])
-
insts = target.GetInstructions(lldb.SBAddress(0, target), raw_bytes)
inst = insts.GetInstructionAtIndex(0)
@@ -34,6 +41,9 @@ def test_disassemble_raw_data(self):
print()
print("Raw bytes: ", [hex(x) for x in raw_bytes])
print("Disassembled%s" % str(inst))
-
- self.assertTrue (inst.GetMnemonic(target) == "movq")
- self.assertTrue (inst.GetOperands(target) == '%' + "rsp, " + '%' + "rbp")
+ if re.match("mips",arch):
+ self.assertTrue (inst.GetMnemonic(target) == "move")
+ self.assertTrue (inst.GetOperands(target) == '$' + "fp, " + '$' + "sp")
+ else:
+ self.assertTrue (inst.GetMnemonic(target) == "movq")
+ self.assertTrue (inst.GetOperands(target) == '%' + "rsp, " + '%' + "rbp")
diff --git a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py
index 0a1a0dfda7d2..51c924b2aff1 100644
--- a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py
+++ b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py
@@ -13,6 +13,7 @@
from lldbsuite.test.lldbtest import *
@skipIfDarwin # llvm.org/pr25924, sometimes generating SIGSEGV
+@skipIfLinux # llvm.org/pr25924, sometimes generating SIGSEGV
class EventAPITestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -25,7 +26,6 @@ def setUp(self):
@add_test_categories(['pyapi'])
@expectedFailureLinux("llvm.org/pr23730") # Flaky, fails ~1/10 cases
- @skipIfLinux # skip to avoid crashes
def test_listen_for_and_print_event(self):
"""Exercise SBEvent API."""
self.build()
@@ -176,7 +176,7 @@ def run(self):
@skipIfFreeBSD # llvm.org/pr21325
@add_test_categories(['pyapi'])
- @expectedFlakeyLinux("llvm.org/pr23617") # Flaky, fails ~1/10 cases
+ @expectedFailureLinux("llvm.org/pr23617") # Flaky, fails ~1/10 cases
@expectedFailureWindows("llvm.org/pr24778")
def test_add_listener_to_broadcaster(self):
"""Exercise some SBBroadcaster APIs."""
diff --git a/packages/Python/lldbsuite/test/python_api/hello_world/main.c b/packages/Python/lldbsuite/test/python_api/hello_world/main.c
index 31a041ede741..1b942d0db159 100644
--- a/packages/Python/lldbsuite/test/python_api/hello_world/main.c
+++ b/packages/Python/lldbsuite/test/python_api/hello_world/main.c
@@ -1,25 +1,8 @@
#include
-#if defined(__linux__)
-#include
-#endif
-
-int main(int argc, char const *argv[]) {
-
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- int prctl_result;
-
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- (void) prctl_result;
-#endif
-#endif
+int main(int argc, char const *argv[])
+{
+ lldb_enable_attach();
printf("Hello world.\n"); // Set break point at this line.
if (argc == 1)
diff --git a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
index bc97d432406f..2de026c54eef 100644
--- a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
+++ b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
@@ -16,6 +16,8 @@ class ModuleAndSectionAPIsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ # Py3 asserts due to a bug in SWIG. A fix for this was upstreamed into SWIG 3.0.8.
+ @skipIf(py_version=['>=', (3,0)], swig_version=['<', (3,0,8)])
@add_test_categories(['pyapi'])
def test_module_and_section(self):
"""Test module and section APIs."""
diff --git a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py
index 77aefe05be46..f8ad97277f05 100644
--- a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py
+++ b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py
@@ -28,6 +28,7 @@ def setUp(self):
@expectedFailureWindows("llvm.org/pr24772")
@add_test_categories(['pyapi'])
+ @expectedFlakeyLinux("llvm.org/pr25652")
def test_change_value(self):
"""Exercise the SBValue::SetValueFromCString API."""
d = {'EXE': self.exe_name}
diff --git a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
index 22d7e7ebf7e8..8b60be97bdc2 100644
--- a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
+++ b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
@@ -25,6 +25,8 @@ def setUp(self):
# Find the line number to break at.
self.line = line_number('main.cpp', '// Break at this line')
+ # Py3 asserts due to a bug in SWIG. A fix for this was upstreamed into SWIG 3.0.8.
+ @skipIf(py_version=['>=', (3,0)], swig_version=['<', (3,0,8)])
@add_test_categories(['pyapi'])
def test(self):
"""Exercise SBValue API linked_list_iter."""
diff --git a/packages/Python/lldbsuite/test/test_categories.py b/packages/Python/lldbsuite/test/test_categories.py
index e3e446091050..72b7afdf7241 100644
--- a/packages/Python/lldbsuite/test/test_categories.py
+++ b/packages/Python/lldbsuite/test/test_categories.py
@@ -44,7 +44,8 @@ def unique_string_match(yourentry, list):
def is_supported_on_platform(category, platform):
if category == "dwo":
- return platform in ["linux", "freebsd", "windows"]
+ # -gsplit-dwarf is not implemented by clang on Windows.
+ return platform in ["linux", "freebsd"]
elif category == "dsym":
return platform in ["darwin", "macosx", "ios"]
return True
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
index c65b22571596..b97c6ebc18e3 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
@@ -20,10 +20,6 @@ int pthread_threadid_np(pthread_t,__uint64_t*);
#include
#endif
-#if defined(__linux__)
-#include
-#endif
-
static const char *const RETVAL_PREFIX = "retval:";
static const char *const SLEEP_PREFIX = "sleep:";
static const char *const STDERR_PREFIX = "stderr:";
@@ -210,16 +206,7 @@ thread_func (void *arg)
int main (int argc, char **argv)
{
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- static_cast (prctl_result);
-#endif
-#endif
+ lldb_enable_attach();
std::vector threads;
std::unique_ptr heap_array_up;
diff --git a/scripts/Python/python-typemaps.swig b/scripts/Python/python-typemaps.swig
index ec9302a15cd7..9c4e5cecb363 100644
--- a/scripts/Python/python-typemaps.swig
+++ b/scripts/Python/python-typemaps.swig
@@ -26,15 +26,17 @@
}
%typemap(in) lldb::tid_t {
- if (PyInt_Check($input))
- $1 = PyInt_AsLong($input);
- else if (PyLong_Check($input))
- $1 = PyLong_AsLongLong($input);
- else
- {
- PyErr_SetString(PyExc_ValueError, "Expecting an integer");
- return NULL;
- }
+ using namespace lldb_private;
+ if (PythonInteger::Check($input))
+ {
+ PythonInteger py_int(PyRefType::Borrowed, $input);
+ $1 = static_cast(py_int.GetInteger());
+ }
+ else
+ {
+ PyErr_SetString(PyExc_ValueError, "Expecting an integer");
+ return nullptr;
+ }
}
%typemap(typecheck) char ** {
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index b7f894f6dcf5..a85ea179abb8 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -550,6 +550,7 @@ class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach
result.AppendMessage(stream.GetData());
result.SetStatus (eReturnStatusSuccessFinishNoResult);
result.SetDidChangeProcessState (true);
+ result.SetAbnormalStopWasExpected(true);
}
else
{
diff --git a/source/Core/StringList.cpp b/source/Core/StringList.cpp
index ce197ac7bd48..98a079007fba 100644
--- a/source/Core/StringList.cpp
+++ b/source/Core/StringList.cpp
@@ -12,7 +12,6 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
#include
diff --git a/source/Host/common/HostInfoBase.cpp b/source/Host/common/HostInfoBase.cpp
index 0f4324f83dd6..f7ba755b5bab 100644
--- a/source/Host/common/HostInfoBase.cpp
+++ b/source/Host/common/HostInfoBase.cpp
@@ -409,13 +409,13 @@ HostInfoBase::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_6
arch_32.SetTriple(triple);
break;
+ case llvm::Triple::aarch64:
case llvm::Triple::ppc64:
case llvm::Triple::x86_64:
arch_64.SetTriple(triple);
arch_32.SetTriple(triple.get32BitArchVariant());
break;
- case llvm::Triple::aarch64:
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
case llvm::Triple::sparcv9:
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index b7cc607e8070..fd88f0d6b4be 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -3038,7 +3038,10 @@ CommandInterpreter::IOHandlerInputComplete (IOHandler &io_handler, std::string &
for (ThreadSP thread_sp : process_sp->GetThreadList().Threads())
{
StopReason reason = thread_sp->GetStopReason();
- if (reason == eStopReasonSignal || reason == eStopReasonException || reason == eStopReasonInstrumentation)
+ if ((reason == eStopReasonSignal
+ || reason == eStopReasonException
+ || reason == eStopReasonInstrumentation)
+ && !result.GetAbnormalStopWasExpected())
{
should_stop = true;
break;
diff --git a/source/Interpreter/CommandReturnObject.cpp b/source/Interpreter/CommandReturnObject.cpp
index 1b5418735069..b083c7f69f13 100644
--- a/source/Interpreter/CommandReturnObject.cpp
+++ b/source/Interpreter/CommandReturnObject.cpp
@@ -47,7 +47,8 @@ CommandReturnObject::CommandReturnObject () :
m_err_stream (),
m_status (eReturnStatusStarted),
m_did_change_process_state (false),
- m_interactive (true)
+ m_interactive (true),
+ m_abnormal_stop_was_expected(false)
{
}
diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
index bc62c9fe82ee..e3da3631723e 100644
--- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
+++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
@@ -206,6 +206,7 @@ ABISysV_mips64::PrepareTrivialCall (Thread &thread,
const RegisterInfo *pc_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
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);
if (log)
log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp);
@@ -228,6 +229,13 @@ ABISysV_mips64::PrepareTrivialCall (Thread &thread,
if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_info, func_addr))
return false;
+ if (log)
+ log->Printf("Writing r25: 0x%" PRIx64, (uint64_t)func_addr);
+
+ // All callers of position independent functions must place the address of the called function in t9 (r25)
+ if (!reg_ctx->WriteRegisterFromUnsigned (r25_info, func_addr))
+ return false;
+
return true;
}
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index 09e874a011df..443f97ed0ba1 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -107,6 +107,7 @@ DYLDRendezvous::DYLDRendezvous(Process *process)
m_rendezvous_addr(LLDB_INVALID_ADDRESS),
m_current(),
m_previous(),
+ m_loaded_modules(),
m_soentries(),
m_added_soentries(),
m_removed_soentries()
@@ -181,6 +182,9 @@ DYLDRendezvous::Resolve()
m_previous = m_current;
m_current = info;
+ if (UpdateSOEntries (true))
+ return true;
+
return UpdateSOEntries();
}
@@ -191,18 +195,23 @@ DYLDRendezvous::IsValid()
}
bool
-DYLDRendezvous::UpdateSOEntries()
+DYLDRendezvous::UpdateSOEntries(bool fromRemote)
{
SOEntry entry;
+ LoadedModuleInfoList module_list;
- if (m_current.map_addr == 0)
+ // If we can't get the SO info from the remote, return failure.
+ if (fromRemote && m_process->LoadModules (module_list) == 0)
+ return false;
+
+ if (!fromRemote && m_current.map_addr == 0)
return false;
// When the previous and current states are consistent this is the first
// time we have been asked to update. Just take a snapshot of the currently
// loaded modules.
- if (m_previous.state == eConsistent && m_current.state == eConsistent)
- return TakeSnapshot(m_soentries);
+ if (m_previous.state == eConsistent && m_current.state == eConsistent)
+ return fromRemote ? SaveSOEntriesFromRemote(module_list) : TakeSnapshot(m_soentries);
// If we are about to add or remove a shared object clear out the current
// state and take a snapshot of the currently loaded images.
@@ -215,6 +224,9 @@ DYLDRendezvous::UpdateSOEntries()
return false;
m_soentries.clear();
+ if (fromRemote)
+ return SaveSOEntriesFromRemote(module_list);
+
m_added_soentries.clear();
m_removed_soentries.clear();
return TakeSnapshot(m_soentries);
@@ -224,15 +236,133 @@ DYLDRendezvous::UpdateSOEntries()
// Otherwise check the previous state to determine what to expect and update
// accordingly.
if (m_previous.state == eAdd)
- return UpdateSOEntriesForAddition();
+ return fromRemote ? AddSOEntriesFromRemote(module_list) : AddSOEntries();
else if (m_previous.state == eDelete)
- return UpdateSOEntriesForDeletion();
+ return fromRemote ? RemoveSOEntriesFromRemote(module_list) : RemoveSOEntries();
return false;
}
-
+
bool
-DYLDRendezvous::UpdateSOEntriesForAddition()
+DYLDRendezvous::FillSOEntryFromModuleInfo (LoadedModuleInfoList::LoadedModuleInfo const & modInfo,
+ SOEntry &entry)
+{
+ addr_t link_map_addr;
+ addr_t base_addr;
+ addr_t dyn_addr;
+ std::string name;
+
+ if (!modInfo.get_link_map (link_map_addr) ||
+ !modInfo.get_base (base_addr) ||
+ !modInfo.get_dynamic (dyn_addr) ||
+ !modInfo.get_name (name))
+ return false;
+
+ entry.link_addr = link_map_addr;
+ entry.base_addr = base_addr;
+ entry.dyn_addr = dyn_addr;
+
+ entry.file_spec.SetFile(name, false);
+
+ UpdateBaseAddrIfNecessary(entry, name);
+
+ // not needed if we're using ModuleInfos
+ entry.next = 0;
+ entry.prev = 0;
+ entry.path_addr = 0;
+
+ return true;
+}
+
+bool
+DYLDRendezvous::SaveSOEntriesFromRemote(LoadedModuleInfoList &module_list)
+{
+ for (auto const & modInfo : module_list.m_list)
+ {
+ SOEntry entry;
+ if (!FillSOEntryFromModuleInfo(modInfo, entry))
+ return false;
+
+ // Only add shared libraries and not the executable.
+ if (!SOEntryIsMainExecutable(entry))
+ m_soentries.push_back(entry);
+ }
+
+ m_loaded_modules = module_list;
+ return true;
+
+}
+
+bool
+DYLDRendezvous::AddSOEntriesFromRemote(LoadedModuleInfoList &module_list)
+{
+ for (auto const & modInfo : module_list.m_list)
+ {
+ bool found = false;
+ for (auto const & existing : m_loaded_modules.m_list)
+ {
+ if (modInfo == existing)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (found)
+ continue;
+
+ SOEntry entry;
+ if (!FillSOEntryFromModuleInfo(modInfo, entry))
+ return false;
+
+ // Only add shared libraries and not the executable.
+ if (!SOEntryIsMainExecutable(entry))
+ m_soentries.push_back(entry);
+ }
+
+ m_loaded_modules = module_list;
+ return true;
+}
+
+bool
+DYLDRendezvous::RemoveSOEntriesFromRemote(LoadedModuleInfoList &module_list)
+{
+ for (auto const & existing : m_loaded_modules.m_list)
+ {
+ bool found = false;
+ for (auto const & modInfo : module_list.m_list)
+ {
+ if (modInfo == existing)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (found)
+ continue;
+
+ SOEntry entry;
+ if (!FillSOEntryFromModuleInfo(existing, entry))
+ return false;
+
+ // Only add shared libraries and not the executable.
+ if (!SOEntryIsMainExecutable(entry))
+ {
+ auto pos = std::find(m_soentries.begin(), m_soentries.end(), entry);
+ if (pos == m_soentries.end())
+ return false;
+
+ m_soentries.erase(pos);
+ }
+ }
+
+ m_loaded_modules = module_list;
+ return true;
+}
+
+bool
+DYLDRendezvous::AddSOEntries()
{
SOEntry entry;
iterator pos;
@@ -263,7 +393,7 @@ DYLDRendezvous::UpdateSOEntriesForAddition()
}
bool
-DYLDRendezvous::UpdateSOEntriesForDeletion()
+DYLDRendezvous::RemoveSOEntries()
{
SOEntryList entry_list;
iterator pos;
@@ -291,7 +421,8 @@ DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry &entry)
// FreeBSD and on Android it is the full path to the executable.
auto triple = m_process->GetTarget().GetArchitecture().GetTriple();
- switch (triple.getOS()) {
+ switch (triple.getOS())
+ {
case llvm::Triple::FreeBSD:
return entry.file_spec == m_exe_file_spec;
case llvm::Triple::Linux:
@@ -386,6 +517,21 @@ isLoadBiasIncorrect(Target& target, const std::string& file_path)
return false;
}
+void
+DYLDRendezvous::UpdateBaseAddrIfNecessary(SOEntry &entry, std::string const &file_path)
+{
+ // If the load bias reported by the linker is incorrect then fetch the load address of the file
+ // from the proc file system.
+ if (isLoadBiasIncorrect(m_process->GetTarget(), file_path))
+ {
+ lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+ bool is_loaded = false;
+ Error error = m_process->GetFileLoadAddress(entry.file_spec, is_loaded, load_addr);
+ if (error.Success() && is_loaded)
+ entry.base_addr = load_addr;
+ }
+}
+
bool
DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
{
@@ -427,16 +573,7 @@ DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
std::string file_path = ReadStringFromMemory(entry.path_addr);
entry.file_spec.SetFile(file_path, false);
- // If the load bias reported by the linker is incorrect then fetch the load address of the file
- // from the proc file system.
- if (isLoadBiasIncorrect(m_process->GetTarget(), file_path))
- {
- lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
- bool is_loaded = false;
- Error error = m_process->GetFileLoadAddress(entry.file_spec, is_loaded, load_addr);
- if (error.Success() && is_loaded)
- entry.base_addr = load_addr;
- }
+ UpdateBaseAddrIfNecessary(entry, file_path);
return true;
}
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
index ec5af945ee7b..8498116c808f 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
@@ -20,6 +20,10 @@
#include "lldb/lldb-types.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/Core/LoadedModuleInfoList.h"
+
+using lldb_private::LoadedModuleInfoList;
+
namespace lldb_private {
class Process;
}
@@ -201,6 +205,9 @@ class DYLDRendezvous {
Rendezvous m_current;
Rendezvous m_previous;
+ /// List of currently loaded SO modules
+ LoadedModuleInfoList m_loaded_modules;
+
/// List of SOEntry objects corresponding to the current link map state.
SOEntryList m_soentries;
@@ -240,13 +247,29 @@ class DYLDRendezvous {
/// Updates the current set of SOEntries, the set of added entries, and the
/// set of removed entries.
bool
- UpdateSOEntries();
+ UpdateSOEntries(bool fromRemote = false);
bool
- UpdateSOEntriesForAddition();
+ FillSOEntryFromModuleInfo (LoadedModuleInfoList::LoadedModuleInfo const & modInfo,
+ SOEntry &entry);
bool
- UpdateSOEntriesForDeletion();
+ SaveSOEntriesFromRemote(LoadedModuleInfoList &module_list);
+
+ bool
+ AddSOEntriesFromRemote(LoadedModuleInfoList &module_list);
+
+ bool
+ RemoveSOEntriesFromRemote(LoadedModuleInfoList &module_list);
+
+ bool
+ AddSOEntries();
+
+ bool
+ RemoveSOEntries();
+
+ void
+ UpdateBaseAddrIfNecessary(SOEntry &entry, std::string const &file_path);
bool
SOEntryIsMainExecutable(const SOEntry &entry);
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index c9bc4b6487cd..f4d6b195c7f0 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -36,6 +36,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeList.h"
@@ -570,6 +571,63 @@ FindCodeSymbolInContext
}
}
+ConstString
+FindBestAlternateMangledName
+(
+ const ConstString &demangled,
+ const LanguageType &lang_type,
+ SymbolContext &sym_ctx
+)
+{
+ CPlusPlusLanguage::MethodName cpp_name(demangled);
+ std::string scope_qualified_name = cpp_name.GetScopeQualifiedName();
+
+ if (!scope_qualified_name.size())
+ return ConstString();
+
+ if (!sym_ctx.module_sp)
+ return ConstString();
+
+ SymbolVendor *sym_vendor = sym_ctx.module_sp->GetSymbolVendor();
+ if (!sym_vendor)
+ return ConstString();
+
+ lldb_private::SymbolFile *sym_file = sym_vendor->GetSymbolFile();
+ if (!sym_file)
+ return ConstString();
+
+ std::vector alternates;
+ sym_file->GetMangledNamesForFunction(scope_qualified_name, alternates);
+
+ std::vector param_and_qual_matches;
+ std::vector param_matches;
+ for (size_t i = 0; i < alternates.size(); i++)
+ {
+ ConstString alternate_mangled_name = alternates[i];
+ Mangled mangled(alternate_mangled_name, true);
+ ConstString demangled = mangled.GetDemangledName(lang_type);
+
+ CPlusPlusLanguage::MethodName alternate_cpp_name(demangled);
+ if (!cpp_name.IsValid())
+ continue;
+
+ if (alternate_cpp_name.GetArguments() == cpp_name.GetArguments())
+ {
+ if (alternate_cpp_name.GetQualifiers() == cpp_name.GetQualifiers())
+ param_and_qual_matches.push_back(alternate_mangled_name);
+ else
+ param_matches.push_back(alternate_mangled_name);
+ }
+ }
+
+ if (param_and_qual_matches.size())
+ return param_and_qual_matches[0]; // It is assumed that there will be only one!
+ else if (param_matches.size())
+ return param_matches[0]; // Return one of them as a best match
+ else
+ return ConstString();
+}
+
bool
ClangExpressionDeclMap::GetFunctionAddress
(
@@ -603,15 +661,25 @@ ClangExpressionDeclMap::GetFunctionAddress
if (Language::LanguageIsCPlusPlus(lang_type) &&
CPlusPlusLanguage::IsCPPMangledName(name.AsCString()))
{
- // 1. Demangle the name
Mangled mangled(name, true);
ConstString demangled = mangled.GetDemangledName(lang_type);
if (demangled)
{
- FindCodeSymbolInContext(
- demangled, m_parser_vars->m_sym_ctx, eFunctionNameTypeFull, sc_list);
- sc_list_size = sc_list.GetSize();
+ ConstString best_alternate_mangled_name = FindBestAlternateMangledName(demangled, lang_type, sc);
+ if (best_alternate_mangled_name)
+ {
+ FindCodeSymbolInContext(
+ best_alternate_mangled_name, m_parser_vars->m_sym_ctx, eFunctionNameTypeAuto, sc_list);
+ sc_list_size = sc_list.GetSize();
+ }
+
+ if (sc_list_size == 0)
+ {
+ FindCodeSymbolInContext(
+ demangled, m_parser_vars->m_sym_ctx, eFunctionNameTypeFull, sc_list);
+ sc_list_size = sc_list.GetSize();
+ }
}
}
}
diff --git a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 37b7bd1d2c84..509c594280a0 100644
--- a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -36,7 +36,6 @@
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include
-
- For MacOSX building from Xcode, simply checkout LLDB and then build from Xcode. The Xcode project will
- automatically detect that it is a fresh checkout, and checkout LLVM and clang automatically. Unlike other
- platforms / build systems, it will use the following directory structure.
-
- lldb
- |
- `-- llvm
- |
- +-- tools
- |
- `-- clang
-
-
- So updating your checkout will consist of updating lldb, llvm, and clang in these locations.
-
-
- Refer to the Build Instructions for more detailed instructions on how to build for a particular
- platform / build system combination.
+
+ For MacOSX building from Xcode, simply checkout LLDB and then build from Xcode. The Xcode project will
+ automatically detect that it is a fresh checkout, and checkout LLVM and clang automatically. Unlike other
+ platforms / build systems, it will use the following directory structure.
+
+ lldb
+ |
+ `-- llvm
+ |
+ +-- tools
+ |
+ `-- clang
+
+
+ So updating your checkout will consist of updating lldb, llvm, and clang in these locations.
+
+
+ Refer to the Build Instructions for more detailed instructions on how to build for a particular
+ platform / build system combination.
-
- Please refer to the LLVM Developer Policy
- for information about authoring and uploading a patch. LLDB differs from the LLVM Developer Policy in
- the following respects.
-
- - Coding conventions. Refer to LLDB Coding Conventions.
- -
- Test infrastructure. It is still important to submit tests with your patches, but LLDB uses a different
- system for tests. Refer to the lldb/test folder on disk for examples of how to write tests.
-
-
- For anything not explicitly listed here, assume that LLDB follows the LLVM policy.
+
+ Please refer to the LLVM Developer Policy
+ for information about authoring and uploading a patch. LLDB differs from the LLVM Developer Policy in
+ the following respects.
+
+ - Coding conventions. Refer to LLDB Coding Conventions.
+ -
+ Test infrastructure. It is still important to submit tests with your patches, but LLDB uses a different
+ system for tests. Refer to the lldb/test folder on disk for examples of how to write tests.
+
+
+ For anything not explicitly listed here, assume that LLDB follows the LLVM policy.