Exit early from DumpELFProgramHeaders if parse fails
authorEd Maste <emaste@freebsd.org>
Mon, 23 Feb 2015 15:33:11 +0000 (15:33 +0000)
committerEd Maste <emaste@freebsd.org>
Mon, 23 Feb 2015 15:33:11 +0000 (15:33 +0000)
This matches the way DumpELFSectionHeaders is implemented and is
recommended by the LLVM coding conventions.

llvm-svn: 230228

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

index e7bf20e..bf466c7 100644 (file)
@@ -2631,22 +2631,22 @@ ObjectFileELF::DumpELFProgramHeader_p_flags(Stream *s, elf_word p_flags)
 void
 ObjectFileELF::DumpELFProgramHeaders(Stream *s)
 {
-    if (ParseProgramHeaders())
+    if (!ParseProgramHeaders())
+        return;
+
+    s->PutCString("Program Headers\n");
+    s->PutCString("IDX  p_type          p_offset p_vaddr  p_paddr  "
+                  "p_filesz p_memsz  p_flags                   p_align\n");
+    s->PutCString("==== --------------- -------- -------- -------- "
+                  "-------- -------- ------------------------- --------\n");
+
+    uint32_t idx = 0;
+    for (ProgramHeaderCollConstIter I = m_program_headers.begin();
+         I != m_program_headers.end(); ++I, ++idx)
     {
-        s->PutCString("Program Headers\n");
-        s->PutCString("IDX  p_type          p_offset p_vaddr  p_paddr  "
-                      "p_filesz p_memsz  p_flags                   p_align\n");
-        s->PutCString("==== --------------- -------- -------- -------- "
-                      "-------- -------- ------------------------- --------\n");
-
-        uint32_t idx = 0;
-        for (ProgramHeaderCollConstIter I = m_program_headers.begin();
-             I != m_program_headers.end(); ++I, ++idx)
-        {
-            s->Printf("[%2u] ", idx);
-            ObjectFileELF::DumpELFProgramHeader(s, *I);
-            s->EOL();
-        }
+        s->Printf("[%2u] ", idx);
+        ObjectFileELF::DumpELFProgramHeader(s, *I);
+        s->EOL();
     }
 }