[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)

via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 4 07:49:07 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 34b10e165d809bb133d37dfe934859800f21a100 66d055aa303c8fa07c4db2023dc175bad48a15a0 --extensions cpp,h -- lldb/source/Plugins/Architecture/RISCV/ArchitectureRISCV.cpp lldb/source/Plugins/Architecture/RISCV/ArchitectureRISCV.h lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.cpp lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.h lldb/test/API/riscv/expressions/main.cpp lldb/include/lldb/Core/Architecture.h lldb/source/Expression/IRExecutionUnit.cpp lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
index fa36d764d3..02f9fae57c 100644
--- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
+++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
@@ -190,8 +190,7 @@ static void LogInitInfo(Log *log, const Thread &thread, addr_t sp,
   std::stringstream ss;
   ss << "ABISysV_riscv::PrepareTrivialCall"
      << " (tid = 0x" << std::hex << thread.GetID() << ", sp = 0x" << sp
-     << ", func_addr = 0x" << func_addr << ", return_addr = 0x"
-     << return_addr;
+     << ", func_addr = 0x" << func_addr << ", return_addr = 0x" << return_addr;
 
   for (auto &&[idx, arg] : enumerate(args))
     ss << ", arg" << std::dec << idx << " = 0x" << std::hex << arg;
diff --git a/lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.cpp b/lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.cpp
index 74096ebb20..4b73d0cf5e 100644
--- a/lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.cpp
+++ b/lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.cpp
@@ -53,14 +53,15 @@ std::string getFunctionName(const llvm::CallInst *ci) {
 bool DirectCallReplacementPass::canBeReplaced(const llvm::CallInst *ci) {
   assert(ci);
   Log *log = GetLog(LLDBLog::Expressions);
-  
+
   auto *return_value_ty = ci->getType();
   if (!(return_value_ty->isIntegerTy() || return_value_ty->isVoidTy() ||
         return_value_ty->isPointerTy())) {
-    LLDB_LOG(log, "DirectCallReplacementPass::{0}() function {1} has unsupported "
-               "return type ({2})\n", __FUNCTION__,
-               getFunctionName(ci),
-               GetValueTypeStr(return_value_ty));
+    LLDB_LOG(log,
+             "DirectCallReplacementPass::{0}() function {1} has unsupported "
+             "return type ({2})\n",
+             __FUNCTION__, getFunctionName(ci),
+             GetValueTypeStr(return_value_ty));
     return false;
   }
 
@@ -70,10 +71,11 @@ bool DirectCallReplacementPass::canBeReplaced(const llvm::CallInst *ci) {
   });
 
   if (arg != ci->arg_end()) {
-    LLDB_LOG(log, "DirectCallReplacementPass::{0}() argument {1} of {2} function "
-               "has unsupported type ({3})\n", __FUNCTION__,
-               (*arg)->getName(), getFunctionName(ci),
-               GetValueTypeStr((*arg)->getType()));
+    LLDB_LOG(log,
+             "DirectCallReplacementPass::{0}() argument {1} of {2} function "
+             "has unsupported type ({3})\n",
+             __FUNCTION__, (*arg)->getName(), getFunctionName(ci),
+             GetValueTypeStr((*arg)->getType()));
     return false;
   }
   return true;
@@ -91,7 +93,7 @@ DirectCallReplacementPass::getFunctionArgsAsValues(const llvm::CallInst *ci) {
 std::optional<lldb::addr_t>
 DirectCallReplacementPass::getFunctionAddress(const llvm::CallInst *ci) const {
   Log *log = GetLog(LLDBLog::Expressions);
-  
+
   auto *target = m_exe_ctx.GetTargetPtr();
   const auto &lldb_module_sp = target->GetExecutableModule();
   const auto &symtab = lldb_module_sp->GetSymtab();
@@ -104,17 +106,21 @@ DirectCallReplacementPass::getFunctionAddress(const llvm::CallInst *ci) const {
       ConstString(name), lldb::SymbolType::eSymbolTypeCode,
       Symtab::Debug::eDebugNo, Symtab::Visibility::eVisibilityExtern);
   if (!symbol) {
-    LLDB_LOG(log, "DirectCallReplacementPass::{0}() can't find {1} in symtab\n", __FUNCTION__, name);
+    LLDB_LOG(log, "DirectCallReplacementPass::{0}() can't find {1} in symtab\n",
+             __FUNCTION__, name);
     return std::nullopt;
   }
 
   lldb::addr_t addr = symbol->GetLoadAddress(target);
-  LLDB_LOG(log, "DirectCallReplacementPass::{0}() found address ({1:x}) of symbol {2}\n", __FUNCTION__, addr,
-             name);
+  LLDB_LOG(
+      log,
+      "DirectCallReplacementPass::{0}() found address ({1:x}) of symbol {2}\n",
+      __FUNCTION__, addr, name);
   return addr;
 }
 
-llvm::CallInst *DirectCallReplacementPass::getInstReplace(llvm::CallInst *ci) const {
+llvm::CallInst *
+DirectCallReplacementPass::getInstReplace(llvm::CallInst *ci) const {
   assert(ci);
 
   std::optional<lldb::addr_t> addr_or_null = getFunctionAddress(ci);
@@ -134,7 +140,8 @@ llvm::CallInst *DirectCallReplacementPass::getInstReplace(llvm::CallInst *ci) co
   return new_inst;
 }
 
-DirectCallReplacementPass::DirectCallReplacementPass(const ExecutionContext &exe_ctx)
+DirectCallReplacementPass::DirectCallReplacementPass(
+    const ExecutionContext &exe_ctx)
     : FunctionPass(ID), m_exe_ctx{exe_ctx} {}
 
 DirectCallReplacementPass::~DirectCallReplacementPass() = default;
diff --git a/lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.h b/lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.h
index d4b4a995e0..70e9eeeed5 100644
--- a/lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.h
+++ b/lldb/source/Plugins/Architecture/RISCV/DirectCallReplacementPass.h
@@ -55,7 +55,8 @@ private:
   const ExecutionContext &m_exe_ctx;
 };
 
-llvm::FunctionPass *createDirectCallReplacementPass(const ExecutionContext &exe_ctx);
+llvm::FunctionPass *
+createDirectCallReplacementPass(const ExecutionContext &exe_ctx);
 } // namespace lldb_private
 
 #endif // LLDB_SOURCE_PLUGINS_ARCHITECTURE_RISCV_DIRECTCALLREPLACEMENTPASS_H

``````````

</details>


https://github.com/llvm/llvm-project/pull/99336


More information about the lldb-commits mailing list