Skip to content

Commit e83b92d

Browse files
authored
Merge pull request #11176 from augusto2112/cp-lldb-rebranch-2
[lldb] Cherry pick missing commits into stable/21.x
2 parents 30469c7 + 3ab0a7b commit e83b92d

File tree

77 files changed

+3246
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3246
-263
lines changed

lldb/cmake/modules/AddLLDB.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ function(add_properties_for_swift_modules target reldir)
191191
set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_INSTALL_RPATH}")
192192
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android|OpenBSD|FreeBSD")
193193
string(REGEX MATCH "^[^-]*" arch ${LLVM_TARGET_TRIPLE})
194-
target_link_libraries(${target} PRIVATE swiftCore-linux-${arch})
195194
string(TOLOWER ${CMAKE_SYSTEM_NAME} platform)
195+
target_link_libraries(${target} PRIVATE swiftCore-${platform}-${arch})
196196
set(SWIFT_BUILD_RPATH "${LLDB_SWIFT_LIBS}/${platform}")
197197
set(SWIFT_INSTALL_RPATH "$ORIGIN/${reldir}lib/swift/${platform}")
198198
set_property(TARGET ${target} APPEND PROPERTY BUILD_RPATH "${SWIFT_BUILD_RPATH}")

lldb/docs/use/formatting.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ A complete list of currently supported format string variables is listed below:
8989
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
9090
| ``function.name-without-args`` | The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) |
9191
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
92+
| ``function.name-qualifiers`` | Any qualifiers added after the name of a function and before its arguments or template arguments. E.g., for Swift the name qualifier for ``closure #1 in A.foo<Int>()`` is `` in A.foo``. |
93+
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
9294
| ``function.basename`` | The basename of the current function depending on the frame's language. E.g., for C++ the basename for ``void ns::foo<float>::bar<int>(int) const`` is ``bar``. |
9395
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
9496
| ``function.prefix`` | Any prefix added to the demangled function name of the current function. This depends on the frame's language. E.g., for C++ the prefix will always be empty. |
@@ -332,6 +334,7 @@ The function names displayed in backtraces/``frame info``/``thread info`` are th
332334
- ``${function.prefix}``
333335
- ``${function.scope}``
334336
- ``${function.basename}``
337+
- ``${function.name-qualifiers}``
335338
- ``${function.template-arguments}``
336339
- ``${function.formatted-arguments}``
337340
- ``${function.qualifiers}``

