[Lldb-commits] [lldb] r244436 - Feedback from Jim: Change the "optimized code" warning to be entirely
Jason Molenda via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 10 00:55:25 PDT 2015
Author: jmolenda
Date: Mon Aug 10 02:55:25 2015
New Revision: 244436
URL: http://llvm.org/viewvc/llvm-project?rev=244436&view=rev
Log:
Feedback from Jim: Change the "optimized code" warning to be entirely
contained within Process so that we won't be duplicating the warning
message if other parts of the code want to issue the message. Change
Process::PrintWarning to be a protected method - the public method
will be the PrintWarningOptimization et al. Also, Have
Thread::FunctionOptimizationWarning shortcut out if the warnings
have been disabled so that we don't (potentially) compute parts of
the SymbolContext unnecessarily.
Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Thread.cpp
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=244436&r1=244435&r2=244436&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Mon Aug 10 02:55:25 2015
@@ -1952,31 +1952,18 @@ public:
}
//------------------------------------------------------------------
- /// Print a user-visible warning one time per Process
- ///
- /// A facility for printing a warning to the user once per repeat_key.
+ /// Print a user-visible warning about a module being built with optimization
///
- /// warning_type is from the Process::Warnings enums.
- /// repeat_key is a pointer value that will be used to ensure that the
- /// warning message is not printed multiple times. For instance, with a
- /// warning about a function being optimized, you can pass the CompileUnit
- /// pointer to have the warning issued for only the first function in a
- /// CU, or the Function pointer to have it issued once for every function,
- /// or a Module pointer to have it issued once per Module.
- ///
- /// @param [in] warning_type
- /// One of the types defined in Process::Warnings.
- ///
- /// @param [in] repeat_key
- /// A pointer value used to ensure that the warning is only printed once.
- /// May be nullptr, indicating that the warning is printed unconditionally
- /// every time.
- ///
- /// @param [in] fmt
- /// printf style format string
+ /// Prints a async warning message to the user one time per Module
+ /// where a function is found that was compiled with optimization, per
+ /// Process.
+ ///
+ /// @param [in] sc
+ /// A SymbolContext with eSymbolContextFunction and eSymbolContextModule
+ /// pre-computed.
//------------------------------------------------------------------
void
- PrintWarning (uint64_t warning_type, void *repeat_key, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
+ PrintWarningOptimization (const SymbolContext &sc);
protected:
@@ -2001,6 +1988,37 @@ protected:
//------------------------------------------------------------------
void
CompleteAttach ();
+
+ //------------------------------------------------------------------
+ /// Print a user-visible warning one time per Process
+ ///
+ /// A facility for printing a warning to the user once per repeat_key.
+ ///
+ /// warning_type is from the Process::Warnings enums.
+ /// repeat_key is a pointer value that will be used to ensure that the
+ /// warning message is not printed multiple times. For instance, with a
+ /// warning about a function being optimized, you can pass the CompileUnit
+ /// pointer to have the warning issued for only the first function in a
+ /// CU, or the Function pointer to have it issued once for every function,
+ /// or a Module pointer to have it issued once per Module.
+ ///
+ /// Classes outside Process should call a specific PrintWarning method
+ /// so that the warning strings are all centralized in Process, instead of
+ /// calling PrintWarning() directly.
+ ///
+ /// @param [in] warning_type
+ /// One of the types defined in Process::Warnings.
+ ///
+ /// @param [in] repeat_key
+ /// A pointer value used to ensure that the warning is only printed once.
+ /// May be nullptr, indicating that the warning is printed unconditionally
+ /// every time.
+ ///
+ /// @param [in] fmt
+ /// printf style format string
+ //------------------------------------------------------------------
+ void
+ PrintWarning (uint64_t warning_type, void *repeat_key, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
public:
//------------------------------------------------------------------
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=244436&r1=244435&r2=244436&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Mon Aug 10 02:55:25 2015
@@ -28,6 +28,7 @@
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
@@ -6596,6 +6597,19 @@ Process::PrintWarning (uint64_t warning_
}
}
+void
+Process::PrintWarningOptimization (const SymbolContext &sc)
+{
+ if (GetWarningsOptimization() == true
+ && sc.module_sp.get()
+ && sc.module_sp->GetFileSpec().GetFilename().IsEmpty() == false
+ && sc.function
+ && sc.function->GetIsOptimized() == true)
+ {
+ PrintWarning (Process::Warnings::eWarningsOptimization, sc.module_sp.get(), "%s was compiled with optimization - stepping may behave oddly; variables may not be available.\n", sc.module_sp->GetFileSpec().GetFilename().GetCString());
+ }
+}
+
ThreadCollectionSP
Process::GetHistoryThreads(lldb::addr_t addr)
{
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=244436&r1=244435&r2=244436&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Mon Aug 10 02:55:25 2015
@@ -427,16 +427,10 @@ Thread::SetSelectedFrameByIndexNoisily (
void
Thread::FunctionOptimizationWarning (StackFrame *frame)
{
- if (frame && frame->HasDebugInformation())
+ if (frame && frame->HasDebugInformation() && GetProcess()->GetWarningsOptimization() == true)
{
SymbolContext sc = frame->GetSymbolContext (eSymbolContextFunction | eSymbolContextModule);
- if (sc.function && sc.function->GetIsOptimized() == true && sc.module_sp.get())
- {
- if (sc.module_sp->GetFileSpec().GetFilename().IsEmpty() == false)
- {
- GetProcess()->PrintWarning (Process::Warnings::eWarningsOptimization, sc.module_sp.get(), "%s was compiled with optimization - stepping may behave oddly; variables may not be available.\n", sc.module_sp->GetFileSpec().GetFilename().GetCString());
- }
- }
+ GetProcess()->PrintWarningOptimization (sc);
}
}
More information about the lldb-commits
mailing list