[Dwarf-discuss] dwarf ver3.0: prologue_end and epilogue_begin bits

Ramanaiah Nalamothu ramana.venkat83@gmail.com
Mon May 21 13:01:18 GMT 2007


Sorry in my previous mail i had given the wrong source and assembly pair. I
have changed the assembly. Please see below the correct assembly.

Again sorry for that. I new to posting queries to groups.

Please help me.

On 5/21/07, Ramanaiah Nalamothu <ramana.venkat83 at gmail.com> wrote:
>
>
>
> On 5/21/07, Ron Brender <ron.brender at charter.net> wrote:
> >
> > The prologue beginning and ending location are compiler code generation
> > artifacts that do not correlate usefully with line number. For example,
> > the same source might be input as
> >
> >      void foo (...) {...}
> >
> > or
> >
> >      void
> >      foo (
> >          ...)
> >      {
> >          ...
> >      }
> >
> > The compiled code, hence the begin and end prologue addresses, will be
> > identical,
>
>
> how the both addresses will be same?? (see below assembly code)
>
> but the line numbers will vary. The "normal" line-address
> > correlation will naturally associate a line number with those same
> > instructions--unrelated to the fact that they are begin or
> > end prologue related; that is expected.
>
>
> but with what line numbers i need to associate them with?? As i told you
> in my first mail -1, -2 and 0 are the special line numbers that my compiler
> will generate. I can't propagate them because they are not valid source line
> numbers.
>
> Here i am providing a sample source code and corresponding assembly code.
> See my comments with # ......#.
> .dbgline -1, .dbgline -2 and .dbgline 0 represents prologue_end,
> epilogue_begin and end of function or epilogue.
>
> test.c
> ---------------
> int res;
> extern void abort (void);
> extern void exit (int);
>
> struct baz
> {
>   int a, b, c, d, e;
> };
>
> void
> bar (struct baz *x, int f, int g, int h, int i, int j)
> {
>   if (x->a != 1 || x->b != 2 || x->c != 3 || x->d != 4 || x->e != 5 ||
>       f != 6 || g != 7 || h != 8 || i != 9 || j != 10)
>     res = -1;
> }
>
> void
> foo (char *z, struct baz x, char *y)
> {
>   bar (&x, 6, 7, 8, 9, 10);
>
>
>
> }
> int main (){
>   struct baz x;
>
>   x.a = 1;
>   x.b = 2;
>   x.c = 3;
>   x.d = 4;
>   x.e = 5;
>   foo ((char *) 0, x, (char *) 0);
>
>   if (res == -1)
>     return 0;
>   else
>     return 1;
>
> }
> ------------------------------------------
>
> test.s
> -------------------
> .dbfile C:\cygwin\home\Administrator\Arm\test.c
>     AREA    "C$$code", CODE, READONLY
>     CODE32
>     ALIGN 4
>     .dbfile C:\cygwin\home\Administrator\Arm\test.c
>     EXPORT _bar
>     .dbfunc e bar _bar fV
>     .dbstruct 0 20 baz
>     .dbfield 0 a I
>     .dbfield 4 b I
>     .dbfield 8 c I
>     .dbfield 12 d I
>     .dbfield 16 e I
>     .dbend
>     AREA    "C$$code", CODE, READONLY
>     CODE32
>     ALIGN 4
> ;              j -> R11,24
> ;              i -> R11,20
> ;              h -> R3
> ;              g -> R2
> ;              f -> R4
> ;              x -> R5
> _bar:
>     mov R12,R13
>     stmfd R13!,{R4,R5,R11,R12,R14}
>     mov R11,R13
>     mov R5,R0
>     mov R4,R1
>     .dbline -1                                             # indicates
> prologue_end #
>     .dbline 12
> ; int res;
> ; extern void abort (void);
> ; extern void exit (int);
> ;
> ; struct baz
> ; {
> ;   int a, b, c, d, e;
> ; };
> ;
> ; void
> ; bar (struct baz *x, int f, int g, int h, int i, int j)
> ; {
>     .dbline 13
> ;   if (x->a != 1 || x->b != 2 || x->c != 3 || x->d != 4 || x->e != 5 ||
>     ldr R0,[R5,#0]
>     cmp R0,#1
>     bne L12
>     ldr R0,[R5,#+4]
>     cmp R0,#2
>     bne L12
>     ldr R0,[R5,#+8]
>     cmp R0,#3
>     bne L12
>     ldr R0,[R5,#+12]
>     cmp R0,#4
>     bne L12
>     ldr R0,[R5,#+16]
>     cmp R0,#5
>     bne L12
>     cmp R4,#6
>     bne L12
>     cmp R2,#7
>     bne L12
>     cmp R3,#8
>     bne L12
>     ldr R12,[R11,#+20]
>     cmp R12,#9
>     bne L12
>     ldr R12,[R11,#+24]
>     cmp R12,#10
>     beq L2
> L12:
>     .dbline 15
> ;       f != 6 || g != 7 || h != 8 || i != 9 || j != 10)
> ;     res = -1;
>     mvn R0,#0
>     ldr R1,LIT_bar+0
>     str R0,[R1,#0]
> L2:
>     .dbline -2                                   # indicates
> prologue_begin. Here begin and end addresses are not same as you suggested #
> L1:
>     ldmfd R11,{R4,R5,R11,SP,R15}
>     .dbline 0 ; func end
>     .dbfile C:\cygwin\home\Administrator\Arm\test.c
> LIT_bar:
>     DCD _res
>     .dbsym l j 24 I
>     .dbsym l i 20 I
>     .dbsym r h 3 I
>     .dbsym r g 2 I
>     .dbsym r f 4 I
>     .dbsym r x 5 pS[baz]
>     .dbend
>     EXPORT _foo
>     .dbfunc e foo _foo fV
>     AREA    "C$$code", CODE, READONLY
>     CODE32
>     ALIGN 4
> ;              y -> R6
> ;              x -> R5
> ;              z -> R7
> _foo:
>     mov R12,R13
>     stmfd R13!,{R4,R5,R6,R7,R11,R12,R14}
>     mov R11,R13
>     sub R13,R13,#0x8
>     mov R7,R0
>     mov R5,R1
>     mov R6,R2
>     .dbline -1
>     .dbline 20
> ; }
> ;
> ; void
> ; foo (char *z, struct baz x, char *y)
> ; {
>     .dbline 21
> ;   bar (&x, 6, 7, 8, 9, 10);
>     mov R0,R5
>     mov R1,#6
>     mov R2,#7
>     mov R3,#8
>     mov R4,#9
>     str R4,[R13,#0]
>     mov R4,#10
>     str R4,[R13,#+4]
>     bl _bar
>     .dbline -2
> L13:
>     ldmfd R11,{R4,R5,R6,R7,R11,SP,R15}
>     .dbline 0 ; func end
>     .dbfile C:\cygwin\home\Administrator\Arm\test.c
>     .dbsym r y 6 pc
>     .dbsym r x 5 pS[baz]
>     .dbsym r z 7 pc
>     .dbend
>     EXPORT _main
>     .dbfunc e main _main fI
>     AREA    "C$$code", CODE, READONLY
>     CODE32
>     ALIGN 4
> ;              x -> R11,-20
> _main:
>     mov R12,R13
>     stmfd R13!,{R12,R14}
>     mov R11,R13
>     sub R13,R13,#0x28
>     .dbline -1
>     .dbline 26
> ;
> ;
> ;
> ; }
> ; int main (){
>     .dbline 29
> ;   struct baz x;
> ;
> ;   x.a = 1;
>     mov R4,#1
>     str R4,[R11,#-20]
>     .dbline 30
> ;   x.b = 2;
>     mov R4,#2
>     str R4,[R11,#-16]
>     .dbline 31
> ;   x.c = 3;
>     mov R4,#3
>     str R4,[R11,#-12]
>     .dbline 32
> ;   x.d = 4;
>     mov R4,#4
>     str R4,[R11,#-8]
>     .dbline 33
> ;   x.e = 5;
>     mov R4,#5
>     str R4,[R11,#-4]
>     .dbline 34
> ;   foo ((char *) 0, x, (char *) 0);
>     mov R4,#0
>     mov R0,R4
>     sub R5,R11,#0x14
>     sub R6,R11,#0x28
>     stmfd R13!,{R0}
>     ldr R12,LIT_main+0
>     add R5,R5,R12
>     add R2,R6,R12
>     ldr R0,[R5,#0]
>     str R0,[R2,#0]
> X0:
>     sub R5,R5,#8
>     sub R2,R2,#8
>     ldr R0,[R5,#0]
>     ldr R1,[R5,#+4]
>     str R0,[R2,#0]
>     str R1,[R2,#+4]
>     cmp R2,R6
>     bhi X0
>     ldmfd R13!,{R0}
>     sub R1,R11,#0x28
>     mov R2,R4
>     bl _foo
>     .dbline 36
> ;
> ;   if (res == -1)
>     mvn R4,#0
>     ldr R5,LIT_main+4
>     ldr R5,[R5,#0]
>     cmp R5,R4
>     .dbline 37
> ;     return 0;
>     moveq R0,#0
> L19:
>     .dbline 39
> ;   else
> ;     return 1;
>     movne R0,#1
>     .dbline -2
> L14:
>     ldmfd R11,{SP,R15}
>     .dbline 0 ; func end
>     .dbfile C:\cygwin\home\Administrator\Arm\test.c
> LIT_main:
>     DCD 16
>     DCD _res
>     .dbsym l x -20 S[baz]
>     .dbend
>     AREA    "Cudata", NOINIT
>     .dbfile C:\cygwin\home\Administrator\Arm\test.c
>     EXPORT _res
>     ALIGN    4
> _res:
>     SPACE 4
>     .dbsym e res _res I
>     END
>
> ------------------------------------------------------------------
>
> So if the debugger needs line numbers info what should be the line numbers
> for these prologue and epilogue cases?
>
> Thanks for your replies.
>
> Regards,
> Ramana
>
>
> Ron
> >
> > --------------------------
> > Ramanaiah Nalamothu wrote:
> > > Hi,
> > >
> > >  I am working at assembler context to emit the ELF-DWARF(dwarf ver3.0
> > ).
> > > I need to set the bits prologue_end and epilogue_begin. My compiler
> > > emits debug directive with specific -ve line numbers to indicate
> > > prologue_end and epilogue_begin. But they are not acceptable line
> > > numbers in source file.
> > > My doubt is, do I need to associate the their occurance with the
> > source
> > > line numbers or is it sufficient just to tell at what 'address' the
> > > prologue_end or epilogue_begin occur? If debugger needs line number,
> > > what line numbers should be emitted in my case?
> > >
> > > Thanks in advance for your replies.
> > >
> > > Regards,
> > > Ramana
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dwarfstd.org/private.cgi/dwarf-discuss-dwarfstd.org/attachments/20070521/0a0880f6/attachment.htm>



More information about the Dwarf-discuss mailing list