Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jan 2008 23:37:20 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 133689 for review
Message-ID:  <200801192337.m0JNbKZe005252@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=133689

Change 133689 by kmacy@kmacy:storage:toehead on 2008/01/19 23:36:24

	IFC 133683

Affected files ...

.. //depot/projects/toehead/contrib/gdb/FREEBSD-diffs#1 branch
.. //depot/projects/toehead/contrib/top/display.c#2 integrate
.. //depot/projects/toehead/contrib/top/layout.h#2 integrate
.. //depot/projects/toehead/contrib/top/machine.h#2 integrate
.. //depot/projects/toehead/contrib/top/top.c#3 integrate
.. //depot/projects/toehead/contrib/top/top.h#2 integrate
.. //depot/projects/toehead/gnu/usr.bin/gdb/kgdb/kgdb.h#2 integrate
.. //depot/projects/toehead/gnu/usr.bin/gdb/kgdb/kthr.c#2 integrate
.. //depot/projects/toehead/gnu/usr.bin/gdb/kgdb/main.c#2 integrate
.. //depot/projects/toehead/gnu/usr.bin/gdb/kgdb/trgt.c#2 integrate
.. //depot/projects/toehead/include/unistd.h#3 integrate
.. //depot/projects/toehead/lib/libarchive/archive_read_extract.c#2 integrate
.. //depot/projects/toehead/lib/libarchive/archive_write_disk.c#3 integrate
.. //depot/projects/toehead/lib/libarchive/test/Makefile#3 integrate
.. //depot/projects/toehead/lib/libarchive/test/test_write_disk.c#2 integrate
.. //depot/projects/toehead/lib/libarchive/test/test_write_disk_hardlink.c#1 branch
.. //depot/projects/toehead/lib/libc/sparc64/_fpmath.h#2 integrate
.. //depot/projects/toehead/lib/libthr/Makefile#2 integrate
.. //depot/projects/toehead/lib/msun/Makefile#4 integrate
.. //depot/projects/toehead/lib/msun/Symbol.map#4 integrate
.. //depot/projects/toehead/lib/msun/ld128/s_exp2l.c#1 branch
.. //depot/projects/toehead/lib/msun/ld80/s_exp2l.c#1 branch
.. //depot/projects/toehead/lib/msun/man/exp.3#2 integrate
.. //depot/projects/toehead/lib/msun/man/log.3#1 branch
.. //depot/projects/toehead/lib/msun/src/e_expf.c#2 integrate
.. //depot/projects/toehead/lib/msun/src/k_rem_pio2.c#2 integrate
.. //depot/projects/toehead/lib/msun/src/k_rem_pio2f.c#2 integrate
.. //depot/projects/toehead/lib/msun/src/math.h#5 integrate
.. //depot/projects/toehead/lib/msun/src/math_private.h#4 integrate
.. //depot/projects/toehead/lib/msun/src/s_exp2.c#2 integrate
.. //depot/projects/toehead/lib/msun/src/s_exp2f.c#2 integrate
.. //depot/projects/toehead/lib/msun/src/s_log1p.c#2 integrate
.. //depot/projects/toehead/lib/msun/src/s_log1pf.c#2 integrate
.. //depot/projects/toehead/lib/msun/src/s_rint.c#3 integrate
.. //depot/projects/toehead/lib/msun/src/s_rintf.c#2 integrate
.. //depot/projects/toehead/share/man/man4/pcib.4#2 integrate
.. //depot/projects/toehead/share/man/man7/clocks.7#2 integrate
.. //depot/projects/toehead/share/man/man9/VOP_LOCK.9#3 integrate
.. //depot/projects/toehead/share/misc/bsd-family-tree#3 integrate
.. //depot/projects/toehead/share/mk/bsd.own.mk#4 integrate
.. //depot/projects/toehead/share/zoneinfo/leapseconds#2 integrate
.. //depot/projects/toehead/sys/arm/xscale/ixp425/if_npe.c#2 integrate
.. //depot/projects/toehead/sys/dev/an/if_an.c#2 integrate
.. //depot/projects/toehead/sys/dev/an/if_an_pci.c#2 integrate
.. //depot/projects/toehead/sys/dev/an/if_anreg.h#2 integrate
.. //depot/projects/toehead/sys/dev/ath/if_ath.c#2 integrate
.. //depot/projects/toehead/sys/dev/bge/if_bge.c#3 integrate
.. //depot/projects/toehead/sys/dev/bge/if_bgereg.h#3 integrate
.. //depot/projects/toehead/sys/dev/cxgb/cxgb_sge.c#4 integrate
.. //depot/projects/toehead/sys/dev/cxgb/sys/cxgb_support.c#3 integrate
.. //depot/projects/toehead/sys/dev/cxgb/sys/mvec.h#4 integrate
.. //depot/projects/toehead/sys/dev/gem/if_gem.c#3 integrate
.. //depot/projects/toehead/sys/dev/mii/brgphy.c#2 integrate
.. //depot/projects/toehead/sys/dev/msk/if_msk.c#2 integrate
.. //depot/projects/toehead/sys/dev/nfe/if_nfe.c#2 integrate
.. //depot/projects/toehead/sys/dev/re/if_re.c#3 integrate
.. //depot/projects/toehead/sys/dev/stge/if_stge.c#3 integrate
.. //depot/projects/toehead/sys/dev/wpi/if_wpi.c#2 integrate
.. //depot/projects/toehead/sys/fs/coda/cnode.h#2 integrate
.. //depot/projects/toehead/sys/fs/coda/coda_namecache.h#2 integrate
.. //depot/projects/toehead/sys/fs/coda/coda_psdev.c#2 integrate
.. //depot/projects/toehead/sys/fs/coda/coda_vfsops.c#3 integrate
.. //depot/projects/toehead/sys/fs/coda/coda_vnops.c#3 integrate
.. //depot/projects/toehead/sys/fs/udf/udf_vfsops.c#4 integrate
.. //depot/projects/toehead/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c#2 integrate
.. //depot/projects/toehead/sys/gnu/fs/xfs/FreeBSD/xfs_buf.h#2 integrate
.. //depot/projects/toehead/sys/kern/genassym.sh#2 integrate
.. //depot/projects/toehead/sys/kern/kern_mib.c#3 integrate
.. //depot/projects/toehead/sys/kern/kern_shutdown.c#3 integrate
.. //depot/projects/toehead/sys/kern/kern_time.c#2 integrate
.. //depot/projects/toehead/sys/kern/tty_pty.c#2 integrate
.. //depot/projects/toehead/sys/kern/uipc_mbuf.c#2 integrate
.. //depot/projects/toehead/sys/kern/uipc_usrreq.c#3 integrate
.. //depot/projects/toehead/sys/kern/vfs_bio.c#3 integrate
.. //depot/projects/toehead/sys/kern/vfs_subr.c#3 integrate
.. //depot/projects/toehead/sys/net/if_bridge.c#4 integrate
.. //depot/projects/toehead/sys/netinet/tcp_usrreq.c#4 integrate
.. //depot/projects/toehead/sys/nfs4client/nfs4_vnops.c#3 integrate
.. //depot/projects/toehead/sys/nfsclient/nfs_subs.c#3 integrate
.. //depot/projects/toehead/sys/nfsclient/nfs_vnops.c#3 integrate
.. //depot/projects/toehead/sys/nfsserver/nfs_srvsubs.c#3 integrate
.. //depot/projects/toehead/sys/security/audit/audit_bsm.c#2 integrate
.. //depot/projects/toehead/sys/sys/buf.h#3 integrate
.. //depot/projects/toehead/sys/sys/lockmgr.h#3 integrate
.. //depot/projects/toehead/sys/sys/mbuf.h#3 integrate
.. //depot/projects/toehead/sys/sys/param.h#3 integrate
.. //depot/projects/toehead/sys/sys/signal.h#2 integrate
.. //depot/projects/toehead/sys/sys/time.h#2 integrate
.. //depot/projects/toehead/sys/ufs/ffs/ffs_vfsops.c#3 integrate
.. //depot/projects/toehead/tools/build/mk/OptionalObsoleteFiles.inc#2 integrate
.. //depot/projects/toehead/tools/regression/lib/msun/Makefile#3 integrate
.. //depot/projects/toehead/tools/regression/lib/msun/test-exponential.c#1 branch
.. //depot/projects/toehead/tools/regression/lib/msun/test-exponential.t#1 branch
.. //depot/projects/toehead/usr.bin/top/machine.c#3 integrate
.. //depot/projects/toehead/usr.bin/vmstat/vmstat.c#3 integrate

