summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-07-12 22:51:12 +0000
committerGreg Clayton <gclayton@apple.com>2012-07-12 22:51:12 +0000
commit1d60909e813a4dcadfed40730788ecb3cd5eb076 (patch)
tree0647d2094d52addc06b5925d3bb67fc3f8ae5b8a /lldb/source/Core
parent5f111b2721f0cada05adddb85568b21ccc13a7be (diff)
downloadbcm5719-llvm-1d60909e813a4dcadfed40730788ecb3cd5eb076.tar.gz
bcm5719-llvm-1d60909e813a4dcadfed40730788ecb3cd5eb076.zip
<rdar://problem/11740973>
Fixed issues that could happen when the UUID doesn't change in a binary and old stale debug info could end up being used. llvm-svn: 160145
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/Module.cpp76
-rw-r--r--lldb/source/Core/ModuleList.cpp29
2 files changed, 48 insertions, 57 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index ee01dfe3f30..b3fac25a7c4 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -134,7 +134,8 @@ Module::Module (const ModuleSpec &module_spec) :
m_did_parse_uuid (false),
m_did_init_ast (false),
m_is_dynamic_loader_module (false),
- m_was_modified (false)
+ m_file_has_changed (false),
+ m_first_file_changed_log (false)
{
// Scope for locker below...
{
@@ -176,7 +177,8 @@ Module::Module(const FileSpec& file_spec,
m_did_parse_uuid (false),
m_did_init_ast (false),
m_is_dynamic_loader_module (false),
- m_was_modified (false)
+ m_file_has_changed (false),
+ m_first_file_changed_log (false)
{
// Scope for locker below...
{
@@ -803,32 +805,44 @@ Module::ReportError (const char *format, ...)
}
}
+bool
+Module::FileHasChanged () const
+{
+ if (m_file_has_changed == false)
+ m_file_has_changed = (m_file.GetModificationTime() != m_mod_time);
+ return m_file_has_changed;
+}
+
void
Module::ReportErrorIfModifyDetected (const char *format, ...)
{
- if (!GetModified(true) && GetModified(false))
+ if (m_first_file_changed_log == false)
{
- if (format)
+ if (FileHasChanged ())
{
- StreamString strm;
- strm.PutCString("error: the object file ");
- GetDescription(&strm, lldb::eDescriptionLevelFull);
- strm.PutCString (" has been modified\n");
-
- va_list args;
- va_start (args, format);
- strm.PrintfVarArg(format, args);
- va_end (args);
-
- const int format_len = strlen(format);
- if (format_len > 0)
+ m_first_file_changed_log = true;
+ if (format)
{
- const char last_char = format[format_len-1];
- if (last_char != '\n' || last_char != '\r')
- strm.EOL();
+ StreamString strm;
+ strm.PutCString("error: the object file ");
+ GetDescription(&strm, lldb::eDescriptionLevelFull);
+ strm.PutCString (" has been modified\n");
+
+ va_list args;
+ va_start (args, format);
+ strm.PrintfVarArg(format, args);
+ va_end (args);
+
+ const int format_len = strlen(format);
+ if (format_len > 0)
+ {
+ const char last_char = format[format_len-1];
+ if (last_char != '\n' || last_char != '\r')
+ strm.EOL();
+ }
+ strm.PutCString("The debug session should be aborted as the original debug information has been overwritten.\n");
+ Host::SystemLog (Host::eSystemLogError, "%s", strm.GetString().c_str());
}
- strm.PutCString("The debug session should be aborted as the original debug information has been overwritten.\n");
- Host::SystemLog (Host::eSystemLogError, "%s", strm.GetString().c_str());
}
}
}
@@ -893,26 +907,6 @@ Module::LogMessageVerboseBacktrace (Log *log, const char *format, ...)
}
}
-bool
-Module::GetModified (bool use_cached_only)
-{
- if (m_was_modified == false && use_cached_only == false)
- {
- TimeValue curr_mod_time (m_file.GetModificationTime());
- m_was_modified = curr_mod_time != m_mod_time;
- }
- return m_was_modified;
-}
-
-bool
-Module::SetModified (bool b)
-{
- const bool prev_value = m_was_modified;
- m_was_modified = b;
- return prev_value;
-}
-
-
void
Module::Dump(Stream *s)
{
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index d6f29a6b49e..5507428c53e 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -710,24 +710,21 @@ ModuleList::GetSharedModule
for (uint32_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
{
module_sp = matching_module_list.GetModuleAtIndex(module_idx);
- // If we had a UUID and we found a match, then that is good enough for a match
- if (uuid_ptr)
- break;
- if (module_file_spec)
+
+ // Make sure the file for the module hasn't been modified
+ if (module_sp->FileHasChanged())
{
- // If we didn't have a UUID in mind when looking for the object file,
- // then we should make sure the modification time hasn't changed!
- TimeValue file_spec_mod_time(module_file_spec.GetModificationTime());
- if (file_spec_mod_time.IsValid())
- {
- if (file_spec_mod_time == module_sp->GetModificationTime())
- return error;
- }
+ if (old_module_sp_ptr && !old_module_sp_ptr->get())
+ *old_module_sp_ptr = module_sp;
+ shared_module_list.Remove (module_sp);
+ module_sp.reset();
+ }
+ else
+ {
+ // The module matches and the module was not modified from
+ // when it was last loaded.
+ return error;
}
- if (old_module_sp_ptr && !old_module_sp_ptr->get())
- *old_module_sp_ptr = module_sp;
- shared_module_list.Remove (module_sp);
- module_sp.reset();
}
}
}
OpenPOWER on IntegriCloud