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