[Lldb-commits] [PATCH] Register Number in DWARFCallFrameInfo.cpp
Jason Molenda
jmolenda at apple.com
Tue Aug 12 15:51:27 PDT 2014
Hm, on my Mac I'm getting the correct registers from the eh_frame.
* thread #1: tid = 0xce36, 0x00001f30 a.out`main, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
#0: 0x00001f30 a.out`main
a.out`main:
-> 0x1f30: pushl %ebp
0x1f31: movl %esp, %ebp
0x1f33: subl $0x8, %esp
0x1f36: calll 0x1f3b ; main + 11
(lldb) image show-unwind -n main
<lldb.driver.main-thread> (i386) /private/tmp/a.out: Reading EH frame info
First non-prologue instruction is at address 0x1f36 or offset 6 into the function.
Asynchronous (not restricted to call-sites) UnwindPlan for a.out`main (start addr 0x1f30):
This UnwindPlan originally sourced from assembly insn profiling
Address range of this UnwindPlan: [a.out.__TEXT.__text + 0-0x00000029)
row[0]: 0x00000000: CFA=esp +4 => esp=esp+4 eip=[esp]
row[1]: 0x00000001: CFA=esp +8 => ebp=[esp] esp=esp+8 eip=[esp+4]
row[2]: 0x00000003: CFA=ebp +8 => ebp=[ebp] esp=ebp+8 eip=[ebp+4]
row[3]: 0x00000028: CFA=esp +4 => esp=esp+4 eip=[esp]
Synchronous (restricted to call-sites) UnwindPlan for a.out`main (start addr 0x1f30):
This UnwindPlan originally sourced from eh_frame CFI
Address range of this UnwindPlan: [a.out.__TEXT.__text + 0-0x00000029)
row[0]: 0x00000000: CFA=esp +4 => eip=[esp]
row[1]: 0x00000001: CFA=esp +8 => ebp=[esp] eip=[esp+4]
row[2]: 0x00000003: CFA=ebp +8 => ebp=[ebp] eip=[ebp+4]
The UnwindAssembly_x86 generated UnwindPlan and the clang-generated eh_frame cfi match up...
> On Aug 12, 2014, at 3:38 PM, Tong Shen <endlessroad at google.com> wrote:
>
> In i386 .eh_frame, esp=4, ebp=5. I confirmed it by cfi directives gcc generates and objdump -W.
>
> So it's either we chose the wrong eRegisterKindXXX, or we put {dwarf, gcc}_{esp, ebp}_i386 in wrong order in source/Plugins/Process/Utility/RegisterContext_x86.h :-)
>
>
> On Tue, Aug 12, 2014 at 3:23 PM, Jason Molenda <jmolenda at apple.com> wrote:
> Hi Tong, sorry for not replying earlier.
>
> I don't understand why the current code is wrong.
>
> eRegisterKindGCC = 0, // the register numbers seen in eh_frame
> eRegisterKindDWARF, // the register numbers seen DWARF
>
> and
>
> SectionSP sect = sl->FindSectionByType (eSectionTypeEHFrame, true);
> if (sect.get())
> {
> m_eh_frame = new DWARFCallFrameInfo(m_object_file, sect, eRegisterKindGCC, true);
> }
>
> We create a DWARFCallFrameInfo object to read the eh_frame information and we tell it that the register kind to use for the reg numbers is eRegisterKindGCC - aka the eh_frame register numbering domain.
>
> This all looks correct to me, and designed specifically to handle the case of that ancient gcc register numbering bug in the eh_frame section for i386.
>
> We never read the actual DWARF debug_frame (today) because I've never seen a case where it had more information than the eh_frame unwind info.
>
>
>
> > On Aug 12, 2014, at 1:36 PM, Tong Shen <endlessroad at google.com> wrote:
> >
> > Aha, got it.
> > Patch confirmed and attached.
> >
> >
> > On Tue, Aug 12, 2014 at 12:51 PM, Ed Maste <emaste at freebsd.org> wrote:
> > On 12 August 2014 15:43, Todd Fiala <tfiala at google.com> wrote:
> > >
> > > Hey Tong,
> > >
> > > Ah interesting. The register infos in lldb have a vector of different register numbers (I think we call them "register kinds") based on the type of encoding you're using. Let's have a look at that to see if we can adjust the code to query for the right register kind. We'll look at this today!
> >
> > There was a thread on this topic on this list a while back, and I
> > think the two register sets in question here are DWARF and GCC, which
> > are identical in all cases except that i386 swaps esp and ebp between
> > the two. This is all the legacy of an ancient GCC bug. So I think
> > you're right Todd, just picking the other set should solve this.
> >
> >
> >
> > --
> > Best Regards, Tong Shen
> > <fix_register_kind.patch>_______________________________________________
> > lldb-commits mailing list
> > lldb-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
>
>
>
> --
> Best Regards, Tong Shen
More information about the lldb-commits
mailing list