xref: /freebsd/sys/ddb/db_break.c (revision 25eb640d903b24d954e620b6596ac5d57bf375ce)
15b81b6b3SRodney W. Grimes /*
25b81b6b3SRodney W. Grimes  * Mach Operating System
35b81b6b3SRodney W. Grimes  * Copyright (c) 1991,1990 Carnegie Mellon University
45b81b6b3SRodney W. Grimes  * All Rights Reserved.
55b81b6b3SRodney W. Grimes  *
65b81b6b3SRodney W. Grimes  * Permission to use, copy, modify and distribute this software and its
75b81b6b3SRodney W. Grimes  * documentation is hereby granted, provided that both the copyright
85b81b6b3SRodney W. Grimes  * notice and this permission notice appear in all copies of the
95b81b6b3SRodney W. Grimes  * software, derivative works or modified versions, and any portions
105b81b6b3SRodney W. Grimes  * thereof, and that both notices appear in supporting documentation.
115b81b6b3SRodney W. Grimes  *
125b81b6b3SRodney W. Grimes  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
135b81b6b3SRodney W. Grimes  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
145b81b6b3SRodney W. Grimes  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
155b81b6b3SRodney W. Grimes  *
165b81b6b3SRodney W. Grimes  * Carnegie Mellon requests users of this software to return to
175b81b6b3SRodney W. Grimes  *
185b81b6b3SRodney W. Grimes  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
195b81b6b3SRodney W. Grimes  *  School of Computer Science
205b81b6b3SRodney W. Grimes  *  Carnegie Mellon University
215b81b6b3SRodney W. Grimes  *  Pittsburgh PA 15213-3890
225b81b6b3SRodney W. Grimes  *
235b81b6b3SRodney W. Grimes  * any improvements or extensions that they make and grant Carnegie the
245b81b6b3SRodney W. Grimes  * rights to redistribute these changes.
250edf66ecSRodney W. Grimes  *
2625eb640dSPoul-Henning Kamp  *	$Id: db_break.c,v 1.9 1995/12/07 12:44:46 davidg Exp $
275b81b6b3SRodney W. Grimes  */
280edf66ecSRodney W. Grimes 
295b81b6b3SRodney W. Grimes /*
305b81b6b3SRodney W. Grimes  *	Author: David B. Golub, Carnegie Mellon University
315b81b6b3SRodney W. Grimes  *	Date:	7/90
325b81b6b3SRodney W. Grimes  */
335b81b6b3SRodney W. Grimes /*
345b81b6b3SRodney W. Grimes  * Breakpoints.
355b81b6b3SRodney W. Grimes  */
36f540b106SGarrett Wollman #include <sys/param.h>
37f540b106SGarrett Wollman #include <sys/systm.h>
38f540b106SGarrett Wollman #include <sys/proc.h>
39efeaf95aSDavid Greenman #include <vm/vm.h>
40efeaf95aSDavid Greenman #include <vm/vm_param.h>
41f540b106SGarrett Wollman #include <ddb/ddb.h>
425b81b6b3SRodney W. Grimes 
435b81b6b3SRodney W. Grimes #include <ddb/db_lex.h>
445b81b6b3SRodney W. Grimes #include <ddb/db_break.h>
455b81b6b3SRodney W. Grimes #include <ddb/db_access.h>
465b81b6b3SRodney W. Grimes #include <ddb/db_sym.h>
475b81b6b3SRodney W. Grimes 
485b81b6b3SRodney W. Grimes #define	NBREAKPOINTS	100
4925eb640dSPoul-Henning Kamp static struct db_breakpoint	db_break_table[NBREAKPOINTS];
50f73a856dSPoul-Henning Kamp static db_breakpoint_t		db_next_free_breakpoint = &db_break_table[0];
51f73a856dSPoul-Henning Kamp static db_breakpoint_t		db_free_breakpoints = 0;
52f73a856dSPoul-Henning Kamp static db_breakpoint_t		db_breakpoint_list = 0;
535b81b6b3SRodney W. Grimes 
54f73a856dSPoul-Henning Kamp static db_breakpoint_t	db_breakpoint_alloc __P((void));
55f73a856dSPoul-Henning Kamp static void	db_breakpoint_free __P((db_breakpoint_t bkpt));
56f73a856dSPoul-Henning Kamp static void	db_delete_breakpoint __P((vm_map_t map, db_addr_t addr));
57f73a856dSPoul-Henning Kamp static db_breakpoint_t	db_find_breakpoint __P((vm_map_t map, db_addr_t addr));
58f73a856dSPoul-Henning Kamp static void	db_list_breakpoints __P((void));
59f73a856dSPoul-Henning Kamp static void	db_set_breakpoint __P((vm_map_t map, db_addr_t addr,
60f73a856dSPoul-Henning Kamp 				       int count));
61f73a856dSPoul-Henning Kamp #ifdef notused
62f73a856dSPoul-Henning Kamp static db_breakpoint_t	db_set_temp_breakpoint __P((db_addr_t addr));
63f73a856dSPoul-Henning Kamp static void	db_delete_temp_breakpoint __P((db_breakpoint_t bkpt));
64f73a856dSPoul-Henning Kamp #endif
65f73a856dSPoul-Henning Kamp 
66f73a856dSPoul-Henning Kamp static db_breakpoint_t
675b81b6b3SRodney W. Grimes db_breakpoint_alloc()
685b81b6b3SRodney W. Grimes {
695b81b6b3SRodney W. Grimes 	register db_breakpoint_t	bkpt;
705b81b6b3SRodney W. Grimes 
715b81b6b3SRodney W. Grimes 	if ((bkpt = db_free_breakpoints) != 0) {
725b81b6b3SRodney W. Grimes 	    db_free_breakpoints = bkpt->link;
735b81b6b3SRodney W. Grimes 	    return (bkpt);
745b81b6b3SRodney W. Grimes 	}
755b81b6b3SRodney W. Grimes 	if (db_next_free_breakpoint == &db_break_table[NBREAKPOINTS]) {
765b81b6b3SRodney W. Grimes 	    db_printf("All breakpoints used.\n");
775b81b6b3SRodney W. Grimes 	    return (0);
785b81b6b3SRodney W. Grimes 	}
795b81b6b3SRodney W. Grimes 	bkpt = db_next_free_breakpoint;
805b81b6b3SRodney W. Grimes 	db_next_free_breakpoint++;
815b81b6b3SRodney W. Grimes 
825b81b6b3SRodney W. Grimes 	return (bkpt);
835b81b6b3SRodney W. Grimes }
845b81b6b3SRodney W. Grimes 
85f73a856dSPoul-Henning Kamp static void
865b81b6b3SRodney W. Grimes db_breakpoint_free(bkpt)
875b81b6b3SRodney W. Grimes 	register db_breakpoint_t	bkpt;
885b81b6b3SRodney W. Grimes {
895b81b6b3SRodney W. Grimes 	bkpt->link = db_free_breakpoints;
905b81b6b3SRodney W. Grimes 	db_free_breakpoints = bkpt;
915b81b6b3SRodney W. Grimes }
925b81b6b3SRodney W. Grimes 
93f73a856dSPoul-Henning Kamp static void
945b81b6b3SRodney W. Grimes db_set_breakpoint(map, addr, count)
955b81b6b3SRodney W. Grimes 	vm_map_t	map;
965b81b6b3SRodney W. Grimes 	db_addr_t	addr;
975b81b6b3SRodney W. Grimes 	int		count;
985b81b6b3SRodney W. Grimes {
995b81b6b3SRodney W. Grimes 	register db_breakpoint_t	bkpt;
1005b81b6b3SRodney W. Grimes 
1015b81b6b3SRodney W. Grimes 	if (db_find_breakpoint(map, addr)) {
1025b81b6b3SRodney W. Grimes 	    db_printf("Already set.\n");
1035b81b6b3SRodney W. Grimes 	    return;
1045b81b6b3SRodney W. Grimes 	}
1055b81b6b3SRodney W. Grimes 
1065b81b6b3SRodney W. Grimes 	bkpt = db_breakpoint_alloc();
1075b81b6b3SRodney W. Grimes 	if (bkpt == 0) {
1085b81b6b3SRodney W. Grimes 	    db_printf("Too many breakpoints.\n");
1095b81b6b3SRodney W. Grimes 	    return;
1105b81b6b3SRodney W. Grimes 	}
1115b81b6b3SRodney W. Grimes 
1125b81b6b3SRodney W. Grimes 	bkpt->map = map;
1135b81b6b3SRodney W. Grimes 	bkpt->address = addr;
1145b81b6b3SRodney W. Grimes 	bkpt->flags = 0;
1155b81b6b3SRodney W. Grimes 	bkpt->init_count = count;
1165b81b6b3SRodney W. Grimes 	bkpt->count = count;
1175b81b6b3SRodney W. Grimes 
1185b81b6b3SRodney W. Grimes 	bkpt->link = db_breakpoint_list;
1195b81b6b3SRodney W. Grimes 	db_breakpoint_list = bkpt;
1205b81b6b3SRodney W. Grimes }
1215b81b6b3SRodney W. Grimes 
122f73a856dSPoul-Henning Kamp static void
1235b81b6b3SRodney W. Grimes db_delete_breakpoint(map, addr)
1245b81b6b3SRodney W. Grimes 	vm_map_t	map;
1255b81b6b3SRodney W. Grimes 	db_addr_t	addr;
1265b81b6b3SRodney W. Grimes {
1275b81b6b3SRodney W. Grimes 	register db_breakpoint_t	bkpt;
1285b81b6b3SRodney W. Grimes 	register db_breakpoint_t	*prev;
1295b81b6b3SRodney W. Grimes 
1305b81b6b3SRodney W. Grimes 	for (prev = &db_breakpoint_list;
1315b81b6b3SRodney W. Grimes 	     (bkpt = *prev) != 0;
1325b81b6b3SRodney W. Grimes 	     prev = &bkpt->link) {
1335b81b6b3SRodney W. Grimes 	    if (db_map_equal(bkpt->map, map) &&
1345b81b6b3SRodney W. Grimes 		(bkpt->address == addr)) {
1355b81b6b3SRodney W. Grimes 		*prev = bkpt->link;
1365b81b6b3SRodney W. Grimes 		break;
1375b81b6b3SRodney W. Grimes 	    }
1385b81b6b3SRodney W. Grimes 	}
1395b81b6b3SRodney W. Grimes 	if (bkpt == 0) {
1405b81b6b3SRodney W. Grimes 	    db_printf("Not set.\n");
1415b81b6b3SRodney W. Grimes 	    return;
1425b81b6b3SRodney W. Grimes 	}
1435b81b6b3SRodney W. Grimes 
1445b81b6b3SRodney W. Grimes 	db_breakpoint_free(bkpt);
1455b81b6b3SRodney W. Grimes }
1465b81b6b3SRodney W. Grimes 
147f73a856dSPoul-Henning Kamp static db_breakpoint_t
1485b81b6b3SRodney W. Grimes db_find_breakpoint(map, addr)
1495b81b6b3SRodney W. Grimes 	vm_map_t	map;
1505b81b6b3SRodney W. Grimes 	db_addr_t	addr;
1515b81b6b3SRodney W. Grimes {
1525b81b6b3SRodney W. Grimes 	register db_breakpoint_t	bkpt;
1535b81b6b3SRodney W. Grimes 
1545b81b6b3SRodney W. Grimes 	for (bkpt = db_breakpoint_list;
1555b81b6b3SRodney W. Grimes 	     bkpt != 0;
1565b81b6b3SRodney W. Grimes 	     bkpt = bkpt->link)
1575b81b6b3SRodney W. Grimes 	{
1585b81b6b3SRodney W. Grimes 	    if (db_map_equal(bkpt->map, map) &&
1595b81b6b3SRodney W. Grimes 		(bkpt->address == addr))
1605b81b6b3SRodney W. Grimes 		return (bkpt);
1615b81b6b3SRodney W. Grimes 	}
1625b81b6b3SRodney W. Grimes 	return (0);
1635b81b6b3SRodney W. Grimes }
1645b81b6b3SRodney W. Grimes 
1655b81b6b3SRodney W. Grimes db_breakpoint_t
1665b81b6b3SRodney W. Grimes db_find_breakpoint_here(addr)
1675b81b6b3SRodney W. Grimes 	db_addr_t	addr;
1685b81b6b3SRodney W. Grimes {
1695b81b6b3SRodney W. Grimes     return db_find_breakpoint(db_map_addr(addr), addr);
1705b81b6b3SRodney W. Grimes }
1715b81b6b3SRodney W. Grimes 
172f73a856dSPoul-Henning Kamp static boolean_t	db_breakpoints_inserted = TRUE;
1735b81b6b3SRodney W. Grimes 
1745b81b6b3SRodney W. Grimes void
1755b81b6b3SRodney W. Grimes db_set_breakpoints()
1765b81b6b3SRodney W. Grimes {
1775b81b6b3SRodney W. Grimes 	register db_breakpoint_t	bkpt;
1785b81b6b3SRodney W. Grimes 
1795b81b6b3SRodney W. Grimes 	if (!db_breakpoints_inserted) {
1805b81b6b3SRodney W. Grimes 
1815b81b6b3SRodney W. Grimes 	    for (bkpt = db_breakpoint_list;
1825b81b6b3SRodney W. Grimes 	         bkpt != 0;
1835b81b6b3SRodney W. Grimes 	         bkpt = bkpt->link)
1845b81b6b3SRodney W. Grimes 		if (db_map_current(bkpt->map)) {
1855b81b6b3SRodney W. Grimes 		    bkpt->bkpt_inst = db_get_value(bkpt->address,
1865b81b6b3SRodney W. Grimes 						   BKPT_SIZE,
1875b81b6b3SRodney W. Grimes 						   FALSE);
1885b81b6b3SRodney W. Grimes 		    db_put_value(bkpt->address,
1895b81b6b3SRodney W. Grimes 				 BKPT_SIZE,
1905b81b6b3SRodney W. Grimes 				 BKPT_SET(bkpt->bkpt_inst));
1915b81b6b3SRodney W. Grimes 		}
1925b81b6b3SRodney W. Grimes 	    db_breakpoints_inserted = TRUE;
1935b81b6b3SRodney W. Grimes 	}
1945b81b6b3SRodney W. Grimes }
1955b81b6b3SRodney W. Grimes 
1965b81b6b3SRodney W. Grimes void
1975b81b6b3SRodney W. Grimes db_clear_breakpoints()
1985b81b6b3SRodney W. Grimes {
1995b81b6b3SRodney W. Grimes 	register db_breakpoint_t	bkpt;
2005b81b6b3SRodney W. Grimes 
2015b81b6b3SRodney W. Grimes 	if (db_breakpoints_inserted) {
2025b81b6b3SRodney W. Grimes 
2035b81b6b3SRodney W. Grimes 	    for (bkpt = db_breakpoint_list;
2045b81b6b3SRodney W. Grimes 	         bkpt != 0;
2055b81b6b3SRodney W. Grimes 		 bkpt = bkpt->link)
2065b81b6b3SRodney W. Grimes 		if (db_map_current(bkpt->map)) {
2075b81b6b3SRodney W. Grimes 		    db_put_value(bkpt->address, BKPT_SIZE, bkpt->bkpt_inst);
2085b81b6b3SRodney W. Grimes 		}
2095b81b6b3SRodney W. Grimes 	    db_breakpoints_inserted = FALSE;
2105b81b6b3SRodney W. Grimes 	}
2115b81b6b3SRodney W. Grimes }
2125b81b6b3SRodney W. Grimes 
213f73a856dSPoul-Henning Kamp #ifdef notused
2145b81b6b3SRodney W. Grimes /*
2155b81b6b3SRodney W. Grimes  * Set a temporary breakpoint.
2165b81b6b3SRodney W. Grimes  * The instruction is changed immediately,
2175b81b6b3SRodney W. Grimes  * so the breakpoint does not have to be on the breakpoint list.
2185b81b6b3SRodney W. Grimes  */
219f73a856dSPoul-Henning Kamp static db_breakpoint_t
2205b81b6b3SRodney W. Grimes db_set_temp_breakpoint(addr)
2215b81b6b3SRodney W. Grimes 	db_addr_t	addr;
2225b81b6b3SRodney W. Grimes {
2235b81b6b3SRodney W. Grimes 	register db_breakpoint_t	bkpt;
2245b81b6b3SRodney W. Grimes 
2255b81b6b3SRodney W. Grimes 	bkpt = db_breakpoint_alloc();
2265b81b6b3SRodney W. Grimes 	if (bkpt == 0) {
2275b81b6b3SRodney W. Grimes 	    db_printf("Too many breakpoints.\n");
2285b81b6b3SRodney W. Grimes 	    return 0;
2295b81b6b3SRodney W. Grimes 	}
2305b81b6b3SRodney W. Grimes 
2315b81b6b3SRodney W. Grimes 	bkpt->map = NULL;
2325b81b6b3SRodney W. Grimes 	bkpt->address = addr;
2335b81b6b3SRodney W. Grimes 	bkpt->flags = BKPT_TEMP;
2345b81b6b3SRodney W. Grimes 	bkpt->init_count = 1;
2355b81b6b3SRodney W. Grimes 	bkpt->count = 1;
2365b81b6b3SRodney W. Grimes 
2375b81b6b3SRodney W. Grimes 	bkpt->bkpt_inst = db_get_value(bkpt->address, BKPT_SIZE, FALSE);
2385b81b6b3SRodney W. Grimes 	db_put_value(bkpt->address, BKPT_SIZE, BKPT_SET(bkpt->bkpt_inst));
2395b81b6b3SRodney W. Grimes 	return bkpt;
2405b81b6b3SRodney W. Grimes }
2415b81b6b3SRodney W. Grimes 
242f73a856dSPoul-Henning Kamp static void
2435b81b6b3SRodney W. Grimes db_delete_temp_breakpoint(bkpt)
2445b81b6b3SRodney W. Grimes 	db_breakpoint_t	bkpt;
2455b81b6b3SRodney W. Grimes {
2465b81b6b3SRodney W. Grimes 	db_put_value(bkpt->address, BKPT_SIZE, bkpt->bkpt_inst);
2475b81b6b3SRodney W. Grimes 	db_breakpoint_free(bkpt);
2485b81b6b3SRodney W. Grimes }
249f73a856dSPoul-Henning Kamp #endif
2505b81b6b3SRodney W. Grimes 
2515b81b6b3SRodney W. Grimes /*
2525b81b6b3SRodney W. Grimes  * List breakpoints.
2535b81b6b3SRodney W. Grimes  */
254f73a856dSPoul-Henning Kamp static void
2555b81b6b3SRodney W. Grimes db_list_breakpoints()
2565b81b6b3SRodney W. Grimes {
2575b81b6b3SRodney W. Grimes 	register db_breakpoint_t	bkpt;
2585b81b6b3SRodney W. Grimes 
2595b81b6b3SRodney W. Grimes 	if (db_breakpoint_list == 0) {
2605b81b6b3SRodney W. Grimes 	    db_printf("No breakpoints set\n");
2615b81b6b3SRodney W. Grimes 	    return;
2625b81b6b3SRodney W. Grimes 	}
2635b81b6b3SRodney W. Grimes 
2645b81b6b3SRodney W. Grimes 	db_printf(" Map      Count    Address\n");
2655b81b6b3SRodney W. Grimes 	for (bkpt = db_breakpoint_list;
2665b81b6b3SRodney W. Grimes 	     bkpt != 0;
2675b81b6b3SRodney W. Grimes 	     bkpt = bkpt->link)
2685b81b6b3SRodney W. Grimes 	{
2695b81b6b3SRodney W. Grimes 	    db_printf("%s%8x %5d    ",
2705b81b6b3SRodney W. Grimes 		      db_map_current(bkpt->map) ? "*" : " ",
2715b81b6b3SRodney W. Grimes 		      bkpt->map, bkpt->init_count);
2725b81b6b3SRodney W. Grimes 	    db_printsym(bkpt->address, DB_STGY_PROC);
2735b81b6b3SRodney W. Grimes 	    db_printf("\n");
2745b81b6b3SRodney W. Grimes 	}
2755b81b6b3SRodney W. Grimes }
2765b81b6b3SRodney W. Grimes 
2775b81b6b3SRodney W. Grimes /* Delete breakpoint */
2785b81b6b3SRodney W. Grimes /*ARGSUSED*/
2795b81b6b3SRodney W. Grimes void
2805b81b6b3SRodney W. Grimes db_delete_cmd(addr, have_addr, count, modif)
2815b81b6b3SRodney W. Grimes 	db_expr_t	addr;
282058284fcSBruce Evans 	boolean_t	have_addr;
2835b81b6b3SRodney W. Grimes 	db_expr_t	count;
2845b81b6b3SRodney W. Grimes 	char *		modif;
2855b81b6b3SRodney W. Grimes {
2865b81b6b3SRodney W. Grimes 	db_delete_breakpoint(db_map_addr(addr), (db_addr_t)addr);
2875b81b6b3SRodney W. Grimes }
2885b81b6b3SRodney W. Grimes 
2895b81b6b3SRodney W. Grimes /* Set breakpoint with skip count */
2905b81b6b3SRodney W. Grimes /*ARGSUSED*/
2915b81b6b3SRodney W. Grimes void
2925b81b6b3SRodney W. Grimes db_breakpoint_cmd(addr, have_addr, count, modif)
2935b81b6b3SRodney W. Grimes 	db_expr_t	addr;
294058284fcSBruce Evans 	boolean_t	have_addr;
2955b81b6b3SRodney W. Grimes 	db_expr_t	count;
2965b81b6b3SRodney W. Grimes 	char *		modif;
2975b81b6b3SRodney W. Grimes {
2985b81b6b3SRodney W. Grimes 	if (count == -1)
2995b81b6b3SRodney W. Grimes 	    count = 1;
3005b81b6b3SRodney W. Grimes 
3015b81b6b3SRodney W. Grimes 	db_set_breakpoint(db_map_addr(addr), (db_addr_t)addr, count);
3025b81b6b3SRodney W. Grimes }
3035b81b6b3SRodney W. Grimes 
3045b81b6b3SRodney W. Grimes /* list breakpoints */
3055b81b6b3SRodney W. Grimes void
306058284fcSBruce Evans db_listbreak_cmd(dummy1, dummy2, dummy3, dummy4)
307058284fcSBruce Evans 	db_expr_t	dummy1;
308058284fcSBruce Evans 	boolean_t	dummy2;
309058284fcSBruce Evans 	db_expr_t	dummy3;
310058284fcSBruce Evans 	char *		dummy4;
3115b81b6b3SRodney W. Grimes {
3125b81b6b3SRodney W. Grimes 	db_list_breakpoints();
3135b81b6b3SRodney W. Grimes }
3145b81b6b3SRodney W. Grimes 
3155b81b6b3SRodney W. Grimes #include <vm/vm_kern.h>
3165b81b6b3SRodney W. Grimes 
3175b81b6b3SRodney W. Grimes /*
3185b81b6b3SRodney W. Grimes  *	We want ddb to be usable before most of the kernel has been
3195b81b6b3SRodney W. Grimes  *	initialized.  In particular, current_thread() or kernel_map
3205b81b6b3SRodney W. Grimes  *	(or both) may be null.
3215b81b6b3SRodney W. Grimes  */
3225b81b6b3SRodney W. Grimes 
3235b81b6b3SRodney W. Grimes boolean_t
3245b81b6b3SRodney W. Grimes db_map_equal(map1, map2)
3255b81b6b3SRodney W. Grimes 	vm_map_t	map1, map2;
3265b81b6b3SRodney W. Grimes {
3275b81b6b3SRodney W. Grimes 	return ((map1 == map2) ||
3285b81b6b3SRodney W. Grimes 		((map1 == NULL) && (map2 == kernel_map)) ||
3295b81b6b3SRodney W. Grimes 		((map1 == kernel_map) && (map2 == NULL)));
3305b81b6b3SRodney W. Grimes }
3315b81b6b3SRodney W. Grimes 
3325b81b6b3SRodney W. Grimes boolean_t
3335b81b6b3SRodney W. Grimes db_map_current(map)
3345b81b6b3SRodney W. Grimes 	vm_map_t	map;
3355b81b6b3SRodney W. Grimes {
3365b81b6b3SRodney W. Grimes #if 0
3375b81b6b3SRodney W. Grimes 	thread_t	thread;
3385b81b6b3SRodney W. Grimes 
3395b81b6b3SRodney W. Grimes 	return ((map == NULL) ||
3405b81b6b3SRodney W. Grimes 		(map == kernel_map) ||
3415b81b6b3SRodney W. Grimes 		(((thread = current_thread()) != NULL) &&
3425b81b6b3SRodney W. Grimes 		 (map == thread->task->map)));
3435b81b6b3SRodney W. Grimes #else
3445b81b6b3SRodney W. Grimes 	return (1);
3455b81b6b3SRodney W. Grimes #endif
3465b81b6b3SRodney W. Grimes }
3475b81b6b3SRodney W. Grimes 
3485b81b6b3SRodney W. Grimes vm_map_t
3495b81b6b3SRodney W. Grimes db_map_addr(addr)
3505b81b6b3SRodney W. Grimes 	vm_offset_t addr;
3515b81b6b3SRodney W. Grimes {
3525b81b6b3SRodney W. Grimes #if 0
3535b81b6b3SRodney W. Grimes 	thread_t	thread;
3545b81b6b3SRodney W. Grimes 
3555b81b6b3SRodney W. Grimes 	/*
3565b81b6b3SRodney W. Grimes 	 *	We want to return kernel_map for all
3575b81b6b3SRodney W. Grimes 	 *	non-user addresses, even when debugging
3585b81b6b3SRodney W. Grimes 	 *	kernel tasks with their own maps.
3595b81b6b3SRodney W. Grimes 	 */
3605b81b6b3SRodney W. Grimes 
3615b81b6b3SRodney W. Grimes 	if ((VM_MIN_ADDRESS <= addr) &&
3625b81b6b3SRodney W. Grimes 	    (addr < VM_MAX_ADDRESS) &&
3635b81b6b3SRodney W. Grimes 	    ((thread = current_thread()) != NULL))
3645b81b6b3SRodney W. Grimes 	    return thread->task->map;
3655b81b6b3SRodney W. Grimes 	else
3665b81b6b3SRodney W. Grimes #endif
3675b81b6b3SRodney W. Grimes 	    return kernel_map;
3685b81b6b3SRodney W. Grimes }
369