diff options
author | Jason Molenda <jmolenda@apple.com> | 2015-08-06 03:27:10 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2015-08-06 03:27:10 +0000 |
commit | ef7d641617c523c2690f4bf97c5c6139ec5b5b75 (patch) | |
tree | affb99c2bae8f93fc7ecfc477175dc7d5387a270 /lldb/source/Target/Process.cpp | |
parent | 50fee93926c36346caee34f4e67f837d5562dcc7 (diff) | |
download | bcm5719-llvm-ef7d641617c523c2690f4bf97c5c6139ec5b5b75.tar.gz bcm5719-llvm-ef7d641617c523c2690f4bf97c5c6139ec5b5b75.zip |
Second part of indicating when the user is stopped in optimized code.
The first part was in r243508 -- the extent of the UI changes in that
patchset was to add "[opt]" to the frame-format when a stack frame was
built with optimized code.
In this change, when a stack frame built with optimization is selected,
a message will be printed to the async output channel --
opt1.c was compiled with optimization - stepping may behave oddly; variables may not be available.
The warning will be only be printed once per source file in a debug session.
These warnings may be disabled by
settings set target.process.optimization-warnings false
Internally, a new Process::PrintWarning() method has been added for
warnings that we want to print only once to the user. It takes a type
of warning (currently only eWarningsOptimization) and an object
pointer (CompileUnit*) - the warning will only be printed once for a
given object pointer value.
This is a bit of a prototype of this change - I think we will be
tweaking it more in the future. But I wanted to land this and see
how it goes. Advanced users will find these warnings unnecessary
noise and will quickly disable them - but anyone who maintains a
debugger knows that debugging optimized code, without realizing it,
is a constant source of confusion and frustation for more typical
debugger users.
I imagine there will be more of these "warn once per whatever" style
warnings that we will want to add in the future and we'll need to
come up with a better way for enabling/disabling them. But I'm not
srue what form that warning settings should take and I didn't want
to code up something that we regret later, so for now I just added
another process setting for this one warning.
<rdar://problem/19281172>
llvm-svn: 244190
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 9594a8ae434..adc393fae67 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -115,6 +115,7 @@ g_properties[] = { "stop-on-sharedlibrary-events" , OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, stop when a shared library is loaded or unloaded." }, { "detach-keeps-stopped" , OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, detach will attempt to keep the process stopped." }, { "memory-cache-line-size" , OptionValue::eTypeUInt64, false, 512, NULL, NULL, "The memory cache line size" }, + { "optimization-warnings" , OptionValue::eTypeBoolean, false, true, NULL, NULL, "If true, warn when stopped in code that is optimized where stepping and variable availability may not behave as expected." }, { NULL , OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL } }; @@ -126,7 +127,8 @@ enum { ePropertyPythonOSPluginPath, ePropertyStopOnSharedLibraryEvents, ePropertyDetachKeepsStopped, - ePropertyMemCacheLineSize + ePropertyMemCacheLineSize, + ePropertyWarningOptimization }; ProcessProperties::ProcessProperties (lldb_private::Process *process) : @@ -263,6 +265,13 @@ ProcessProperties::SetDetachKeepsStopped (bool stop) m_collection_sp->SetPropertyAtIndexAsBoolean(NULL, idx, stop); } +bool +ProcessProperties::GetWarningsOptimization () const +{ + const uint32_t idx = ePropertyWarningOptimization; + return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0); +} + void ProcessInstanceInfo::Dump (Stream &s, Platform *platform) const { @@ -755,6 +764,7 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s m_last_broadcast_state (eStateInvalid), m_destroy_in_process (false), m_can_interpret_function_calls(false), + m_warnings_issued (), m_can_jit(eCanJITDontKnow) { CheckInWithManager (); @@ -6542,6 +6552,50 @@ Process::ModulesDidLoad (ModuleList &module_list) } } +void +Process::PrintWarning (uint64_t warning_type, void *repeat_key, const char *fmt, ...) +{ + bool print_warning = true; + + StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream(); + if (stream_sp.get() == nullptr) + return; + if (warning_type == eWarningsOptimization + && GetWarningsOptimization() == false) + { + return; + } + + if (repeat_key != nullptr) + { + WarningsCollection::iterator it = m_warnings_issued.find (warning_type); + if (it == m_warnings_issued.end()) + { + m_warnings_issued[warning_type] = WarningsPointerSet(); + m_warnings_issued[warning_type].insert (repeat_key); + } + else + { + if (it->second.find (repeat_key) != it->second.end()) + { + print_warning = false; + } + else + { + it->second.insert (repeat_key); + } + } + } + + if (print_warning) + { + va_list args; + va_start (args, fmt); + stream_sp->PrintfVarArg (fmt, args); + va_end (args); + } +} + ThreadCollectionSP Process::GetHistoryThreads(lldb::addr_t addr) { |