[Lldb-commits] [lldb] r259237 - Fixed a couple of places where we were getting the module from a

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 29 12:21:34 PST 2016


Author: jingham
Date: Fri Jan 29 14:21:33 2016
New Revision: 259237

URL: http://llvm.org/viewvc/llvm-project?rev=259237&view=rev
Log:
Fixed a couple of places where we were getting the module from a
section and using it w/o checking that it was valid.  This can
cause crashes - usually when tearing down a target.

Modified:
    lldb/trunk/source/Core/Address.cpp
    lldb/trunk/source/Target/SectionLoadList.cpp

Modified: lldb/trunk/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=259237&r1=259236&r2=259237&view=diff
==============================================================================
--- lldb/trunk/source/Core/Address.cpp (original)
+++ lldb/trunk/source/Core/Address.cpp Fri Jan 29 14:21:33 2016
@@ -442,7 +442,11 @@ Address::Dump (Stream *s, ExecutionConte
     case DumpStyleModuleWithFileAddress:
         if (section_sp)
         {
-            s->Printf("%s[", section_sp->GetModule()->GetFileSpec().GetFilename().AsCString("<Unknown>"));
+            ModuleSP module_sp = section_sp->GetModule();
+            if (module_sp)
+                s->Printf("%s[", module_sp->GetFileSpec().GetFilename().AsCString("<Unknown>"));
+            else
+                s->Printf("%s[","<Unknown>");
         }
         // Fall through
     case DumpStyleFileAddress:

Modified: lldb/trunk/source/Target/SectionLoadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SectionLoadList.cpp?rev=259237&r1=259236&r2=259237&view=diff
==============================================================================
--- lldb/trunk/source/Target/SectionLoadList.cpp (original)
+++ lldb/trunk/source/Target/SectionLoadList.cpp Fri Jan 29 14:21:33 2016
@@ -172,10 +172,16 @@ SectionLoadList::SetSectionUnloaded (con
 
         if (log)
         {
-            const FileSpec &module_file_spec (section_sp->GetModule()->GetFileSpec());
+            ModuleSP module_sp = section_sp->GetModule();
+            std::string module_name("<Unknown>");
+            if (module_sp)
+            {
+                const FileSpec &module_file_spec (section_sp->GetModule()->GetFileSpec());
+                module_name = module_file_spec.GetPath();
+            }
             log->Printf ("SectionLoadList::%s (section = %p (%s.%s))",
                          __FUNCTION__, static_cast<void*>(section_sp.get()),
-                         module_file_spec.GetPath().c_str(),
+                         module_name.c_str(),
                          section_sp->GetName().AsCString());
         }
 
@@ -203,10 +209,16 @@ SectionLoadList::SetSectionUnloaded (con
 
     if (log)
     {
-        const FileSpec &module_file_spec (section_sp->GetModule()->GetFileSpec());
+        ModuleSP module_sp = section_sp->GetModule();
+        std::string module_name("<Unknown>");
+        if (module_sp)
+        {
+            const FileSpec &module_file_spec (section_sp->GetModule()->GetFileSpec());
+            module_name = module_file_spec.GetPath();
+        }
         log->Printf ("SectionLoadList::%s (section = %p (%s.%s), load_addr = 0x%16.16" PRIx64 ")",
                      __FUNCTION__, static_cast<void*>(section_sp.get()),
-                     module_file_spec.GetPath().c_str(),
+                     module_name.c_str(),
                      section_sp->GetName().AsCString(), load_addr);
     }
     bool erased = false;




More information about the lldb-commits mailing list