Differences ...

==== //depot/projects/toehead/contrib/top/display.c#2 (text+ko) ====

@@ -8,7 +8,7 @@
  *  Copyright (c) 1984, 1989, William LeFebvre, Rice University
  *  Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University
  *
- * $FreeBSD: src/contrib/top/display.c,v 1.9 2005/05/19 13:34:19 keramida Exp $
+ * $FreeBSD: src/contrib/top/display.c,v 1.10 2008/01/18 01:43:13 peter Exp $
  */
 
 /*
@@ -78,8 +78,10 @@
 static int *lmemory;
 static int *lswap;
 
+static int num_cpus;
 static int *cpustate_columns;
 static int cpustate_total_length;
+static int cpustates_column;
 
 static enum { OFF, ON, ERASE } header_status = ON;
 
@@ -87,6 +89,29 @@
 static void summary_format();
 static void line_update();
 
+int  x_lastpid =	10;
+int  y_lastpid =	0;
+int  x_loadave =	33;
+int  x_loadave_nompid =	15;
+int  y_loadave =	0;
+int  x_procstate =	0;
+int  y_procstate =	1;
+int  x_brkdn =		15;
+int  y_brkdn =		1;
+int  x_mem =		5;
+int  y_mem =		3;
+int  x_swap =		6;
+int  y_swap =		4;
+int  y_message =	5;
+int  x_header =		0;
+int  y_header =		6;
+int  x_idlecursor =	0;
+int  y_idlecursor =	5;
+int  y_procs =		7;
+
+int  y_cpustates =	2;
+int  Header_lines =	7;
+
 int display_resize()
 
 {
@@ -138,6 +163,12 @@
 
     /* call resize to do the dirty work */
     lines = display_resize();
