[Lldb-commits] [lldb] r186516 - Re-introduces ELF core file support for Linux x86-64

Samuel Jacob samueldotj at gmail.com
Thu Jul 18 11:26:16 PDT 2013


Looks good to me.
Please attach patch, so that I can test on my Linux cores.


On Thu, Jul 18, 2013 at 5:24 AM, Ed Maste <emaste at freebsd.org> wrote:

> feynman% readelf -n tdcnt.core
>
> Notes at offset 0x00000318 with length 0x00000d5c:
>   Owner         Data size       Description
>   FreeBSD               0x00000078      NT_PRPSINFO (prpsinfo structure)
>   FreeBSD               0x000000e0      NT_PRSTATUS (prstatus structure)
>   FreeBSD               0x00000200      NT_FPREGSET (floating point
> registers)
>   FreeBSD               0x00000018      NT_THRMISC (thrmisc structure)
>   FreeBSD               0x000000e0      NT_PRSTATUS (prstatus structure)
>   FreeBSD               0x00000200      NT_FPREGSET (floating point
> registers)
>   FreeBSD               0x00000018      NT_THRMISC (thrmisc structure)
>
> The current logic for case (b) finds the type for the first instance
> of NT_PRPSINFO or NT_PRSTATUS, and considers each subsequent note of
> the same type to be the start of a new thread.  This of course doesn't
> work for FreeBSD, because there is no second NT_PRPSINFO.
>
> What do you think about this approach instead:
>
> diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.cpp
> b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
> index 5ff3aaa..d24283a 100644
> --- a/source/Plugins/Process/elf-core/ProcessElfCore.cpp
> +++ b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
> @@ -436,27 +436,27 @@
> ProcessElfCore::ParseThreadContextsFromNoteSegment(const
> elf::ELFProgramHeader *
>      assert(segment_header && segment_header->p_type ==
> llvm::ELF::PT_NOTE);
>
>      lldb::offset_t offset = 0;
> -    ThreadData *thread_data = NULL;
> +    ThreadData *thread_data = new ThreadData();
> +    bool have_prstatus = false;
> +    bool have_prpsinfo = false;
>
>      // Loop through the NOTE entires in the segment
>      while (offset < segment_header->p_filesz)
>      {
> -        static unsigned lead_n_type = -1;
>          ELFNote note = ELFNote();
>          note.Parse(segment_data, &offset);
>
> -        if ((lead_n_type == (unsigned)-1) &&
> -           ((note.n_type == NT_PRSTATUS) || (note.n_type == NT_PRPSINFO)))
> -            lead_n_type = note.n_type;
> -
>          // Begining of new thread
> -        if (note.n_type == lead_n_type)
> +        if ((note.n_type == NT_PRSTATUS && have_prstatus) ||
> +            (note.n_type == NT_PRPSINFO && have_prpsinfo))
>          {
>              if (thread_data)
>              {
>                  assert(thread_data->prstatus.GetByteSize() > 0);
>                  // Add the new thread to thread list
>                  m_thread_data.push_back(*thread_data);
> +                have_prstatus = false;
> +                have_prpsinfo = false;
>              }
>              thread_data = new ThreadData();
>          }
> @@ -470,12 +470,14 @@
> ProcessElfCore::ParseThreadContextsFromNoteSegment(const
> elf::ELFProgramHeader *
>          switch (note.n_type)
>          {
>              case NT_PRSTATUS:
> +                have_prstatus = true;
>                  thread_data->prstatus = note_data;
>                  break;
>              case NT_FPREGSET:
>                  thread_data->fpregset = note_data;
>                  break;
>              case NT_PRPSINFO:
> +                have_prpsinfo = true;
>                  thread_data->prpsinfo = note_data;
>                  break;
>              case NT_AUXV:
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130718/2dfcb186/attachment.html>


More information about the lldb-commits mailing list