xref: /netbsd-src/sys/gdbscripts/msgbuf (revision 11a6dbe72840351315e0652b2fc6663628c84cad)
1*11a6dbe7Smartin# $NetBSD: msgbuf,v 1.5 2008/04/30 13:10:59 martin Exp $
259f702f7Sjhawk#
359f702f7Sjhawk# Copyright (c) 2000 The NetBSD Foundation, Inc.
459f702f7Sjhawk# All rights reserved.
559f702f7Sjhawk#
659f702f7Sjhawk# This code is derived from software contributed to The NetBSD Foundation
759f702f7Sjhawk# by John A. Hawkinson
859f702f7Sjhawk#
959f702f7Sjhawk# Redistribution and use in source and binary forms, with or without
1059f702f7Sjhawk# modification, are permitted provided that the following conditions
1159f702f7Sjhawk# are met:
1259f702f7Sjhawk# 1. Redistributions of source code must retain the above copyright
1359f702f7Sjhawk#    notice, this list of conditions and the following disclaimer.
1459f702f7Sjhawk# 2. Redistributions in binary form must reproduce the above copyright
1559f702f7Sjhawk#    notice, this list of conditions and the following disclaimer in the
1659f702f7Sjhawk#    documentation and/or other materials provided with the distribution.
1759f702f7Sjhawk#
1859f702f7Sjhawk# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1959f702f7Sjhawk# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2059f702f7Sjhawk# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2159f702f7Sjhawk# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2259f702f7Sjhawk# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2359f702f7Sjhawk# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2459f702f7Sjhawk# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2559f702f7Sjhawk# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2659f702f7Sjhawk# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2759f702f7Sjhawk# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2859f702f7Sjhawk# POSSIBILITY OF SUCH DAMAGE.
2959f702f7Sjhawk#
3059f702f7Sjhawk
3159f702f7Sjhawkdefine msgbuf
3285c0b91eSdeberg  set $bufx=*(long*)((char *)msgbufp+1*sizeof(long))
3385c0b91eSdeberg  set $bufr=*(long*)((char *)msgbufp+2*sizeof(long))
3485c0b91eSdeberg  set $bufs=*(long*)((char *)msgbufp+3*sizeof(long))
3559f702f7Sjhawk
3659f702f7Sjhawk  printf "msgbufp %#x: bufx %d bufr %d bufs %d\n", msgbufp, $bufx, $bufr, $bufs
3759f702f7Sjhawk
3859f702f7Sjhawk# Dump the unread section
3959f702f7Sjhawk#  set $l = $bufx - $bufr
4059f702f7Sjhawk#  if ($l < 0)
4159f702f7Sjhawk#    set $l = $bufs - $bufr
4259f702f7Sjhawk#  end
4359f702f7Sjhawk#  set $p = (long)msgbufp+4*sizeof(long)+$bufr
4459f702f7Sjhawk#  set print elements $l
4559f702f7Sjhawk#  x/s $p
4659f702f7Sjhawk
4759f702f7Sjhawk# Dump the whole thing
4859f702f7Sjhawk# Presume each section is null-terminated. Possibly bad presumption?
4959f702f7Sjhawk  set $p = (long)msgbufp+4*sizeof(long)+$bufx
5059f702f7Sjhawk  set $l = $bufs - $bufx
5159f702f7Sjhawk  set print elements $l
5259f702f7Sjhawk  printf "Dumping %#x length %d\n", $p, $l
5359f702f7Sjhawk  # XXX (unsupported by gdb): printf "%.*s\n", $l, $p
5459f702f7Sjhawk  printf "%s\n", $p
5559f702f7Sjhawk  set $p = (long)msgbufp+4*sizeof(long)
5659f702f7Sjhawk  set $l = $bufx
5759f702f7Sjhawk  set print elements $l
5859f702f7Sjhawk  printf "Dumping %#x length %d\n", $p, $l
5959f702f7Sjhawk  # XXX (unsupported by gdb): printf "%.*s\n\n", $l, $p
6059f702f7Sjhawk  printf "%s\n\n", $p
6159f702f7Sjhawkend
6259f702f7Sjhawk
6359f702f7Sjhawkdocument msgbuf
6459f702f7Sjhawk  Dump the kernel message buffer.
6559f702f7Sjhawkend
66