+    num_cpus = statics->ncpus;
+    cpustates_column = 5;	/* CPU: */
+    if (num_cpus != 1)
+    cpustates_column += 2;	/* CPU 0: */
+    for (i = num_cpus; i > 9; i /= 10)
+	cpustates_column++;
 
     /* only do the rest if we need to */
     if (lines > -1)
@@ -153,7 +184,7 @@
 	num_swap = string_count(swap_names);
 	lswap = (int *)malloc(num_swap * sizeof(int));
 	num_cpustates = string_count(cpustate_names);
-	lcpustates = (int *)malloc(num_cpustates * sizeof(int));
+	lcpustates = (int *)malloc(num_cpustates * sizeof(int) * num_cpus);
 	cpustate_columns = (int *)malloc(num_cpustates * sizeof(int));
 
 	memory_names = statics->memory_names;
@@ -365,14 +396,13 @@
     }
 }
 
+#ifdef no_more
 /*
  *  *_cpustates(states, names) - print the cpu state percentages
  *
  *  Assumptions:  cursor is on the PREVIOUS line
  */
 
-static int cpustates_column;
-
 /* cpustates_tag() calculates the correct tag to use to label the line */
 
 char *cpustates_tag()
@@ -398,6 +428,7 @@
     cpustates_column = strlen(use);
     return(use);
 }
+#endif
 
 i_cpustates(states)
 
@@ -406,11 +437,18 @@
 {
     register int i = 0;
     register int value;
-    register char **names = cpustate_names;
+    register char **names;
     register char *thisname;
+    int cpu;
+
+for (cpu = 0; cpu < num_cpus; cpu++) {
+    names = cpustate_names;
 
     /* print tag and bump lastline */
-    printf("\n%s", cpustates_tag());
+    if (num_cpus == 1)
+	printf("\nCPU: ");
+    else
+	printf("\nCPU %d: ", cpu);
     lastline++;
 
     /* now walk thru the names and print the line */
@@ -423,14 +461,15 @@
 
 	    /* if percentage is >= 1000, print it as 100% */
 	    printf((value >= 1000 ? "%s%4.0f%% %s" : "%s%4.1f%% %s"),
-		   i++ == 0 ? "" : ", ",
+		   (i++ % num_cpustates) == 0 ? "" : ", ",
 		   ((float)value)/10.,
 		   thisname);
 	}
     }
+}
 
     /* copy over values into "last" array */
-    memcpy(lcpustates, states, num_cpustates * sizeof(int));
+    memcpy(lcpustates, states, num_cpustates * sizeof(int) * num_cpus);
 }
 
 u_cpustates(states)
