[Lldb-commits] [lldb] [lldb] Suppress unsupported language warning for assembly (PR #95871)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 17 16:54:22 PDT 2024


https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/95871

The following warning is technically correct, but pretty much useless, since there aren't any frame variables that we'd expect the debugger to understand.

  This version of LLDB has no plugin for the language "assembler".
  Inspection of frame variables will be limited.

This message is useful in the general case but should be suppressed for the "assembler" case.

rdar://92745462

>From 0a43839e81e85d171155ae1e46661c5d6a65bec1 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Mon, 17 Jun 2024 16:52:24 -0700
Subject: [PATCH] [lldb] Suppress unsupported language warning for assembly

The following warning is technically correct, but pretty much useless,
since there aren't any frame variables that we'd expect the debugger to
understand.

  This version of LLDB has no plugin for the language "assembler".
  Inspection of frame variables will be limited.

This message is useful in the general case but should be suppressed for
the "assembler" case.

rdar://92745462
---
 lldb/source/Target/Process.cpp                | 101 +++++++++---------
 .../Shell/Process/UnsupportedLanguage.test    |  15 ++-
 2 files changed, 62 insertions(+), 54 deletions(-)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 1e321f8bde391..6a7a084d702bc 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -407,8 +407,8 @@ ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,
     create_callback =
         PluginManager::GetProcessCreateCallbackForPluginName(plugin_name);
     if (create_callback) {
-      process_sp = create_callback(target_sp, listener_sp, crash_file_path,
-                                   can_connect);
+      process_sp =
+          create_callback(target_sp, listener_sp, crash_file_path, can_connect);
       if (process_sp) {
         if (process_sp->CanDebug(target_sp, true)) {
           process_sp->m_process_unique_id = ++g_process_unique_id;
@@ -421,8 +421,8 @@ ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,
          (create_callback =
               PluginManager::GetProcessCreateCallbackAtIndex(idx)) != nullptr;
          ++idx) {
-      process_sp = create_callback(target_sp, listener_sp, crash_file_path,
-                                   can_connect);
+      process_sp =
+          create_callback(target_sp, listener_sp, crash_file_path, can_connect);
       if (process_sp) {
         if (process_sp->CanDebug(target_sp, false)) {
           process_sp->m_process_unique_id = ++g_process_unique_id;
@@ -541,8 +541,7 @@ Process::~Process() {
 ProcessProperties &Process::GetGlobalProperties() {
   // NOTE: intentional leak so we don't crash if global destructor chain gets
   // called as other threads still use the result of this function
-  static ProcessProperties *g_settings_ptr =
-      new ProcessProperties(nullptr);
+  static ProcessProperties *g_settings_ptr = new ProcessProperties(nullptr);
   return *g_settings_ptr;
 }
 
@@ -647,7 +646,7 @@ StateType Process::GetNextEvent(EventSP &event_sp) {
   StateType state = eStateInvalid;
 
   if (GetPrimaryListener()->GetEventForBroadcaster(this, event_sp,
-                                            std::chrono::seconds(0)) &&
+                                                   std::chrono::seconds(0)) &&
       event_sp)
     state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
 
@@ -745,8 +744,7 @@ StateType Process::WaitForProcessToStop(
 
 bool Process::HandleProcessStateChangedEvent(
     const EventSP &event_sp, Stream *stream,
-    SelectMostRelevant select_most_relevant,
-    bool &pop_process_io_handler) {
+    SelectMostRelevant select_most_relevant, bool &pop_process_io_handler) {
   const bool handle_pop = pop_process_io_handler;
 
   pop_process_io_handler = false;
@@ -937,8 +935,7 @@ bool Process::HandleProcessStateChangedEvent(
           process_sp->GetStatus(*stream);
           process_sp->GetThreadStatus(*stream, only_threads_with_stop_reason,
                                       start_frame, num_frames,
-                                      num_frames_with_source,
-                                      stop_format);
+                                      num_frames_with_source, stop_format);
           if (curr_thread_stop_info_sp) {
             lldb::addr_t crashing_address;
             ValueObjectSP valobj_sp = StopInfo::GetCrashingDereference(
@@ -1141,7 +1138,7 @@ bool Process::SetProcessExitStatus(
     lldb::pid_t pid, bool exited,
     int signo,      // Zero for no signal
     int exit_status // Exit value of process if signal is zero
-    ) {
+) {
   Log *log = GetLog(LLDBLog::Process);
   LLDB_LOGF(log,
             "Process::SetProcessExitStatus (pid=%" PRIu64
@@ -1346,7 +1343,7 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
 
   Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
   LLDB_LOGF(log, "(plugin = %s, state = %s, restarted = %i)",
-           GetPluginName().data(), StateAsCString(new_state), restarted);
+            GetPluginName().data(), StateAsCString(new_state), restarted);
   const StateType old_state = m_public_state.GetValue();
   m_public_state.SetValue(new_state);
 
@@ -1356,15 +1353,15 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
   if (!StateChangedIsExternallyHijacked()) {
     if (new_state == eStateDetached) {
       LLDB_LOGF(log,
-               "(plugin = %s, state = %s) -- unlocking run lock for detach",
-               GetPluginName().data(), StateAsCString(new_state));
+                "(plugin = %s, state = %s) -- unlocking run lock for detach",
+                GetPluginName().data(), StateAsCString(new_state));
       m_public_run_lock.SetStopped();
     } else {
       const bool old_state_is_stopped = StateIsStoppedState(old_state, false);
       if ((old_state_is_stopped != new_state_is_stopped)) {
         if (new_state_is_stopped && !restarted) {
           LLDB_LOGF(log, "(plugin = %s, state = %s) -- unlocking run lock",
-                   GetPluginName().data(), StateAsCString(new_state));
+                    GetPluginName().data(), StateAsCString(new_state));
           m_public_run_lock.SetStopped();
         }
       }
@@ -1378,7 +1375,7 @@ Status Process::Resume() {
   if (!m_public_run_lock.TrySetRunning()) {
     Status error("Resume request failed - process still running.");
     LLDB_LOGF(log, "(plugin = %s) -- TrySetRunning failed, not resuming.",
-             GetPluginName().data());
+              GetPluginName().data());
     return error;
   }
   Status error = PrivateResume();
@@ -1458,7 +1455,7 @@ void Process::SetPrivateState(StateType new_state) {
   bool state_changed = false;
 
   LLDB_LOGF(log, "(plugin = %s, state = %s)", GetPluginName().data(),
-           StateAsCString(new_state));
+            StateAsCString(new_state));
 
   std::lock_guard<std::recursive_mutex> thread_guard(m_thread_list.GetMutex());
   std::lock_guard<std::recursive_mutex> guard(m_private_state.GetMutex());
@@ -1500,14 +1497,14 @@ void Process::SetPrivateState(StateType new_state) {
         m_mod_id.SetStopEventForLastNaturalStopID(event_sp);
       m_memory_cache.Clear();
       LLDB_LOGF(log, "(plugin = %s, state = %s, stop_id = %u",
-               GetPluginName().data(), StateAsCString(new_state),
-               m_mod_id.GetStopID());
+                GetPluginName().data(), StateAsCString(new_state),
+                m_mod_id.GetStopID());
     }
 
     m_private_state_broadcaster.BroadcastEvent(event_sp);
   } else {
     LLDB_LOGF(log, "(plugin = %s, state = %s) state didn't change. Ignoring...",
-             GetPluginName().data(), StateAsCString(new_state));
+              GetPluginName().data(), StateAsCString(new_state));
   }
 }
 
@@ -1523,7 +1520,8 @@ addr_t Process::GetImageInfoAddress() { return LLDB_INVALID_ADDRESS; }
 
 const lldb::ABISP &Process::GetABI() {
   if (!m_abi_sp)
-    m_abi_sp = ABI::FindPlugin(shared_from_this(), GetTarget().GetArchitecture());
+    m_abi_sp =
+        ABI::FindPlugin(shared_from_this(), GetTarget().GetArchitecture());
   return m_abi_sp;
 }
 
@@ -1570,7 +1568,8 @@ LanguageRuntime *Process::GetLanguageRuntime(lldb::LanguageType language) {
     // for example, CPPLanguageRuntime will support eLanguageTypeC_plus_plus,
     // eLanguageTypeC_plus_plus_03, etc. Because of this, we should get the
     // primary language type and make sure that our runtime supports it.
-    assert(runtime->GetLanguageType() == Language::GetPrimaryLanguage(language));
+    assert(runtime->GetLanguageType() ==
+           Language::GetPrimaryLanguage(language));
 
   return runtime;
 }
@@ -1961,7 +1960,7 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
 
 // Uncomment to verify memory caching works after making changes to caching
 // code
-//#define VERIFY_MEMORY_READS
+// #define VERIFY_MEMORY_READS
 
 size_t Process::ReadMemory(addr_t addr, void *buf, size_t size, Status &error) {
   if (ABISP abi_sp = GetABI())
@@ -2818,9 +2817,7 @@ ListenerSP ProcessAttachInfo::GetListenerForProcess(Debugger &debugger) {
     return debugger.GetListener();
 }
 
-Status Process::WillLaunch(Module *module) {
-  return DoWillLaunch(module);
-}
+Status Process::WillLaunch(Module *module) { return DoWillLaunch(module); }
 
 Status Process::WillAttachToProcessWithID(lldb::pid_t pid) {
   return DoWillAttachToProcessWithID(pid);
@@ -3710,8 +3707,8 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
       while (!receipt_received) {
         // Check for a receipt for n seconds and then check if the private
         // state thread is still around.
-        receipt_received =
-          event_receipt_sp->WaitForEventReceived(GetUtilityExpressionTimeout());
+        receipt_received = event_receipt_sp->WaitForEventReceived(
+            GetUtilityExpressionTimeout());
         if (!receipt_received) {
           // Check if the private state thread is still around. If it isn't
           // then we are done waiting
@@ -4758,7 +4755,8 @@ HandleStoppedEvent(lldb::tid_t thread_id, const ThreadPlanSP &thread_plan_sp,
   StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
   if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint &&
       stop_info_sp->ShouldNotify(event_sp.get())) {
-    LLDB_LOG(log, "stopped for breakpoint: {0}.", stop_info_sp->GetDescription());
+    LLDB_LOG(log, "stopped for breakpoint: {0}.",
+             stop_info_sp->GetDescription());
     if (!options.DoesIgnoreBreakpoints()) {
       // Restore the plan state and then force Private to false.  We are going
       // to stop because of this plan so we need it to become a public plan or
@@ -5010,8 +5008,8 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
     // coalescing to cause us to lose OUR running event...
     ForceNextEventDelivery();
 
-// This while loop must exit out the bottom, there's cleanup that we need to do
-// when we are done. So don't call return anywhere within it.
+    // This while loop must exit out the bottom, there's cleanup that we need to
+    // do when we are done. So don't call return anywhere within it.
 
 #ifdef LLDB_RUN_THREAD_HALT_WITH_EVENT
     // It's pretty much impossible to write test cases for things like: One
@@ -5235,12 +5233,14 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
               LLDB_LOG(log,
                        "Running function with one thread timeout timed out.");
             } else
-              LLDB_LOG(log, "Restarting function with all threads enabled and "
-                            "timeout: {0} timed out, abandoning execution.",
+              LLDB_LOG(log,
+                       "Restarting function with all threads enabled and "
+                       "timeout: {0} timed out, abandoning execution.",
                        timeout);
           } else
-            LLDB_LOG(log, "Running function with timeout: {0} timed out, "
-                          "abandoning execution.",
+            LLDB_LOG(log,
+                     "Running function with timeout: {0} timed out, "
+                     "abandoning execution.",
                      timeout);
         }
 
@@ -5663,8 +5663,7 @@ size_t Process::GetThreadStatus(Stream &strm,
           continue;
       }
       thread_sp->GetStatus(strm, start_frame, num_frames,
-                           num_frames_with_source,
-                           stop_format);
+                           num_frames_with_source, stop_format);
       ++num_thread_infos_dumped;
     } else {
       Log *log = GetLog(LLDBLog::Process);
@@ -5703,14 +5702,14 @@ bool Process::RunPreResumeActions() {
 
 void Process::ClearPreResumeActions() { m_pre_resume_actions.clear(); }
 
-void Process::ClearPreResumeAction(PreResumeActionCallback callback, void *baton)
-{
-    PreResumeCallbackAndBaton element(callback, baton);
-    auto found_iter = std::find(m_pre_resume_actions.begin(), m_pre_resume_actions.end(), element);
-    if (found_iter != m_pre_resume_actions.end())
-    {
-        m_pre_resume_actions.erase(found_iter);
-    }
+void Process::ClearPreResumeAction(PreResumeActionCallback callback,
+                                   void *baton) {
+  PreResumeCallbackAndBaton element(callback, baton);
+  auto found_iter = std::find(m_pre_resume_actions.begin(),
+                              m_pre_resume_actions.end(), element);
+  if (found_iter != m_pre_resume_actions.end()) {
+    m_pre_resume_actions.erase(found_iter);
+  }
 }
 
 ProcessRunLock &Process::GetRunLock() {
@@ -5720,12 +5719,10 @@ ProcessRunLock &Process::GetRunLock() {
     return m_public_run_lock;
 }
 
-bool Process::CurrentThreadIsPrivateStateThread()
-{
+bool Process::CurrentThreadIsPrivateStateThread() {
   return m_private_state_thread.EqualsThread(Host::GetCurrentThread());
 }
 
-
 void Process::Flush() {
   m_thread_list.Flush();
   m_extended_thread_list.Flush();
@@ -5924,7 +5921,9 @@ void Process::PrintWarningUnsupportedLanguage(const SymbolContext &sc) {
   if (!sc.module_sp)
     return;
   LanguageType language = sc.GetLanguage();
-  if (language == eLanguageTypeUnknown)
+  if (language == eLanguageTypeUnknown ||
+      language == lldb::eLanguageTypeAssembly ||
+      language == lldb::eLanguageTypeMipsAssembler)
     return;
   LanguageSet plugins =
       PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
@@ -6429,7 +6428,7 @@ static void GetCoreFileSaveRangesFull(Process &process,
                                       std::set<addr_t> &stack_ends) {
 
   // Don't add only dirty pages, add full regions.
-const bool try_dirty_pages = false;
+  const bool try_dirty_pages = false;
   for (const auto &region : regions)
     if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0)
       AddRegion(region, try_dirty_pages, ranges);
diff --git a/lldb/test/Shell/Process/UnsupportedLanguage.test b/lldb/test/Shell/Process/UnsupportedLanguage.test
index 8cf0c048e366b..6490505033483 100644
--- a/lldb/test/Shell/Process/UnsupportedLanguage.test
+++ b/lldb/test/Shell/Process/UnsupportedLanguage.test
@@ -1,8 +1,17 @@
-Test warnings.
+Test unsupported language warning
+
 REQUIRES: shell
+
 RUN: %clang_host %S/Inputs/true.c -std=c99 -g -c -S -emit-llvm -o - \
 RUN:   | sed -e 's/DW_LANG_C99/DW_LANG_Mips_Assembler/g' >%t.ll
 RUN: %clang_host %t.ll -g -o %t.exe
-RUN: %lldb -o "b main" -o r -o q -b %t.exe 2>&1 | FileCheck %s
+RUN: %lldb -o "b main" -o r -o q -b %t.exe 2>&1 | FileCheck %s --check-prefix ASM
+
+ASM-NOT: This version of LLDB has no plugin for the language "assembler"
+
+RUN: %clang_host %S/Inputs/true.c -std=c99 -g -c -S -emit-llvm -o - \
+RUN:   | sed -e 's/DW_LANG_C99/DW_LANG_Cobol74/g' >%t.ll
+RUN: %clang_host %t.ll -g -o %t.exe
+RUN: %lldb -o "b main" -o r -o q -b %t.exe 2>&1 | FileCheck %s --check-prefix COBOL
 
-CHECK: This version of LLDB has no plugin for the language "assembler"
+COBOL-NOT: This version of LLDB has no plugin for the language "cobol"



More information about the lldb-commits mailing list