lldb/include/lldb/Core/DemangledNameInfo.h

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,29 @@ namespace lldb_private {
2222
struct DemangledNameInfo {
2323
/// A [start, end) pair for the function basename.
2424
/// The basename is the name without scope qualifiers
25-
/// and without template parameters. E.g.,
25+
/// and without template parameters.
26+
///
27+
/// E.g.,
2628
/// \code{.cpp}
2729
/// void foo::bar<int>::someFunc<float>(int) const &&
2830
/// ^ ^
2931
/// start end
3032
/// \endcode
3133
std::pair<size_t, size_t> BasenameRange;
3234

35+
/// A [start, end) pair for the function template arguments.
36+
///
37+
/// E.g.,
38+
/// \code{.cpp}
39+
/// void foo::bar<int>::someFunc<float>(int) const &&
40+
/// ^ ^
41+
/// start end
42+
/// \endcode
43+
std::pair<size_t, size_t> TemplateArgumentsRange;
44+
3345
/// A [start, end) pair for the function scope qualifiers.
34-
/// E.g., for
46+
///
47+
/// E.g.,
3548
/// \code{.cpp}
3649
/// void foo::bar<int>::qux<float>(int) const &&
3750
/// ^ ^
@@ -40,6 +53,7 @@ struct DemangledNameInfo {
4053
std::pair<size_t, size_t> ScopeRange;
4154

4255
/// Indicates the [start, end) of the function argument list.
56+
///
4357
/// E.g.,
4458
/// \code{.cpp}
4559
/// int (*getFunc<float>(float, double))(int, int)
@@ -59,6 +73,19 @@ struct DemangledNameInfo {
5973
/// \endcode
6074
std::pair<size_t, size_t> QualifiersRange;
6175

76+
/// Indicates the [start, end) of the function's name qualifiers. This is a
77+
/// catch-all range for anything in between the basename and the function's
78+
/// arguments or template arguments, that is not tracked by the rest of the
79+
/// pairs.
80+
///
81+
/// E.g.,
82+
/// \code{.swift}
83+
/// closure #1 in A.foo<Int>()
84+
/// ^ ^
85+
/// start end
86+
/// \endcode
87+
std::pair<size_t, size_t> NameQualifiersRange;
88+
6289
/// Indicates the [start, end) of the function's prefix. This is a
6390
/// catch-all range for anything that is not tracked by the rest of
6491
/// the pairs.
@@ -75,6 +102,11 @@ struct DemangledNameInfo {
75102
return BasenameRange.second > BasenameRange.first;
76103
}
77104

105+
/// Returns \c true if this object holds a valid template arguments range.
106+
bool hasTemplateArguments() const {
107+
return TemplateArgumentsRange.second >= TemplateArgumentsRange.first;
108+
}
109+
78110
/// Returns \c true if this object holds a valid scope range.
79111
bool hasScope() const { return ScopeRange.second >= ScopeRange.first; }
80112

@@ -88,6 +120,11 @@ struct DemangledNameInfo {
88120
return QualifiersRange.second >= QualifiersRange.first;
89121
}
90122

123+
/// Returns \c true if this object holds a valid name qualifiers range.
124+
bool hasNameQualifiers() const {
125+
return NameQualifiersRange.second >= NameQualifiersRange.first;
126+
}
127+
91128
/// Returns \c true if this object holds a valid prefix range.
92129
bool hasPrefix() const { return PrefixRange.second >= PrefixRange.first; }
93130

lldb/include/lldb/Core/FormatEntity.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct Entry {
9191
FunctionPrefix,
9292
FunctionScope,
9393
FunctionBasename,
94+
FunctionNameQualifiers,
9495
FunctionTemplateArguments,
9596
FunctionFormattedArguments,
9697
FunctionReturnLeft,

lldb/include/lldb/Core/Mangled.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class Mangled {
3939
ePreferDemangledWithoutArguments
4040
};
4141

42+
enum NameFormatPreference {
43+
eCompactName,
44+
eFullName,
45+
};
46+
4247
enum ManglingScheme {
4348
eManglingSchemeNone = 0,
4449
eManglingSchemeMSVC,
@@ -125,7 +130,9 @@ class Mangled {
125130
///
126131
/// \return
127132
/// A const reference to the demangled name string object.
128-
ConstString GetDemangledName(const SymbolContext *sc = nullptr) const;
133+
ConstString
134+
GetDemangledName(const SymbolContext *sc = nullptr,
135+
NameFormatPreference preference = eFullName) const;
129136

130137
/// Display demangled name get accessor.
131138
///
@@ -291,7 +298,9 @@ class Mangled {
291298
/// demangled name (if any). If \c force is \c true (or the mangled name
292299
/// on this object was not previously demangled), demangle and cache the
293300
/// name.
294-
ConstString GetDemangledNameImpl(bool force, const SymbolContext *sc = nullptr) const;
301+
ConstString
302+
GetDemangledNameImpl(bool force, const SymbolContext *sc = nullptr,
303+
NameFormatPreference preference = eFullName) const;
295304

296305
/// The mangled version of the name.
297306
ConstString m_mangled;

lldb/include/lldb/Core/ModuleList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class ModuleListProperties : public Properties {
8686
bool GetSwiftLoadConformances() const;
8787
SwiftModuleLoadingMode GetSwiftModuleLoadingMode() const;
8888
bool SetSwiftModuleLoadingMode(SwiftModuleLoadingMode);
89+
bool GetSwiftPreferSerializedBridgingHeader() const;
8990

9091
bool GetEnableSwiftMetadataCache() const;
9192
uint64_t GetSwiftMetadataCacheMaxByteSize();

lldb/include/lldb/Target/Process.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class ProcessProperties : public Properties {
100100
void SetStopOnSharedLibraryEvents(bool stop);
101101
bool GetDisableLangRuntimeUnwindPlans() const;
102102
void SetDisableLangRuntimeUnwindPlans(bool disable);
103+
void DisableLanguageRuntimeUnwindPlansCallback();
103104
bool GetDetachKeepsStopped() const;
104105
void SetDetachKeepsStopped(bool keep_stopped);
105106
bool GetWarningsOptimization() const;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//===-- ThreadSafeStringMap.h ------------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLDB_UTILITY_THREADSAFESTRINGMAP_H
10+
#define LLDB_UTILITY_THREADSAFESTRINGMAP_H
11+
12+
#include <mutex>
13+
14+
#include "llvm/ADT/StringMap.h"
15+
16+
namespace lldb_private {
17+
18+
template <typename _ValueType> class ThreadSafeStringMap {
19+
public:
20+
typedef llvm::StringMap<_ValueType> LLVMMapType;
21+
22+
ThreadSafeStringMap(unsigned map_initial_capacity = 0)
23+
: m_map(map_initial_capacity), m_mutex() {}
24+
25+
void Insert(llvm::StringRef k, _ValueType v) {
26+
std::lock_guard<std::mutex> guard(m_mutex);
27+
m_map.insert(std::make_pair(k, v));
28+
}
29+
30+
void Erase(llvm::StringRef k) {
31+
std::lock_guard<std::mutex> guard(m_mutex);
32+
m_map.erase(k);
33+
}
34+
35+
_ValueType Lookup(llvm::StringRef k) {
36+
std::lock_guard<std::mutex> guard(m_mutex);
37+
return m_map.lookup(k);
38+
}
39+
40+
bool Lookup(llvm::StringRef k, _ValueType &v) {
41+
std::lock_guard<std::mutex> guard(m_mutex);
42+
auto iter = m_map.find(k), end = m_map.end();
43+
if (iter == end)
44+
return false;
45+
v = iter->second;
46+
return true;
47+
}
48+
49+
void Clear() {
50+
std::lock_guard<std::mutex> guard(m_mutex);
51+
m_map.clear();
52+
}
53+
54+
protected:
55+
LLVMMapType m_map;
56+
std::mutex m_mutex;
57+
};
58+
59+
} // namespace lldb_private
60+
61+
#endif // LLDB_UTILITY_THREADSAFESTRINGMAP_H

lldb/source/Commands/CommandObjectDWIMPrint.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
152152
return;
153153
}
154154
}
155+
m_interpreter.PrintWarningsIfNecessary(result.GetOutputStream(),
156+
m_cmd_name);
155157
result.SetStatus(eReturnStatusSuccessFinishResult);
156158
};
157159

lldb/source/Commands/CommandObjectExpression.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
494494
return false;
495495
}
496496

497+
m_interpreter.PrintWarningsIfNecessary(result.GetOutputStream(),
498+
m_cmd_name);
499+
497500
if (suppress_result)
498501
if (auto result_var_sp =
499502
target.GetPersistentVariable(result_valobj_sp->GetName())) {

0 commit comments

Comments
 (0)