[Lldb-commits] [PATCH] Fix Module::GetSymbolFileFileSpec and simplify CommandObjectTargetModulesList::PrintModule

Ilia K ki.stfu at gmail.com
Mon Mar 2 06:27:04 PST 2015


Hi abidh, clayborg,

The Module::GetSymbolVendor mistakenly doesn't update m_symfile_spec when a new SymbolVendor is created. It causes that Module::GetSymbolFileFileSpec returns an invalid FileSpec data.

This patch fixes that error and, in addition, simplifies CommandObjectTargetModulesList::PrintModule method.

All tests pass on OS X.

http://reviews.llvm.org/D8002

Files:
  source/Commands/CommandObjectTarget.cpp
  source/Core/Module.cpp

Index: source/Commands/CommandObjectTarget.cpp
===================================================================
--- source/Commands/CommandObjectTarget.cpp
+++ source/Commands/CommandObjectTarget.cpp
@@ -3469,25 +3469,21 @@
                         SymbolVendor *symbol_vendor = module->GetSymbolVendor();
                         if (symbol_vendor)
                         {
-                            SymbolFile *symbol_file = symbol_vendor->GetSymbolFile();
-                            if (symbol_file)
+                            const FileSpec &symfile_spec = module->GetSymbolFileFileSpec();
+                            if (format_char == 'S')
                             {
-                                if (format_char == 'S')
+                                // Dump symbol file only if different from module file
+                                if (!symfile_spec || symfile_spec == module->GetFileSpec())
                                 {
-                                    FileSpec &symfile_spec = symbol_file->GetObjectFile()->GetFileSpec();
-                                    // Dump symbol file only if different from module file
-                                    if (!symfile_spec || symfile_spec == module->GetFileSpec())
-                                    {
-                                        print_space = false;
-                                        break;
-                                    }
-                                    // Add a newline and indent past the index
-                                    strm.Printf ("\n%*s", indent, "");
+                                    print_space = false;
+                                    break;
                                 }
-                                DumpFullpath (strm, &symbol_file->GetObjectFile()->GetFileSpec(), width);
-                                dump_object_name = true;
-                                break;
+                                // Add a newline and indent past the index
+                                strm.Printf ("\n%*s", indent, "");
                             }
+                            DumpFullpath (strm, &symfile_spec, width);
+                            dump_object_name = true;
+                            break;
                         }
                         strm.Printf("%.*s", width, "<NONE>");
                     }
Index: source/Core/Module.cpp
===================================================================
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -1047,6 +1047,17 @@
             Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
             m_symfile_ap.reset(SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
             m_did_load_symbol_vendor = true;
+            // Update symbol file specification.
+            if (m_symfile_ap)
+            {
+                SymbolFile *symbol_file = m_symfile_ap->GetSymbolFile();
+                if (symbol_file)
+                {
+                    ObjectFile *obj_file = symbol_file->GetObjectFile();
+                    if (obj_file)
+                        m_symfile_spec = obj_file->GetFileSpec();
+                }
+            }
         }
     }
     return m_symfile_ap.get();

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8002.21002.patch
Type: text/x-patch
Size: 3264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150302/968d7a01/attachment.bin>


More information about the lldb-commits mailing list