This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug exp/15238] New: odd things with printing function types (p*****************_start)


http://sourceware.org/bugzilla/show_bug.cgi?id=15238

             Bug #: 15238
           Summary: odd things with printing function types (p
                    *****************_start)
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: exp
        AssignedTo: unassigned@sourceware.org
        ReportedBy: palves@redhat.com
    Classification: Unclassified


$ gdb ...
  ...
  0x0000003d25a01530 in _start () from /lib64/ld-linux-x86-64.so.2
  (gdb) p _start
  $1 = {<text variable, no debug info>} 0x402860 <_start>

I was trying to poke at the first address of _start.  I forgot
one needs to write "p *(char *)_start = 1", and got:

  (gdb)  p *_start = 1
  Invalid cast.

Trying to recall the correct syntax, I noticed that
dereferencing a function yields back the same thing:

  (gdb) p *_start 
  $2 = {<text variable, no debug info>} 0x402860 <_start>

and on:

  (gdb) p **_start 
  $3 = {<text variable, no debug info>} 0x402860 <_start>

and on... :

  (gdb) p *****************************************_start 
  $30 = {<text variable, no debug info>} 0x402860 <_start>

That looks bizarre.

I don't have debug info for _start, so GDB assumes 'int()':

  (gdb) ptype _start 
  type = int ()

But:

  (gdb) ptype *_start 
  Attempt to take contents of a non-pointer value.

I _think_ ptype is right in erroring out.  Maybe the print behavior is intended
though, not sure, haven't looked at the code.
But then I'm surprised that print "works" and ptype doesn't.  If an expression
works with one, it should work with the other, and the inverse too.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]