Skip to content

Commit 8778f15

Browse files
committed
[lldb/Plugins] Replace platform-specific macro with LLVM_PRETTY_FUNCTION (NFC)
This patch refactors Scripted Process and Scripted Thread related classes to use LLVM_PRETTY_FUNCTION instead of the compiler macro. Differential Revision: https://reviews.llvm.org/D111452 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 27e3dc6 commit 8778f15

File tree

6 files changed

+23
-25
lines changed

6 files changed

+23
-25
lines changed

lldb/include/lldb/Interpreter/ScriptedInterface.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
#ifndef LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
1010
#define LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
1111

12-
#ifdef _MSC_VER
13-
#define __PRETTY_FUNCTION__ __FUNCSIG__
14-
#endif
15-
1612
#include "lldb/Core/StructuredDataImpl.h"
1713
#include "lldb/Target/ExecutionContext.h"
1814
#include "lldb/Utility/Log.h"
1915
#include "lldb/Utility/Logging.h"
2016
#include "lldb/lldb-private.h"
2117

18+
#include "llvm/Support/Compiler.h"
19+
2220
#include <string>
2321

2422
namespace lldb_private {

lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ bool ScriptedProcess::IsAlive() {
235235
size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
236236
Status &error) {
237237
if (!m_interpreter)
238-
return GetInterface().ErrorWithMessage<size_t>(__PRETTY_FUNCTION__,
238+
return GetInterface().ErrorWithMessage<size_t>(LLVM_PRETTY_FUNCTION,
239239
"No interpreter.", error);
240240

241241
lldb::DataExtractorSP data_extractor_sp =
@@ -249,7 +249,7 @@ size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
249249

250250
if (!bytes_copied || bytes_copied == LLDB_INVALID_OFFSET)
251251
return GetInterface().ErrorWithMessage<size_t>(
252-
__PRETTY_FUNCTION__, "Failed to copy read memory to buffer.", error);
252+
LLVM_PRETTY_FUNCTION, "Failed to copy read memory to buffer.", error);
253253

254254
return size;
255255
}
@@ -306,7 +306,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
306306

307307
if (language != eScriptLanguagePython)
308308
return GetInterface().ErrorWithMessage<bool>(
309-
__PRETTY_FUNCTION__,
309+
LLVM_PRETTY_FUNCTION,
310310
llvm::Twine("ScriptInterpreter language (" +
311311
llvm::Twine(m_interpreter->LanguageToString(language)) +
312312
llvm::Twine(") not supported."))
@@ -317,7 +317,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
317317
thread_sp = std::make_shared<ScriptedThread>(*this, error);
318318

319319
if (!thread_sp || error.Fail())
320-
return GetInterface().ErrorWithMessage<bool>(__PRETTY_FUNCTION__,
320+
return GetInterface().ErrorWithMessage<bool>(LLVM_PRETTY_FUNCTION,
321321
error.AsCString(), error);
322322

323323
new_thread_list.AddThread(thread_sp);

lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ bool ScriptedThread::CalculateStopInfo() {
141141

142142
if (!dict_sp->GetValueForKeyAsInteger("type", stop_reason_type))
143143
return GetInterface()->ErrorWithMessage<bool>(
144-
__PRETTY_FUNCTION__,
144+
LLVM_PRETTY_FUNCTION,
145145
"Couldn't find value for key 'type' in stop reason dictionary.", error);
146146

147147
StructuredData::Dictionary *data_dict;
148148
if (!dict_sp->GetValueForKeyAsDictionary("data", data_dict))
149149
return GetInterface()->ErrorWithMessage<bool>(
150-
__PRETTY_FUNCTION__,
150+
LLVM_PRETTY_FUNCTION,
151151
"Couldn't find value for key 'type' in stop reason dictionary.", error);
152152

153153
switch (stop_reason_type) {
@@ -171,7 +171,7 @@ bool ScriptedThread::CalculateStopInfo() {
171171
} break;
172172
default:
173173
return GetInterface()->ErrorWithMessage<bool>(
174-
__PRETTY_FUNCTION__,
174+
LLVM_PRETTY_FUNCTION,
175175
llvm::Twine("Unsupported stop reason type (" +
176176
llvm::Twine(stop_reason_type) + llvm::Twine(")."))
177177
.str(),

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bool ScriptedProcessPythonInterface::ShouldStop() {
7272
Status error;
7373
StructuredData::ObjectSP obj = Dispatch("is_alive", error);
7474

75-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
75+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
7676
return {};
7777

7878
return obj->GetBooleanValue();
@@ -89,7 +89,7 @@ ScriptedProcessPythonInterface::GetMemoryRegionContainingAddress(
8989
"get_memory_region_containing_address", error, address);
9090

9191
if (error.Fail()) {
92-
return ErrorWithMessage<MemoryRegionInfo>(__PRETTY_FUNCTION__,
92+
return ErrorWithMessage<MemoryRegionInfo>(LLVM_PRETTY_FUNCTION,
9393
error.AsCString(), error);
9494
}
9595

@@ -101,7 +101,7 @@ ScriptedProcessPythonInterface::GetThreadWithID(lldb::tid_t tid) {
101101
Status error;
102102
StructuredData::ObjectSP obj = Dispatch("get_thread_with_id", error, tid);
103103

104-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
104+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
105105
return {};
106106

107107
StructuredData::DictionarySP dict{obj->GetAsDictionary()};
@@ -130,7 +130,7 @@ lldb::pid_t ScriptedProcessPythonInterface::GetProcessID() {
130130
Status error;
131131
StructuredData::ObjectSP obj = Dispatch("get_process_id", error);
132132

133-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
133+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
134134
return LLDB_INVALID_PROCESS_ID;
135135

136136
return obj->GetIntegerValue(LLDB_INVALID_PROCESS_ID);
@@ -140,7 +140,7 @@ bool ScriptedProcessPythonInterface::IsAlive() {
140140
Status error;
141141
StructuredData::ObjectSP obj = Dispatch("is_alive", error);
142142

143-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
143+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
144144
return {};
145145

146146
return obj->GetBooleanValue();
@@ -151,7 +151,7 @@ ScriptedProcessPythonInterface::GetScriptedThreadPluginName() {
151151
Status error;
152152
StructuredData::ObjectSP obj = Dispatch("get_scripted_thread_plugin", error);
153153

154-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
154+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
155155
return {};
156156

157157
return obj->GetStringValue().str();

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
3939
using Locker = ScriptInterpreterPythonImpl::Locker;
4040

4141
std::string caller_signature =
42-
llvm::Twine(__PRETTY_FUNCTION__ + llvm::Twine(" (") +
42+
llvm::Twine(LLVM_PRETTY_FUNCTION + llvm::Twine(" (") +
4343
llvm::Twine(method_name) + llvm::Twine(")"))
4444
.str();
4545
if (!m_object_instance_sp)

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ lldb::tid_t ScriptedThreadPythonInterface::GetThreadID() {
6060
Status error;
6161
StructuredData::ObjectSP obj = Dispatch("get_thread_id", error);
6262

63-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
63+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
6464
return LLDB_INVALID_THREAD_ID;
6565

6666
return obj->GetIntegerValue(LLDB_INVALID_THREAD_ID);
@@ -70,7 +70,7 @@ llvm::Optional<std::string> ScriptedThreadPythonInterface::GetName() {
7070
Status error;
7171
StructuredData::ObjectSP obj = Dispatch("get_name", error);
7272

73-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
73+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
7474
return {};
7575

7676
return obj->GetStringValue().str();
@@ -80,7 +80,7 @@ lldb::StateType ScriptedThreadPythonInterface::GetState() {
8080
Status error;
8181
StructuredData::ObjectSP obj = Dispatch("get_state", error);
8282

83-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
83+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
8484
return eStateInvalid;
8585

8686
return static_cast<StateType>(obj->GetIntegerValue(eStateInvalid));
@@ -90,7 +90,7 @@ llvm::Optional<std::string> ScriptedThreadPythonInterface::GetQueue() {
9090
Status error;
9191
StructuredData::ObjectSP obj = Dispatch("get_queue", error);
9292

93-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
93+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
9494
return {};
9595

9696
return obj->GetStringValue().str();
@@ -101,7 +101,7 @@ StructuredData::DictionarySP ScriptedThreadPythonInterface::GetStopReason() {
101101
StructuredData::DictionarySP dict =
102102
Dispatch<StructuredData::DictionarySP>("get_stop_reason", error);
103103

104-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, dict, error))
104+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict, error))
105105
return {};
106106

107107
return dict;
@@ -116,7 +116,7 @@ StructuredData::DictionarySP ScriptedThreadPythonInterface::GetRegisterInfo() {
116116
StructuredData::DictionarySP dict =
117117
Dispatch<StructuredData::DictionarySP>("get_register_info", error);
118118

119-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, dict, error))
119+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict, error))
120120
return {};
121121

122122
return dict;
@@ -127,7 +127,7 @@ ScriptedThreadPythonInterface::GetRegisterContext() {
127127
Status error;
128128
StructuredData::ObjectSP obj = Dispatch("get_register_context", error);
129129

130-
if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
130+
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
131131
return {};
132132

133133
return obj->GetAsString()->GetValue().str();

0 commit comments

Comments
 (0)