]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ddb/db_break.c
xnu-1699.24.8.tar.gz
[apple/xnu.git] / osfmk / ddb / db_break.c
index f4c841f17fe36584f634377ecb9679c4271f7c8e..38c4e232a677a8c1afe4f4977f62db11c43d561f 100644 (file)
@@ -1,23 +1,29 @@
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * 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. 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.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * 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@
@@ -44,7 +50,7 @@
 #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)
@@ -221,7 +227,7 @@ db_find_thread_breakpoint_here(
        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
@@ -323,7 +329,7 @@ db_set_breakpoint(
                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 %llX",
                              (unsigned long long)addr);
@@ -422,7 +428,7 @@ db_find_breakpoint_here(
                 && 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);
@@ -436,7 +442,7 @@ db_set_breakpoints(void)
        register db_breakpoint_t bkpt;
        register task_t task;
        db_expr_t       inst;
-       thread_t        cur_act = current_act();
+       thread_t        cur_act = current_thread();
        task_t          cur_task =
                                (cur_act) ?
                                        cur_act->task : TASK_NULL;
@@ -455,12 +461,12 @@ db_set_breakpoints(void)
                    } 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);
@@ -479,7 +485,7 @@ db_clear_breakpoints(void)
        register db_breakpoint_t bkpt, *bkptp;
        register task_t  task;
        db_expr_t inst;
-       thread_t         cur_act = current_act();
+       thread_t         cur_act = current_thread();
        task_t   cur_task = (cur_act) ?
                        cur_act->task: TASK_NULL;
 
@@ -495,7 +501,7 @@ db_clear_breakpoints(void)
                    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)) {
@@ -545,7 +551,7 @@ db_set_temp_breakpoint(
            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);
@@ -694,13 +700,13 @@ db_delete_cmd(void)
 
        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);
            }
@@ -745,11 +751,8 @@ db_delete_cmd(void)
 #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_t thr_act;
@@ -757,7 +760,7 @@ db_breakpoint_cmd(
        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'))
@@ -793,20 +796,21 @@ db_breakpoint_cmd(
                         && 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,
+                                       (db_addr_t)addr, (int)count,
                                        (user_global)? THREAD_NULL: thr_act,
                                        task_bpt);
            }
        } else {
            db_set_breakpoint(db_target_space(THREAD_NULL, user_space),
                                 (db_addr_t)addr,
-                                count, THREAD_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();
 }