Exit early from DumpELFProgramHeaders if parse fails

This matches the way DumpELFSectionHeaders is implemented and is
recommended by the LLVM coding conventions.

llvm-svn: 230228
This commit is contained in:
Ed Maste 2015-02-23 15:33:11 +00:00
parent aec140380f
commit 3a8ab6ee2a
1 changed files with 15 additions and 15 deletions

View File

@ -2631,22 +2631,22 @@ ObjectFileELF::DumpELFProgramHeader_p_flags(Stream *s, elf_word p_flags)
void
ObjectFileELF::DumpELFProgramHeaders(Stream *s)
{
if (ParseProgramHeaders())
{
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");
if (!ParseProgramHeaders())
return;
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->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();
}
}