Home | History | Annotate | Line # | Download | only in gdbscripts
msgbuf revision 1.1.6.3
      1  1.1.6.3  bouyer # $NetBSD: msgbuf,v 1.1.6.3 2001/01/18 09:23:42 bouyer Exp $
      2  1.1.6.2  bouyer #
      3  1.1.6.2  bouyer # Copyright (c) 2000 The NetBSD Foundation, Inc.
      4  1.1.6.2  bouyer # All rights reserved.
      5  1.1.6.2  bouyer #
      6  1.1.6.2  bouyer # This code is derived from software contributed to The NetBSD Foundation
      7  1.1.6.2  bouyer # by John A. Hawkinson
      8  1.1.6.2  bouyer #
      9  1.1.6.2  bouyer # Redistribution and use in source and binary forms, with or without
     10  1.1.6.2  bouyer # modification, are permitted provided that the following conditions
     11  1.1.6.2  bouyer # are met:
     12  1.1.6.2  bouyer # 1. Redistributions of source code must retain the above copyright
     13  1.1.6.2  bouyer #    notice, this list of conditions and the following disclaimer.
     14  1.1.6.2  bouyer # 2. Redistributions in binary form must reproduce the above copyright
     15  1.1.6.2  bouyer #    notice, this list of conditions and the following disclaimer in the
     16  1.1.6.2  bouyer #    documentation and/or other materials provided with the distribution.
     17  1.1.6.2  bouyer # 3. All advertising materials mentioning features or use of this software
     18  1.1.6.2  bouyer #    must display the following acknowledgement:
     19  1.1.6.2  bouyer #        This product includes software developed by the NetBSD
     20  1.1.6.2  bouyer #        Foundation, Inc. and its contributors.
     21  1.1.6.2  bouyer # 4. Neither the name of The NetBSD Foundation nor the names of its
     22  1.1.6.2  bouyer #    contributors may be used to endorse or promote products derived
     23  1.1.6.2  bouyer #    from this software without specific prior written permission.
     24  1.1.6.2  bouyer #
     25  1.1.6.2  bouyer # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26  1.1.6.2  bouyer # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  1.1.6.2  bouyer # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  1.1.6.2  bouyer # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29  1.1.6.2  bouyer # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  1.1.6.2  bouyer # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  1.1.6.2  bouyer # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  1.1.6.2  bouyer # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  1.1.6.2  bouyer # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  1.1.6.2  bouyer # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  1.1.6.2  bouyer # POSSIBILITY OF SUCH DAMAGE.
     36  1.1.6.2  bouyer #
     37  1.1.6.2  bouyer 
     38  1.1.6.2  bouyer define msgbuf
     39  1.1.6.3  bouyer   set $bufx=*(long*)((char *)msgbufp+1*sizeof(long))
     40  1.1.6.3  bouyer   set $bufr=*(long*)((char *)msgbufp+2*sizeof(long))
     41  1.1.6.3  bouyer   set $bufs=*(long*)((char *)msgbufp+3*sizeof(long))
     42  1.1.6.2  bouyer 
     43  1.1.6.2  bouyer   printf "msgbufp %#x: bufx %d bufr %d bufs %d\n", msgbufp, $bufx, $bufr, $bufs
     44  1.1.6.2  bouyer 
     45  1.1.6.2  bouyer # Dump the unread section
     46  1.1.6.2  bouyer #  set $l = $bufx - $bufr
     47  1.1.6.2  bouyer #  if ($l < 0)
     48  1.1.6.2  bouyer #    set $l = $bufs - $bufr
     49  1.1.6.2  bouyer #  end
     50  1.1.6.2  bouyer #  set $p = (long)msgbufp+4*sizeof(long)+$bufr
     51  1.1.6.2  bouyer #  set print elements $l
     52  1.1.6.2  bouyer #  x/s $p
     53  1.1.6.2  bouyer 
     54  1.1.6.2  bouyer # Dump the whole thing
     55  1.1.6.2  bouyer # Presume each section is null-terminated. Possibly bad presumption?
     56  1.1.6.2  bouyer   set $p = (long)msgbufp+4*sizeof(long)+$bufx
     57  1.1.6.2  bouyer   set $l = $bufs - $bufx
     58  1.1.6.2  bouyer   set print elements $l
     59  1.1.6.2  bouyer   printf "Dumping %#x length %d\n", $p, $l  
     60  1.1.6.2  bouyer   # XXX (unsupported by gdb): printf "%.*s\n", $l, $p
     61  1.1.6.2  bouyer   printf "%s\n", $p
     62  1.1.6.2  bouyer   set $p = (long)msgbufp+4*sizeof(long)
     63  1.1.6.2  bouyer   set $l = $bufx
     64  1.1.6.2  bouyer   set print elements $l
     65  1.1.6.2  bouyer   printf "Dumping %#x length %d\n", $p, $l  
     66  1.1.6.2  bouyer   # XXX (unsupported by gdb): printf "%.*s\n\n", $l, $p
     67  1.1.6.2  bouyer   printf "%s\n\n", $p
     68  1.1.6.2  bouyer end
     69  1.1.6.2  bouyer 
     70  1.1.6.2  bouyer document msgbuf
     71  1.1.6.2  bouyer   Dump the kernel message buffer.
     72  1.1.6.2  bouyer end
     73