@@ -439,14 +478,18 @@
 
 {
     register int value;
-    register char **names = cpustate_names;
+    register char **names;
     register char *thisname;
     register int *lp;
     register int *colp;
+    int cpu;
+
+for (cpu = 0; cpu < num_cpus; cpu++) {
+    names = cpustate_names;
 
-    Move_to(cpustates_column, y_cpustates);
-    lastline = y_cpustates;
-    lp = lcpustates;
+    Move_to(cpustates_column, y_cpustates + cpu);
+    lastline = y_cpustates + cpu;
+    lp = lcpustates + (cpu * num_cpustates);
     colp = cpustate_columns;
 
     /* we could be much more optimal about this */
@@ -458,8 +501,8 @@
 	    if (*lp != *states)
 	    {
 		/* yes, move and change */
-		Move_to(cpustates_column + *colp, y_cpustates);
-		lastline = y_cpustates;
+		Move_to(cpustates_column + *colp, y_cpustates + cpu);
+		lastline = y_cpustates + cpu;
 
 		/* retrieve value and remember it */
 		value = *states;
@@ -479,30 +522,39 @@
 	colp++;
     }
 }
+}
 
 z_cpustates()
 
 {
     register int i = 0;
-    register char **names = cpustate_names;
+    register char **names;
     register char *thisname;
     register int *lp;
+    int cpu;
+
+for (cpu = 0; cpu < num_cpus; cpu++) {
+    names = cpustate_names;
 
     /* show tag and bump lastline */
-    printf("\n%s", cpustates_tag());
+    if (num_cpus == 1)
+	printf("\nCPU: ");
+    else
+	printf("\nCPU %d: ", cpu);
     lastline++;
 
     while ((thisname = *names++) != NULL)
     {
 	if (*thisname != '\0')
 	{
-	    printf("%s    %% %s", i++ == 0 ? "" : ", ", thisname);
+	    printf("%s    %% %s", (i++ % num_cpustates) == 0 ? "" : ", ", thisname);
 	}
     }
+}
 
     /* fill the "last" array with all -1s, to insure correct updating */
     lp = lcpustates;
-    i = num_cpustates;
+    i = num_cpustates * num_cpus;
     while (--i >= 0)
     {
 	*lp++ = -1;

==== //depot/projects/toehead/contrib/top/layout.h#2 (text+ko) ====

@@ -4,26 +4,28 @@
  *  This file defines the locations on tne screen for various parts of the
  *  display.  These definitions are used by the routines in "display.c" for
  *  cursor addressing.
+ *
+ * $FreeBSD: src/contrib/top/layout.h,v 1.3 2008/01/18 01:43:13 peter Exp $
  */
 
-#define  x_lastpid	10
-#define  y_lastpid	0
-#define  x_loadave	33
-#define  x_loadave_nompid	15
-#define  y_loadave	0
-#define  x_procstate	0
-#define  y_procstate	1
-#define  x_brkdn	15
-#define  y_brkdn	1
-#define  x_mem		5
-#define  y_mem		3
-#define  x_swap		6
-#define  y_swap		4
-#define  y_message	5
-#define  x_header	0
-#define  y_header	6
-#define  x_idlecursor	0
-#define  y_idlecursor	5
-#define  y_procs	7
+extern int  x_lastpid;		/* 10 */
+extern int  y_lastpid;		/* 0 */
+extern int  x_loadave;		/* 33 */
+extern int  x_loadave_nompid;	/* 15 */
+extern int  y_loadave;		/* 0 */
+extern int  x_procstate;	/* 0 */
+extern int  y_procstate;	/* 1 */
+extern int  x_brkdn;		/* 15 */
+extern int  y_brkdn;		/* 1 */
+extern int  x_mem;		/* 5 */
+extern int  y_mem;		/* 3 */
+extern int  x_swap;		/* 6 */
+extern int  y_swap;		/* 4 */
+extern int  y_message;		/* 5 */
+extern int  x_header;		/* 0 */
+extern int  y_header;		/* 6 */
+extern int  x_idlecursor;	/* 0 */
+extern int  y_idlecursor;	/* 5 */
+extern int  y_procs;		/* 7 */
 
-#define  y_cpustates	2
+extern int  y_cpustates;	/* 2 */

==== //depot/projects/toehead/contrib/top/machine.h#2 (text+ko) ====

@@ -1,5 +1,5 @@
 /*
- * $FreeBSD: src/contrib/top/machine.h,v 1.9 2007/05/04 15:42:58 rafan Exp $
+ * $FreeBSD: src/contrib/top/machine.h,v 1.10 2008/01/18 01:43:13 peter Exp $
  */
 
 /*
@@ -20,6 +20,7 @@
 #ifdef ORDER
     char **order_names;
 #endif
+    int ncpus;
 };
 
 /*
@@ -43,6 +44,8 @@
     int    *memory;
     int    *swap;
     struct timeval boottime;
+    unsigned long cpumask;	/* bitfield of cpu states represented */
+    int    ncpus;
 };
 
 /* cpu_states is an array of percentages * 10.  For example, 

==== //depot/projects/toehead/contrib/top/top.c#3 (text+ko) ====

@@ -13,7 +13,7 @@
  *  Copyright (c) 1994, 1995, William LeFebvre, Argonne National Laboratory
  *  Copyright (c) 1996, William LeFebvre, Group sys Consulting
  *
- * $FreeBSD: src/contrib/top/top.c,v 1.24 2008/01/09 18:06:24 obrien Exp $
+ * $FreeBSD: src/contrib/top/top.c,v 1.25 2008/01/18 01:43:13 peter Exp $
  */
 
 /*
@@ -66,6 +66,7 @@
 extern int overstrike;
 
 static int fmt_flags = 0;
+int pcpu_stats = No;
 
 /* signal handling routines */
 sigret_t leave();
@@ -282,7 +283,7 @@
 	    optind = 1;
 	}
 
