[Lldb-commits] [lldb] r160145 - in /lldb/trunk: include/lldb/Core/Module.h source/Core/Module.cpp source/Core/ModuleList.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
Greg Clayton
gclayton at apple.com
Thu Jul 12 15:51:12 PDT 2012
Author: gclayton
Date: Thu Jul 12 17:51:12 2012
New Revision: 160145
URL: http://llvm.org/viewvc/llvm-project?rev=160145&view=rev
Log:
<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.
Modified:
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Core/ModuleList.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=160145&r1=160144&r2=160145&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Thu Jul 12 17:51:12 2012
@@ -1030,11 +1030,13 @@
void
ReportErrorIfModifyDetected (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+ //------------------------------------------------------------------
+ // Return true if the file backing this module has changed since the
+ // module was originally created since we saved the intial file
+ // modification time when the module first gets created.
+ //------------------------------------------------------------------
bool
- GetModified (bool use_cached_only);
-
- bool
- SetModified (bool b);
+ FileHasChanged () const;
//------------------------------------------------------------------
// SymbolVendor, SymbolFile and ObjectFile member objects should
@@ -1124,8 +1126,9 @@
m_did_load_symbol_vendor:1,
m_did_parse_uuid:1,
m_did_init_ast:1,
- m_is_dynamic_loader_module:1,
- m_was_modified:1; /// See if the module was modified after it was initially opened.
+ m_is_dynamic_loader_module:1;
+ mutable bool m_file_has_changed:1,
+ m_first_file_changed_log:1; /// See if the module was modified after it was initially opened.
//------------------------------------------------------------------
/// Resolve a file or load virtual address.
Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=160145&r1=160144&r2=160145&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Thu Jul 12 17:51:12 2012
@@ -134,7 +134,8 @@
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 @@
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 @@
}
}
+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 @@
}
}
-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)
{
Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=160145&r1=160144&r2=160145&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Thu Jul 12 17:51:12 2012
@@ -710,24 +710,21 @@
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)
- {
- // 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;
- }
+
+ // Make sure the file for the module hasn't been modified
+ if (module_sp->FileHasChanged())
+ {
+ 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();
}
}
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=160145&r1=160144&r2=160145&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Thu Jul 12 17:51:12 2012
@@ -2127,8 +2127,6 @@
if (abbrev_decl->Code() == abbrev_code)
return abbrev_decl;
- // Only log if we are the one to figure out that the module was modified
- // which is indicated by SetModified() returning false.
dwarf2Data->GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("0x%8.8x: the DWARF debug information has been modified (abbrev code was %u, and is now %u)",
GetOffset(),
(uint32_t)abbrev_decl->Code(),
More information about the lldb-commits
mailing list