From citrin@citrin.park.rambler.ru  Thu Apr 16 11:48:28 2009
Return-Path: <citrin@citrin.park.rambler.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C6CF3106564A
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Apr 2009 11:48:28 +0000 (UTC)
	(envelope-from citrin@citrin.park.rambler.ru)
Received: from mailsupport.rambler.ru (mailsupport.rambler.ru [81.19.66.129])
	by mx1.freebsd.org (Postfix) with ESMTP id 7BD048FC18
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Apr 2009 11:48:28 +0000 (UTC)
	(envelope-from citrin@citrin.park.rambler.ru)
Received: from citrin.park.rambler.ru (unknown [81.19.90.176])
	by mailsupport.rambler.ru (Postfix) with ESMTPS id 76B8EA7
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Apr 2009 15:48:26 +0400 (MSD)
Received: from citrin.park.rambler.ru (localhost [127.0.0.1])
	by citrin.park.rambler.ru (8.14.3/8.14.3) with ESMTP id n3GBmQa2078807
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Apr 2009 15:48:26 +0400 (MSD)
	(envelope-from citrin@citrin.park.rambler.ru)
Received: (from citrin@localhost)
	by citrin.park.rambler.ru (8.14.3/8.14.3/Submit) id n3GBmQX4078806;
	Thu, 16 Apr 2009 15:48:26 +0400 (MSD)
	(envelope-from citrin)
Message-Id: <200904161148.n3GBmQX4078806@citrin.park.rambler.ru>
Date: Thu, 16 Apr 2009 15:48:26 +0400 (MSD)
From: Anton Yuzhaninov <citrin@citrin.ru>
Reply-To: Anton Yuzhaninov <citrin@citrin.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] gdb debugscripts: fix proc address print in ps macros
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         133775
>Category:       kern
>Synopsis:       [patch] gdb(1) debugscripts: fix proc address print in ps macros
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 16 11:50:01 UTC 2009
>Closed-Date:    
>Last-Modified:  Thu Apr 16 17:25:02 UTC 2009
>Originator:     Anton Yuzhaninov
>Release:        FreeBSD 8.0-CURRENT amd64
>Organization:
Rambler
>Environment:
System: FreeBSD citrin.park.rambler.ru 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Wed Apr 8 05:31:05 MSD 2009 citrin@citrin.park.rambler.ru:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
ps macros from debugscripts print correct proc address on i386, but print only half of address on amd64
>How-To-Repeat:
on amd64 host:
# cd/usr/obj/usr/src/sys/GENERIC
# make gdbinit
# kgdb kernel.debug /dev/mem
(kgdb) ps
During symbol reading, Incomplete CFI data; unspecified registers at 0xffffffff805479c9.
  pid    proc   uid  ppid  pgrp   flag stat comm         wchan
76791 57d01000 1001 75925 31548  10004002  1  inkscape     
76789 042978b0    0 35574 76789  10004002  1  kgdb         
...
(kgdb) p *(struct proc*) 0x042978b0
Error accessing memory address 0x42978b0: Bad address.
>Fix:
--- tools/debugscripts/gdbinit.kernel.orig	2009-04-16 14:09:42.000000000 +0400
+++ tools/debugscripts/gdbinit.kernel	2009-04-16 15:33:52.000000000 +0400
@@ -199,7 +199,7 @@
     set $nproc = nprocs
     set $aproc = allproc.lh_first
     set $proc = allproc.lh_first
-    printf "  pid    proc   uid  ppid  pgrp   flag stat comm         wchan\n"
+    printf "  pid          proc       uid  ppid  pgrp   flag stat comm         wchan\n"
     while (--$nproc >= 0)
         set $pptr = $proc.p_pptr
         if ($pptr == 0)
@@ -208,7 +208,7 @@
         if ($proc.p_state)
             set $thread = $proc->p_threads.tqh_first
             while ($thread)
-                printf "%5d %08x %4d %5d %5d  %06x  %d  %-10s   ", \
+                printf "%5d %18p %4d %5d %5d  %06x  %d  %-10s   ", \
                        $proc.p_pid, $aproc, \
                        $proc.p_ucred->cr_ruid, $pptr->p_pid, \
                        $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_state, \
>Release-Note:
>Audit-Trail:

From: Maxim Konovalov <maxim@macomnet.ru>
To: Anton Yuzhaninov <citrin@citirn.ru>
Cc: bug-followup@freebsd.org
Subject: Re: kern/133775: [patch] gdb debugscripts: fix proc address print
 in ps macros
Date: Thu, 16 Apr 2009 17:48:13 +0400 (MSD)

 > >Fix:
 > --- tools/debugscripts/gdbinit.kernel.orig	2009-04-16 14:09:42.000000000 +0400
 > +++ tools/debugscripts/gdbinit.kernel	2009-04-16 15:33:52.000000000 +0400
 > @@ -199,7 +199,7 @@
 >      set $nproc = nprocs
 >      set $aproc = allproc.lh_first
 >      set $proc = allproc.lh_first
 > -    printf "  pid    proc   uid  ppid  pgrp   flag stat comm         wchan\n"
 > +    printf "  pid          proc       uid  ppid  pgrp   flag stat comm         wchan\n"
 >      while (--$nproc >= 0)
 >          set $pptr = $proc.p_pptr
 >          if ($pptr == 0)
 > @@ -208,7 +208,7 @@
 >          if ($proc.p_state)
 >              set $thread = $proc->p_threads.tqh_first
 >              while ($thread)
 > -                printf "%5d %08x %4d %5d %5d  %06x  %d  %-10s   ", \
 > +                printf "%5d %18p %4d %5d %5d  %06x  %d  %-10s   ", \
 >                         $proc.p_pid, $aproc, \
 >                         $proc.p_ucred->cr_ruid, $pptr->p_pid, \
 >                         $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_state, \
 
 It makes kgdb output on i386 system looks ugly.  Is there a way to
 make gdbinit platform aware?
 
 -- 
 Maxim Konovalov

From: Anton Yuzhaninov <citrin@citrin.ru>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/133775: [patch] gdb debugscripts: fix proc address print
 in ps macros
Date: Thu, 16 Apr 2009 19:25:32 +0400

 >  It makes kgdb output on i386 system looks ugly.  Is there a way to
 >  make gdbinit platform aware?
 
 Simplest way is to have 2 slightly different variants of ps macro -
 in gdbinit.i386 and default in gdbinit.kernel
 
 But copy-paste is not good way in this case.
 
 -- 
   Anton Yuzhaninov
>Unformatted:
