/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
- *
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* Please see the License for the specific language governing rights and
* limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
#include <ddb/db_expr.h>
#include <ddb/db_output.h> /* For db_printf() */
#include <ddb/db_task_thread.h>
-
+#include <kern/thread.h>
#define NBREAKPOINTS 100
#define NTHREAD_LIST (NBREAKPOINTS*3)
static db_thread_breakpoint_t db_find_thread_breakpoint(
db_breakpoint_t bkpt,
- thread_act_t thr_act);
+ thread_t thr_act);
static void db_force_delete_breakpoint(
db_breakpoint_t bkpt,
static db_thread_breakpoint_t
db_find_thread_breakpoint(
db_breakpoint_t bkpt,
- thread_act_t thr_act)
+ thread_t thr_act)
{
register db_thread_breakpoint_t tp;
register task_t task =
- (thr_act == THR_ACT_NULL)
+ (thr_act == THREAD_NULL)
? TASK_NULL : thr_act->task;
for (tp = bkpt->threads; tp; tp = tp->tb_next) {
bkpt = db_find_breakpoint(task, (db_addr_t)addr);
if (bkpt == 0)
return(0);
- return(db_find_thread_breakpoint(bkpt, current_act()));
+ return(db_find_thread_breakpoint(bkpt, current_thread()));
}
db_thread_breakpoint_t
if ((tbp->tb_is_task &&
db_lookup_task((task_t)(tbp->tb_task_thd)) < 0) ||
(!tbp->tb_is_task &&
- db_lookup_act((thread_act_t)(tbp->tb_task_thd)) < 0)) {
+ db_lookup_act((thread_t)(tbp->tb_task_thd)) < 0)) {
db_force_delete_breakpoint(bkpt,
tbp->tb_task_thd, tbp->tb_is_task);
}
task_t task,
db_addr_t addr,
int count,
- thread_act_t thr_act,
+ thread_t thr_act,
boolean_t task_bpt)
{
register db_breakpoint_t bkpt;
bkpt = db_find_breakpoint(task, addr);
if (bkpt) {
- if (thr_act == THR_ACT_NULL
+ if (thr_act == THREAD_NULL
|| db_find_thread_breakpoint(bkpt, thr_act)) {
db_printf("Already set.\n");
return;
}
} else {
- if (!DB_CHECK_ACCESS(addr, BKPT_SIZE, task)) {
+ if (!DB_CHECK_ACCESS((vm_offset_t)addr, BKPT_SIZE, task)) {
if (task) {
- db_printf("Warning: non-resident page for breakpoint at %lX",
- addr);
+ db_printf("Warning: non-resident page for breakpoint at %llX",
+ (unsigned long long)addr);
db_printf(" in task %lX.\n", task);
} else {
- db_printf("Cannot set breakpoint at %lX in kernel space.\n",
- addr);
+ db_printf("Cannot set breakpoint at %llX in kernel space.\n",
+ (unsigned long long)addr);
return;
}
}
return;
}
bkpt->task = task;
- bkpt->flags = (task && thr_act == THR_ACT_NULL)?
+ bkpt->flags = (task && thr_act == THREAD_NULL)?
(BKPT_USR_GLOBAL|BKPT_1ST_SET): 0;
bkpt->address = addr;
bkpt->threads = 0;
&& bkpt->address == addr)
return(TRUE);
if ((bkpt->flags & BKPT_USR_GLOBAL) == 0 &&
- DB_PHYS_EQ(task, addr, bkpt->task, bkpt->address))
+ DB_PHYS_EQ(task, (vm_offset_t)addr, bkpt->task, (vm_offset_t)bkpt->address))
return (TRUE);
}
return(FALSE);
register db_breakpoint_t bkpt;
register task_t task;
db_expr_t inst;
- thread_act_t cur_act = current_act();
+ thread_t cur_act = current_thread();
task_t cur_task =
(cur_act) ?
cur_act->task : TASK_NULL;
} else
bkpt->flags &= ~BKPT_1ST_SET;
}
- if (DB_CHECK_ACCESS(bkpt->address, BKPT_SIZE, task)) {
+ if (DB_CHECK_ACCESS((vm_offset_t)bkpt->address, BKPT_SIZE, task)) {
inst = db_get_task_value(bkpt->address, BKPT_SIZE, FALSE,
task);
if (inst == BKPT_SET(inst))
continue;
- bkpt->bkpt_inst = inst;
+ bkpt->bkpt_inst = (vm_size_t)inst;
db_put_task_value(bkpt->address,
BKPT_SIZE,
BKPT_SET(bkpt->bkpt_inst), task);
register db_breakpoint_t bkpt, *bkptp;
register task_t task;
db_expr_t inst;
- thread_act_t cur_act = current_act();
+ thread_t cur_act = current_thread();
task_t cur_task = (cur_act) ?
cur_act->task: TASK_NULL;
task = cur_task;
}
if ((bkpt->flags & BKPT_SET_IN_MEM)
- && DB_CHECK_ACCESS(bkpt->address, BKPT_SIZE, task)) {
+ && DB_CHECK_ACCESS((vm_offset_t)bkpt->address, BKPT_SIZE, task)) {
inst = db_get_task_value(bkpt->address, BKPT_SIZE, FALSE,
task);
if (inst != BKPT_SET(inst)) {
db_printf("Too many thread_breakpoints.\n");
return 0;
}
- bkpt->bkpt_inst = db_get_task_value(bkpt->address, BKPT_SIZE,
+ bkpt->bkpt_inst = (vm_size_t)db_get_task_value(bkpt->address, BKPT_SIZE,
FALSE, task);
db_put_task_value(bkpt->address, BKPT_SIZE,
BKPT_SET(bkpt->bkpt_inst), task);
else
db_printf("task%03d ", task_id);
} else {
- thread_act_t thd = (thread_act_t)(tp->tb_task_thd);
+ thread_t thd = (thread_t)(tp->tb_task_thd);
task_id = db_lookup_task(thd->task);
act_id = db_lookup_task_act(thd->task, thd);
if (task_id < 0 || act_id < 0)
db_delete_cmd(void)
{
register int n;
- thread_act_t thr_act;
+ thread_t thr_act;
vm_offset_t task_thd;
boolean_t user_global = FALSE;
boolean_t task_bpt = FALSE;
if (t == tHASH) {
db_thread_breakpoint_t tbp;
- db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt = 0;
if (db_read_token() != tNUMBER) {
db_printf("Bad break point number #%s\n", db_tok_string);
db_error(0);
}
- if ((tbp = db_find_breakpoint_number(db_tok_number, &bkpt)) == 0) {
+ if ((tbp = db_find_breakpoint_number((int)db_tok_number, &bkpt)) == 0) {
db_printf("No such break point #%d\n", db_tok_number);
db_error(0);
}
user_space = TRUE;
}
if (!DB_VALID_ADDRESS(addr, user_space)) {
- db_printf("Address %#X is not in %s space\n", addr,
+ db_printf("Address %#llX is not in %s space\n", (unsigned long long)addr,
(user_space)? "user": "kernel");
db_error(0);
}
if (thd_bpt || task_bpt) {
for (n = 0; db_get_next_act(&thr_act, n); n++) {
- if (thr_act == THR_ACT_NULL)
+ if (thr_act == THREAD_NULL)
db_error("No active thr_act\n");
if (task_bpt) {
if (thr_act->task == TASK_NULL)
(db_addr_t)addr, task_thd);
}
} else {
- db_delete_breakpoint(db_target_space(THR_ACT_NULL, user_space),
+ db_delete_breakpoint(db_target_space(THREAD_NULL, user_space),
(db_addr_t)addr, 0);
}
}
#include <mach/machine/vm_param.h>
void
-db_breakpoint_cmd(
- db_expr_t addr,
- int have_addr,
- db_expr_t count,
- char * modif)
+db_breakpoint_cmd(db_expr_t addr, __unused boolean_t have_addr, db_expr_t count,
+ char *modif)
{
register int n;
- thread_act_t thr_act;
+ thread_t thr_act;
boolean_t user_global = db_option(modif, 'U');
boolean_t task_bpt = db_option(modif, 'T');
boolean_t user_space;
- if (count == -1)
+ if (count == (uint64_t)-1)
count = 1;
#if 0 /* CHECKME */
if (!task_bpt && db_option(modif,'t'))
if (user_space)
db_error("Invalid user space address\n");
user_space = TRUE;
- db_printf("%#X is in user space\n", addr);
+ db_printf("%#llX is in user space\n", (unsigned long long)addr);
#ifdef ppc
db_printf("kernel is from %#X to %#x\n", VM_MIN_KERNEL_ADDRESS, vm_last_addr);
#else
}
if (db_option(modif, 't') || task_bpt) {
for (n = 0; db_get_next_act(&thr_act, n); n++) {
- if (thr_act == THR_ACT_NULL)
+ if (thr_act == THREAD_NULL)
db_error("No active thr_act\n");
if (task_bpt && thr_act->task == TASK_NULL)
db_error("No task\n");
&& thr_act->task != db_current_space())
db_error("Cannot set break point in inactive user space\n");
db_set_breakpoint(db_target_space(thr_act, user_space),
- (db_addr_t)addr, count,
- (user_global)? THR_ACT_NULL: thr_act,
+ (db_addr_t)addr, (int)count,
+ (user_global)? THREAD_NULL: thr_act,
task_bpt);
}
} else {
- db_set_breakpoint(db_target_space(THR_ACT_NULL, user_space),
+ db_set_breakpoint(db_target_space(THREAD_NULL, user_space),
(db_addr_t)addr,
- count, THR_ACT_NULL, FALSE);
+ (int)count, THREAD_NULL, FALSE);
}
}
/* list breakpoints */
void
-db_listbreak_cmd(void)
+db_listbreak_cmd(__unused db_expr_t addr, __unused boolean_t have_addr,
+ __unused db_expr_t count, __unused char *modif)
{
db_list_breakpoints();
}