-	while ((i = getopt(ac, av, "CSIHabijnquvs:d:U:m:o:t")) != EOF)
+	while ((i = getopt(ac, av, "CSIHPabijnpquvs:d:U:m:o:t")) != EOF)
 	{
 	    switch(i)
 	    {
@@ -407,6 +408,14 @@
 		ps.jail = !ps.jail;
 		break;
 
+	      case 'P':
+		pcpu_stats = Yes;
+		break;
+
+	      case 'p':
+		pcpu_stats = No;
+		break;
+
 	      default:
 		fprintf(stderr,
 "Top version %s\n"

==== //depot/projects/toehead/contrib/top/top.h#2 (text+ko) ====

@@ -1,5 +1,5 @@
 /*
- * $FreeBSD: src/contrib/top/top.h,v 1.4 2007/04/14 10:16:51 stas Exp $
+ * $FreeBSD: src/contrib/top/top.h,v 1.5 2008/01/18 01:43:13 peter Exp $
  */
 /*
  *  Top - a top users display for Berkeley Unix
@@ -11,7 +11,7 @@
 #define VERSION		3
 
 /* Number of lines of header information on the standard screen */
-#define Header_lines	7
+extern int Header_lines;	/* 7 */
 
 /* Maximum number of columns allowed for display */
 #define MAX_COLS	128
@@ -45,3 +45,5 @@
 #define FMT_SHOWARGS 0x00000001
 
 extern enum displaymodes displaymode;
+
+extern int pcpu_stats;

==== //depot/projects/toehead/gnu/usr.bin/gdb/kgdb/kgdb.h#2 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/gnu/usr.bin/gdb/kgdb/kgdb.h,v 1.6 2007/11/16 22:17:37 jhb Exp $
+ * $FreeBSD: src/gnu/usr.bin/gdb/kgdb/kgdb.h,v 1.7 2008/01/17 21:43:12 jhb Exp $
  */
 
 #ifndef _KGDB_H_
@@ -32,6 +32,7 @@
 struct thread_info;
 
 extern kvm_t *kvm;
+extern char *kernel;
 
 struct kthr {
 	struct kthr	*next;
@@ -63,5 +64,6 @@
 char        *kgdb_thr_extra_thread_info(int);
 
 uintptr_t kgdb_lookup(const char *sym);
+CORE_ADDR kgdb_parse(const char *exp);
 
 #endif /* _KGDB_H_ */

==== //depot/projects/toehead/gnu/usr.bin/gdb/kgdb/kthr.c#2 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.8 2007/11/16 22:17:37 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.9 2008/01/18 18:57:27 emaste Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -36,6 +36,7 @@
 #include <kvm.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <defs.h>
 #include <frame-unwind.h>
@@ -204,17 +205,26 @@
 char *
 kgdb_thr_extra_thread_info(int tid)
 {
+	char comm[MAXCOMLEN + 1];
+	char td_name[MAXCOMLEN + 1];
 	struct kthr *kt;
 	struct proc *p;
-	static char comm[MAXCOMLEN + 1];
+	struct thread *t;
+	static char info[MAXCOMLEN + 1 + MAXCOMLEN + 1];
 
 	kt = kgdb_thr_lookup_tid(tid);
 	if (kt == NULL)
 		return (NULL);
 	p = (struct proc *)kt->paddr;
+	t = (struct thread *)kt->kaddr;
 	if (kvm_read(kvm, (uintptr_t)&p->p_comm[0], &comm, sizeof(comm)) !=
 	    sizeof(comm))
 		return (NULL);
-
-	return (comm);
+	if (kvm_read(kvm, (uintptr_t)&t->td_name[0], &td_name,
+	    sizeof(td_name)) == sizeof(td_name) &&
+	    strcmp(comm, td_name) != 0)
+		snprintf(info, sizeof(info), "%s/%s", comm, td_name);
+	else
+		strlcpy(info, comm, sizeof(info));
+	return (info);
 }

==== //depot/projects/toehead/gnu/usr.bin/gdb/kgdb/main.c#2 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/main.c,v 1.11 2006/01/04 23:17:52 kan Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/main.c,v 1.12 2008/01/17 21:43:12 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/stat.h>
@@ -75,7 +75,7 @@
 static int verbose;
 
 static char crashdir[PATH_MAX];
-static char *kernel;
+char *kernel;
 static char *remote;
 static char *vmcore;
 
@@ -178,7 +178,7 @@
 		kgdb_new_objfile_chain(objfile);
 }
 
-static CORE_ADDR
+CORE_ADDR
 kgdb_parse(const char *exp)
 {
 	struct cleanup *old_chain;

==== //depot/projects/toehead/gnu/usr.bin/gdb/kgdb/trgt.c#2 (text+ko) ====

@@ -25,13 +25,16 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt.c,v 1.5 2006/10/16 20:06:32 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt.c,v 1.6 2008/01/17 21:43:12 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
+#include <sys/stat.h>
 #include <sys/sysctl.h>
 #include <sys/user.h>
+#include <libgen.h>
 #include <kvm.h>
+#include <string.h>
 
 #include <defs.h>
 #include <command.h>
@@ -40,6 +43,9 @@
 #include <inferior.h>
 #include <regcache.h>
 #include <target.h>
+#include <objfiles.h>
+#include <gdbcore.h>
+#include <language.h>
 
 #include "kgdb.h"
 
@@ -199,6 +205,268 @@
 	kgdb_switch_to_thread(thr);
 }
 
+static int
+kld_ok (char *path)
+{
+	struct stat sb;
+
+	if (stat(path, &sb) == 0 && S_ISREG(sb.st_mode))
+		return (1);
+	return (0);
+}
+
+/*
+ * Look for a matching file in the following order:
+ * - filename + ".symbols" (e.g. foo.ko.symbols)
+ * - filename + ".debug" (e.g. foo.ko.debug)
+ * - filename (e.g. foo.ko)
+ * - dirname(kernel) + filename + ".symbols" (e.g. /boot/kernel/foo.ko.symbols)
+ * - dirname(kernel) + filename + ".debug" (e.g. /boot/kernel/foo.ko.debug)
+ * - dirname(kernel) + filename (e.g. /boot/kernel/foo.ko)
+ * - iterate over each path in the module path looking for:
+ *   - dir + filename + ".symbols" (e.g. /boot/modules/foo.ko.symbols)
+ *   - dir + filename + ".debug" (e.g. /boot/modules/foo.ko.debug)
+ *   - dir + filename (e.g. /boot/modules/foo.ko)
+ */
+static int
+find_kld_path (char *filename, char *path, size_t path_size)
+{
+	CORE_ADDR module_path_addr;
+	char module_path[PATH_MAX];
+	char *kernel_dir, *module_dir, *cp;
+
+	snprintf(path, path_size, "%s.symbols", filename);
+	if (kld_ok(path))
+		return (1);
+	snprintf(path, path_size, "%s.debug", filename);
+	if (kld_ok(path))
+		return (1);
+	snprintf(path, path_size, "%s", filename);
+	if (kld_ok(path))
+		return (1);
+	kernel_dir = dirname(kernel);
+	if (kernel_dir != NULL) {
+		snprintf(path, path_size, "%s/%s.symbols", kernel_dir,
+		    filename);
+		if (kld_ok(path))
+			return (1);
+		snprintf(path, path_size, "%s/%s.debug", kernel_dir, filename);
+		if (kld_ok(path))
+			return (1);
+		snprintf(path, path_size, "%s/%s", kernel_dir, filename);
+		if (kld_ok(path))
+			return (1);
+	}
+	module_path_addr = kgdb_parse("linker_path");
+	if (module_path_addr != 0 &&
+	    kvm_read(kvm, module_path_addr, module_path, sizeof(module_path)) ==
+	    sizeof(module_path)) {
+		module_path[PATH_MAX - 1] = '\0';
+		cp = module_path;
+		while ((module_dir = strsep(&cp, ";")) != NULL) {
+			snprintf(path, path_size, "%s/%s.symbols", module_dir,
+			    filename);
+			if (kld_ok(path))
+				return (1);
+			snprintf(path, path_size, "%s/%s.debug", module_dir,
+			    filename);
+			if (kld_ok(path))
+				return (1);
+			snprintf(path, path_size, "%s/%s", module_dir,
+			    filename);
+			if (kld_ok(path))
+				return (1);			
+		}
+	}	
+	return (0);
+}
+
+/*
+ * Read a kernel pointer given a KVA in 'address'.
+ */
+static CORE_ADDR
+read_pointer (CORE_ADDR address)
+{
+	union {
+		uint32_t d32;
+		uint64_t d64;
+	} val;
+
+	switch (TARGET_PTR_BIT) {
+	case 32:
+		if (kvm_read(kvm, address, &val.d32, sizeof(val.d32)) !=
+		    sizeof(val.d32))
+			return (0);
+		return (val.d32);
+	case 64:
+		if (kvm_read(kvm, address, &val.d64, sizeof(val.d64)) !=
+		    sizeof(val.d64))
+			return (0);
+		return (val.d64);
+	default:
+		return (0);
+	}
+}
+
+/*
+ * Try to find this kld in the kernel linker's list of linker files.
+ */
+static int
+find_kld_address (char *arg, CORE_ADDR *address)
+{
+	CORE_ADDR kld, filename_addr;
+	CORE_ADDR off_address, off_filename, off_next;
+	char kld_filename[PATH_MAX];
+	char *filename;
+	size_t filelen;
+
+	/* Compute offsets of relevant members in struct linker_file. */
+	off_address = kgdb_parse("&((struct linker_file *)0)->address");
+	off_filename = kgdb_parse("&((struct linker_file *)0)->filename");
+	off_next = kgdb_parse("&((struct linker_file *)0)->link.tqe_next");
+	if (off_address == 0 || off_filename == 0 || off_next == 0)
+		return (0);
+
+	filename = basename(arg);
+	filelen = strlen(filename) + 1;
+	kld = kgdb_parse("linker_files.tqh_first");
+	while (kld != 0) {
+		/* Try to read this linker file's filename. */
+		filename_addr = read_pointer(kld + off_filename);
+		if (filename_addr == 0)
+			goto next_kld;
+		if (kvm_read(kvm, filename_addr, kld_filename, filelen) !=
+		    filelen)
+			goto next_kld;
+
+		/* Compare this kld's filename against our passed in name. */
+		if (kld_filename[filelen - 1] != '\0')
+			goto next_kld;
+		if (strcmp(kld_filename, filename) != 0)
+			goto next_kld;
+
+		/*
+		 * We found a match, use its address as the base
+		 * address if we can read it.
+		 */
+		*address = read_pointer(kld + off_address);
+		if (*address == 0)
+			return (0);
+		return (1);
+
+	next_kld:
+		kld = read_pointer(kld + off_next);
+	}
+	return (0);
+}
+
+static void
+add_section(struct section_addr_info *section_addrs, int *sect_indexp,
+    char *name, CORE_ADDR address)
+{
+	int sect_index;
+
+	sect_index = *sect_indexp;
+	section_addrs->other[sect_index].name = name;
+	section_addrs->other[sect_index].addr = address;
+	printf_unfiltered("\t%s_addr = %s\n", name,
+	    local_hex_string(address));
+	sect_index++;
+	*sect_indexp = sect_index;
+}
+
+static void
+kgdb_add_kld_cmd (char *arg, int from_tty)
+{
+	struct section_addr_info *section_addrs;
+	struct cleanup *cleanup;
+	char path[PATH_MAX];
+	asection *sect;
+	CORE_ADDR base_addr;
+	bfd *bfd;
+	CORE_ADDR text_addr, data_addr, bss_addr, rodata_addr;
+	int sect_count, sect_index;
+
+	if (!find_kld_path(arg, path, sizeof(path))) {
+		error("unable to locate kld");
+		return;
+	}
+
+	if (!find_kld_address(arg, &base_addr)) {
+		error("unable to find kld in kernel");
+		return;
+	}
+
+	/* Open the kld and find the offsets of the various sections. */
+	bfd = bfd_openr(path, gnutarget);
+	if (bfd == NULL) {
+		error("\"%s\": can't open: %s", path,
+		    bfd_errmsg(bfd_get_error()));
+		return;
+	}
+	cleanup = make_cleanup_bfd_close(bfd);
+
+	if (!bfd_check_format(bfd, bfd_object)) {
+		do_cleanups(cleanup);
+		error("\%s\": not an object file", path);
+		return;
+	}
+
+	data_addr = bss_addr = rodata_addr = 0;
+	sect = bfd_get_section_by_name (bfd, ".text");
+	if (sect == NULL) {
+		do_cleanups(cleanup);
+		error("\"%s\": can't find text section", path);
+		return;
+	}
+	text_addr = bfd_get_section_vma(bfd, sect);
+	sect_count = 1;
+
+	/* Save the offsets of relevant sections. */
+	sect = bfd_get_section_by_name (bfd, ".data");
+	if (sect != NULL) {
+		data_addr = bfd_get_section_vma(bfd, sect);
+		sect_count++;
+	}
+
+	sect = bfd_get_section_by_name (bfd, ".bss");
+	if (sect != NULL) {
+		bss_addr = bfd_get_section_vma(bfd, sect);
+		sect_count++;
+	}
+
+	sect = bfd_get_section_by_name (bfd, ".rodata");
+	if (sect != NULL) {
+		rodata_addr = bfd_get_section_vma(bfd, sect);
+		sect_count++;
+	}
+
+	do_cleanups(cleanup);
+
+	printf_unfiltered("add symbol table from file \"%s\" at\n", path);
+
+	/* Build a section table for symbol_file_add(). */
+	section_addrs = alloc_section_addr_info(sect_count);
+	cleanup = make_cleanup(xfree, section_addrs);
+	sect_index = 0;
+	add_section(section_addrs, &sect_index, ".text", base_addr + text_addr);
+	if (data_addr != 0)
+		add_section(section_addrs, &sect_index, ".data",
+		    base_addr + data_addr);
+	if (bss_addr != 0)
+		add_section(section_addrs, &sect_index, ".bss",
+		    base_addr + bss_addr);
+	if (rodata_addr != 0)
+		add_section(section_addrs, &sect_index, ".rodata",
+		    base_addr + rodata_addr);
+
+	symbol_file_add(path, from_tty, section_addrs, 0, OBJF_USERLOADED);
+
+	reinit_frame_cache();
+
+	do_cleanups(cleanup);
+}
+
 void
 kgdb_target(void)
 {
@@ -236,4 +504,7 @@
 	   "Set current process context");
 	add_com ("tid", class_obscure, kgdb_set_tid_cmd,
 	   "Set current thread context");
+	add_com ("add-kld", class_files, kgdb_add_kld_cmd,
+	   "Usage: add-kld FILE\n\
+Load the symbols from the kernel loadable module FILE.");
 }

==== //depot/projects/toehead/include/unistd.h#3 (text+ko) ====

@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)unistd.h	8.12 (Berkeley) 4/27/95
- * $FreeBSD: src/include/unistd.h,v 1.81 2008/01/10 22:11:20 jhb Exp $
+ * $FreeBSD: src/include/unistd.h,v 1.82 2008/01/18 08:48:32 davidxu Exp $
  */
 
 #ifndef _UNISTD_H_
@@ -111,7 +111,7 @@
 #define	_POSIX_SPIN_LOCKS		200112L
 #define	_POSIX_THREAD_ATTR_STACKADDR	200112L
 #define	_POSIX_THREAD_ATTR_STACKSIZE	200112L
-#define	_POSIX_THREAD_CPUTIME		-1
+#define	_POSIX_THREAD_CPUTIME		200112L
 #define	_POSIX_THREAD_PRIO_INHERIT	200112L
 #define	_POSIX_THREAD_PRIO_PROTECT	200112L
 #define	_POSIX_THREAD_PRIORITY_SCHEDULING 200112L

==== //depot/projects/toehead/lib/libarchive/archive_read_extract.c#2 (text+ko) ====

@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.59 2007/05/29 01:00:18 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.60 2008/01/18 04:53:45 kientzle Exp $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -67,6 +67,7 @@
 			archive_set_error(&a->archive, ENOMEM, "Can't extract");
 			return (NULL);
 		}
