Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Request/question from RMS
@ 2002-01-10  6:45 Andrew Cagney
  2002-01-10  7:49 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2002-01-10  6:45 UTC (permalink / raw)
  To: gdb

Private e-mail from Richard Stallman.  Reproduced with permission.


> In Emacs .gdbinit I found this:
> 
>     define xreload
>       set $valmask = ((long)1 << gdb_valbits) - 1
>       set $nonvalbits = gdb_emacs_intbits - gdb_valbits
>     end
>     document xreload
>       When starting Emacs a second time in the same gdb session under
>       FreeBSD 2.2.5, gdb 4.13, $valmask and $nonvalbits have lost
>       their values.  (The same happens on current (2000) versions of GNU/Linux
>       with gdb 5.0.)
>       This function reloads them.
>     end
> 
> I think GDB should avoid making this necessary--that it should
> reread .gdbinit when it reloads the executable.  Or there should
> be a certain user-defined command that will be run after GDB
> reloads the executable.


I know there are now things like posthook-run commands.  However, 
without knowing how EMACS uses the above (I've no desire to debug emacs, 
debugging mozilla was scary enough :-^) it is hard to suggest a replacement.

RMS also expressed a preference for avoiding features less than a year old.

Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Request/question from RMS
  2002-01-10  6:45 Request/question from RMS Andrew Cagney
@ 2002-01-10  7:49 ` Eli Zaretskii
  2002-01-10 16:13   ` Andrew Cagney
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2002-01-10  7:49 UTC (permalink / raw)
  To: ac131313; +Cc: gdb

> Date: Thu, 10 Jan 2002 09:45:26 -0500
> From: Andrew Cagney <ac131313@cygnus.com>
> 
> > In Emacs .gdbinit I found this:
> > 
> >     define xreload
> >       set $valmask = ((long)1 << gdb_valbits) - 1
> >       set $nonvalbits = gdb_emacs_intbits - gdb_valbits
> >     end
[...]
> > I think GDB should avoid making this necessary--that it should
> > reread .gdbinit when it reloads the executable.  Or there should
> > be a certain user-defined command that will be run after GDB
> > reloads the executable.
> 
> I know there are now things like posthook-run commands.  However, 
> without knowing how EMACS uses the above (I've no desire to debug emacs, 
> debugging mozilla was scary enough :-^) it is hard to suggest a replacement.

Here's an example of how this is used:

    define xint
    print (($ & $valmask) << $nonvalbits) >> $nonvalbits
    end
    document xint
    Print $, assuming it is an Emacs Lisp integer.  This gets the sign right.
    end
    define xsymbol
    print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits)
    output (char*)$->name->data
    echo \n
    end
    document xsymbol
    Print the name and address of the symbol $.
    This command assumes that $ is an Emacs Lisp symbol value.
    end

In other words, Emacs Lisp objects are represented by C int's, whereby
a few high bits are used for the tag that distinguishes between the
types, while the rest of the int is normally a pointer to a place
where the object is stored (an Emacs integer is an exception: it
represents itself).  When you debug Emacs, you use commands like xint
and xsymbol to display the values of the Lisp object (here, an integer
and a symbol, respectively) in human-readable format.  Here's an
example of usage:

    (gdb) p Qnil
    $1 = 270900228
    (gdb) xsymbol
    $2 = (struct Lisp_Symbol *) 0x259c04
    0x129928 "nil"
    (gdb)

(`Qnil' is the C variable which holds the Lisp symbol `nil'.)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Request/question from RMS
  2002-01-10  7:49 ` Eli Zaretskii
@ 2002-01-10 16:13   ` Andrew Cagney
  2002-01-10 23:55     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2002-01-10 16:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb

> Date: Thu, 10 Jan 2002 09:45:26 -0500
>> From: Andrew Cagney <ac131313@cygnus.com>
>> 
> 
>> > In Emacs .gdbinit I found this:
>> > 
>> > define xreload
>> > set $valmask = ((long)1 << gdb_valbits) - 1
>> > set $nonvalbits = gdb_emacs_intbits - gdb_valbits
>> > end
> 
> [...]
> 
>> > I think GDB should avoid making this necessary--that it should
>> > reread .gdbinit when it reloads the executable.  Or there should
>> > be a certain user-defined command that will be run after GDB
>> > reloads the executable.
> 
>> 
>> I know there are now things like posthook-run commands.  However, 
>> without knowing how EMACS uses the above (I've no desire to debug emacs, 
>> debugging mozilla was scary enough :-^) it is hard to suggest a replacement.
> 
> 
> Here's an example of how this is used:
> 
>     define xint
>     print (($ & $valmask) << $nonvalbits) >> $nonvalbits
>     end
>     document xint
>     Print $, assuming it is an Emacs Lisp integer.  This gets the sign right.
>     end
>     define xsymbol
>     print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits)
>     output (char*)$->name->data
>     echo \n
>     end
>     document xsymbol
>     Print the name and address of the symbol $.
>     This command assumes that $ is an Emacs Lisp symbol value.
>     end


Ok.

This suggests that:

	define hookpost-run
	set $valmask = ((long)1 << gdb_valbits) - 1
	set $nonvalbits = gdb_emacs_intbits - gdb_valbits
	end

should do the trick.

	Andrew






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Request/question from RMS
  2002-01-10 16:13   ` Andrew Cagney
@ 2002-01-10 23:55     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2002-01-10 23:55 UTC (permalink / raw)
  To: ac131313; +Cc: gdb

> Date: Thu, 10 Jan 2002 19:13:13 -0500
> From: Andrew Cagney <ac131313@cygnus.com>
> 
> This suggests that:
> 
> 	define hookpost-run
> 	set $valmask = ((long)1 << gdb_valbits) - 1
> 	set $nonvalbits = gdb_emacs_intbits - gdb_valbits
> 	end
> 
> should do the trick.

Thanks, please post this to emacs-devel@gnu.org.  (I never needed to
use xreload, so I cannot check whethr this solves the problem.)

Btw, isn't hookpost-run something introduced only in GDB 5.1?


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-01-11  7:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-10  6:45 Request/question from RMS Andrew Cagney
2002-01-10  7:49 ` Eli Zaretskii
2002-01-10 16:13   ` Andrew Cagney
2002-01-10 23:55     ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox