[Lldb-commits] [lldb] 88a941b - [lldb/Plugins] Replace platform-specific macro with LLVM_PRETTY_FUNCTION (NFC)

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 8 11:51:00 PDT 2021


Author: Med Ismail Bennani
Date: 2021-10-08T20:50:45+02:00
New Revision: 88a941ba64a3824e1a6bac178034e4fce548f6cb

URL: https://github.com/llvm/llvm-project/commit/88a941ba64a3824e1a6bac178034e4fce548f6cb
DIFF: https://github.com/llvm/llvm-project/commit/88a941ba64a3824e1a6bac178034e4fce548f6cb.diff

LOG: [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 <medismail.bennani at gmail.com>

Added: 
    

Modified: 
    lldb/include/lldb/Interpreter/ScriptedInterface.h
    lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
    lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
    lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
    lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
    lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/ScriptedInterface.h b/lldb/include/lldb/Interpreter/ScriptedInterface.h
index bd1ed11279f4..427fa3f4f793 100644
--- a/lldb/include/lldb/Interpreter/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/ScriptedInterface.h
@@ -9,16 +9,14 @@
 #ifndef LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
 #define LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
 
-#ifdef _MSC_VER
-#define __PRETTY_FUNCTION__ __FUNCSIG__
-#endif
-
 #include "lldb/Core/StructuredDataImpl.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Logging.h"
 #include "lldb/lldb-private.h"
 
+#include "llvm/Support/Compiler.h"
+
 #include <string>
 
 namespace lldb_private {

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 551a0f752c9c..58576251be14 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -233,7 +233,7 @@ bool ScriptedProcess::IsAlive() {
 size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
                                      Status &error) {
   if (!m_interpreter)
-    return GetInterface().ErrorWithMessage<size_t>(__PRETTY_FUNCTION__,
+    return GetInterface().ErrorWithMessage<size_t>(LLVM_PRETTY_FUNCTION,
                                                    "No interpreter.", error);
 
   lldb::DataExtractorSP data_extractor_sp =
@@ -247,7 +247,7 @@ size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
 
   if (!bytes_copied || bytes_copied == LLDB_INVALID_OFFSET)
     return GetInterface().ErrorWithMessage<size_t>(
-        __PRETTY_FUNCTION__, "Failed to copy read memory to buffer.", error);
+        LLVM_PRETTY_FUNCTION, "Failed to copy read memory to buffer.", error);
 
   return size;
 }
@@ -304,7 +304,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
 
   if (language != eScriptLanguagePython)
     return GetInterface().ErrorWithMessage<bool>(
-        __PRETTY_FUNCTION__,
+        LLVM_PRETTY_FUNCTION,
         llvm::Twine("ScriptInterpreter language (" +
                     llvm::Twine(m_interpreter->LanguageToString(language)) +
                     llvm::Twine(") not supported."))
@@ -315,7 +315,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
   thread_sp = std::make_shared<ScriptedThread>(*this, error);
 
   if (!thread_sp || error.Fail())
-    return GetInterface().ErrorWithMessage<bool>(__PRETTY_FUNCTION__,
+    return GetInterface().ErrorWithMessage<bool>(LLVM_PRETTY_FUNCTION,
                                                  error.AsCString(), error);
 
   new_thread_list.AddThread(thread_sp);

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
index 11db89bfc397..de1203300e4b 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -141,13 +141,13 @@ bool ScriptedThread::CalculateStopInfo() {
 
   if (!dict_sp->GetValueForKeyAsInteger("type", stop_reason_type))
     return GetInterface()->ErrorWithMessage<bool>(
-        __PRETTY_FUNCTION__,
+        LLVM_PRETTY_FUNCTION,
         "Couldn't find value for key 'type' in stop reason dictionary.", error);
 
   StructuredData::Dictionary *data_dict;
   if (!dict_sp->GetValueForKeyAsDictionary("data", data_dict))
     return GetInterface()->ErrorWithMessage<bool>(
-        __PRETTY_FUNCTION__,
+        LLVM_PRETTY_FUNCTION,
         "Couldn't find value for key 'type' in stop reason dictionary.", error);
 
   switch (stop_reason_type) {
@@ -171,7 +171,7 @@ bool ScriptedThread::CalculateStopInfo() {
   } break;
   default:
     return GetInterface()->ErrorWithMessage<bool>(
-        __PRETTY_FUNCTION__,
+        LLVM_PRETTY_FUNCTION,
         llvm::Twine("Unsupported stop reason type (" +
                     llvm::Twine(stop_reason_type) + llvm::Twine(")."))
             .str(),

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
index ffaee2614793..29680dab5a14 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -72,7 +72,7 @@ bool ScriptedProcessPythonInterface::ShouldStop() {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("is_alive", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return {};
 
   return obj->GetBooleanValue();
@@ -89,7 +89,7 @@ ScriptedProcessPythonInterface::GetMemoryRegionContainingAddress(
       "get_memory_region_containing_address", error, address);
 
   if (error.Fail()) {
-    return ErrorWithMessage<MemoryRegionInfo>(__PRETTY_FUNCTION__,
+    return ErrorWithMessage<MemoryRegionInfo>(LLVM_PRETTY_FUNCTION,
                                               error.AsCString(), error);
   }
 
@@ -101,7 +101,7 @@ ScriptedProcessPythonInterface::GetThreadWithID(lldb::tid_t tid) {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("get_thread_with_id", error, tid);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return {};
 
   StructuredData::DictionarySP dict{obj->GetAsDictionary()};
@@ -130,7 +130,7 @@ lldb::pid_t ScriptedProcessPythonInterface::GetProcessID() {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("get_process_id", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return LLDB_INVALID_PROCESS_ID;
 
   return obj->GetIntegerValue(LLDB_INVALID_PROCESS_ID);
@@ -140,7 +140,7 @@ bool ScriptedProcessPythonInterface::IsAlive() {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("is_alive", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return {};
 
   return obj->GetBooleanValue();
@@ -151,7 +151,7 @@ ScriptedProcessPythonInterface::GetScriptedThreadPluginName() {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("get_scripted_thread_plugin", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return {};
 
   return obj->GetStringValue().str();

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
index 9b81555dacb6..da112eb72022 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
@@ -39,7 +39,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
     using Locker = ScriptInterpreterPythonImpl::Locker;
 
     std::string caller_signature =
-        llvm::Twine(__PRETTY_FUNCTION__ + llvm::Twine(" (") +
+        llvm::Twine(LLVM_PRETTY_FUNCTION + llvm::Twine(" (") +
                     llvm::Twine(method_name) + llvm::Twine(")"))
             .str();
     if (!m_object_instance_sp)

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
index c2aa4381a1ce..4d6903d567c5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
@@ -60,7 +60,7 @@ lldb::tid_t ScriptedThreadPythonInterface::GetThreadID() {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("get_thread_id", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return LLDB_INVALID_THREAD_ID;
 
   return obj->GetIntegerValue(LLDB_INVALID_THREAD_ID);
@@ -70,7 +70,7 @@ llvm::Optional<std::string> ScriptedThreadPythonInterface::GetName() {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("get_name", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return {};
 
   return obj->GetStringValue().str();
@@ -80,7 +80,7 @@ lldb::StateType ScriptedThreadPythonInterface::GetState() {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("get_state", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return eStateInvalid;
 
   return static_cast<StateType>(obj->GetIntegerValue(eStateInvalid));
@@ -90,7 +90,7 @@ llvm::Optional<std::string> ScriptedThreadPythonInterface::GetQueue() {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("get_queue", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return {};
 
   return obj->GetStringValue().str();
@@ -101,7 +101,7 @@ StructuredData::DictionarySP ScriptedThreadPythonInterface::GetStopReason() {
   StructuredData::DictionarySP dict =
       Dispatch<StructuredData::DictionarySP>("get_stop_reason", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, dict, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict, error))
     return {};
 
   return dict;
@@ -116,7 +116,7 @@ StructuredData::DictionarySP ScriptedThreadPythonInterface::GetRegisterInfo() {
   StructuredData::DictionarySP dict =
       Dispatch<StructuredData::DictionarySP>("get_register_info", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, dict, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict, error))
     return {};
 
   return dict;
@@ -127,7 +127,7 @@ ScriptedThreadPythonInterface::GetRegisterContext() {
   Status error;
   StructuredData::ObjectSP obj = Dispatch("get_register_context", error);
 
-  if (!CheckStructuredDataObject(__PRETTY_FUNCTION__, obj, error))
+  if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
     return {};
 
   return obj->GetAsString()->GetValue().str();


        


More information about the lldb-commits mailing list