+		memset(a->extract, 0, sizeof(*a->extract));
 		a->extract->ad = archive_write_disk_new();
 		if (a->extract->ad == NULL) {
 			archive_set_error(&a->archive, ENOMEM, "Can't extract");
@@ -130,11 +131,13 @@
 static int
 copy_data(struct archive *ar, struct archive *aw)
 {
-	int r;
+	off_t offset;
 	const void *buff;
+	struct extract *extract;
 	size_t size;
-	off_t offset;
+	int r;
 
+	extract = get_extract((struct archive_read *)ar);
 	for (;;) {
 		r = archive_read_data_block(ar, &buff, &size, &offset);
 		if (r == ARCHIVE_EOF)
@@ -149,6 +152,9 @@
 			    "%s", archive_error_string(aw));
 			return (r);
 		}
+		if (extract->extract_progress)
+			(extract->extract_progress)
+			    (extract->extract_progress_user_data);
 	}
 }
 

==== //depot/projects/toehead/lib/libarchive/archive_write_disk.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.18 2007/12/30 04:58:21 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.21 2008/01/18 06:16:08 kientzle Exp $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -171,6 +171,8 @@
 	int			 fd;
 	/* Current offset for writing data to the file. */
 	off_t			 offset;
+	/* Maximum size of file. */
+	off_t			 filesize;
 	/* Dir we were in before this restore; only for deep paths. */
 	int			 restore_pwd;
 	/* Mode we should use for this entry; affected by _PERM and umask. */
@@ -302,6 +304,7 @@
 	a->offset = 0;
 	a->uid = a->user_uid;
 	a->mode = archive_entry_mode(a->entry);
+	a->filesize = archive_entry_size(a->entry);
 	archive_strcpy(&(a->_name_data), archive_entry_pathname(a->entry));
 	a->name = a->_name_data.s;
 	archive_clear_error(&a->archive);
@@ -425,8 +428,10 @@
 	 * If it's not open, tell our client not to try writing.
 	 * In particular, dirs, links, etc, don't get written to.
 	 */
-	if (a->fd < 0)
+	if (a->fd < 0) {
 		archive_entry_set_size(entry, 0);
+		a->filesize = 0;
+	}
 done:
 	/* Restore the user's umask before returning. */
 	umask(a->user_umask);
@@ -451,6 +456,7 @@
 {
 	struct archive_write_disk *a = (struct archive_write_disk *)_a;
 	ssize_t bytes_written = 0;
+	int r = ARCHIVE_OK;
 
 	__archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
 	    ARCHIVE_STATE_DATA, "archive_write_disk_block");
@@ -470,7 +476,13 @@
 	}

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801192337.m0JNbKZe005252>