1*e93f7393Sniklas /* 2*e93f7393Sniklas * (c) Copyright 1990-1996 OPEN SOFTWARE FOUNDATION, INC. 3*e93f7393Sniklas * (c) Copyright 1990-1996 HEWLETT-PACKARD COMPANY 4*e93f7393Sniklas * (c) Copyright 1990-1996 DIGITAL EQUIPMENT CORPORATION 5*e93f7393Sniklas * (c) Copyright 1991, 1992 Siemens-Nixdorf Information Systems 6*e93f7393Sniklas * To anyone who acknowledges that this file is provided "AS IS" without 7*e93f7393Sniklas * any express or implied warranty: permission to use, copy, modify, and 8*e93f7393Sniklas * distribute this file for any purpose is hereby granted without fee, 9*e93f7393Sniklas * provided that the above copyright notices and this notice appears in 10*e93f7393Sniklas * all source code copies, and that none of the names listed above be used 11*e93f7393Sniklas * in advertising or publicity pertaining to distribution of the software 12*e93f7393Sniklas * without specific, written prior permission. None of these organizations 13*e93f7393Sniklas * makes any representations about the suitability of this software for 14*e93f7393Sniklas * any purpose. 15*e93f7393Sniklas */ 16*e93f7393Sniklas /* 17*e93f7393Sniklas * Header file providing access to CMA clients that implement 18*e93f7393Sniklas * language run-times to the CMA debugger capabilities. 19*e93f7393Sniklas * 20*e93f7393Sniklas * NOTE: the clients that are able to use this interface is 21*e93f7393Sniklas * very limited because clients needing task debugging must have 22*e93f7393Sniklas * support in the system debugger as well as here (at present). 23*e93f7393Sniklas * The following are the only legitimate clients of this interface: 24*e93f7393Sniklas * ADA runtime, C++ tasking library, and CMA. 25*e93f7393Sniklas * 26*e93f7393Sniklas *FIX-ME* We shall endeavor to extend these capabilities so that the 27*e93f7393Sniklas * all-platform CMA debugger CMA_DEBUG and any client can layer 28*e93f7393Sniklas * on thread debugging. But that is still an open design problem. 29*e93f7393Sniklas * The design here does not preclude that extension (for example, 30*e93f7393Sniklas * the identity of the debug-client is indicated in an "open" 31*e93f7393Sniklas * manner by using the CMA context key as the identifier. 32*e93f7393Sniklas */ 33*e93f7393Sniklas 34*e93f7393Sniklas #ifndef CMA_DEBUG_CLIENT 35*e93f7393Sniklas #define CMA_DEBUG_CLIENT 36*e93f7393Sniklas 37*e93f7393Sniklas /* 38*e93f7393Sniklas * INCLUDE FILES 39*e93f7393Sniklas */ 40*e93f7393Sniklas #include <cma.h> 41*e93f7393Sniklas 42*e93f7393Sniklas /* 43*e93f7393Sniklas * CONSTANTS AND MACROS 44*e93f7393Sniklas */ 45*e93f7393Sniklas 46*e93f7393Sniklas /* 47*e93f7393Sniklas * TYPEDEFS 48*e93f7393Sniklas */ 49*e93f7393Sniklas 50*e93f7393Sniklas /* 51*e93f7393Sniklas * Type describing constants for a valid TCB sentinel. 52*e93f7393Sniklas * Exactly one value is valid, but we provide a symbolic name for 53*e93f7393Sniklas * at least one invalid sentinel as a convenience. 54*e93f7393Sniklas */ 55*e93f7393Sniklas typedef enum CMA_T_TCB_SENTINEL { 56*e93f7393Sniklas cma_c_tcb_sentinel_nogood = 0, /* Invalid sentinel constant */ 57*e93f7393Sniklas cma_c_tcb_sentinel = 0x0ACEFACE /* Valid TCB sentinel */ 58*e93f7393Sniklas } cma_t_tcb_sentinel; 59*e93f7393Sniklas 60*e93f7393Sniklas /* 61*e93f7393Sniklas * Type describing pad fields needed to align the "standard prolog" 62*e93f7393Sniklas * to the right byte at the front of each TCB. These fields are 63*e93f7393Sniklas * free to be put to any use by the client. 64*e93f7393Sniklas * 65*e93f7393Sniklas * This is 32 bytes long and is fixed at this size for all clients 66*e93f7393Sniklas * and CMA, for all time. 67*e93f7393Sniklas */ 68*e93f7393Sniklas typedef struct CMA_T_TCB_PRIVATE { 69*e93f7393Sniklas cma_t_integer pad1; 70*e93f7393Sniklas cma_t_integer pad2; 71*e93f7393Sniklas cma_t_integer pad3; 72*e93f7393Sniklas cma_t_integer pad4; 73*e93f7393Sniklas cma_t_integer pad5; 74*e93f7393Sniklas cma_t_integer pad6; 75*e93f7393Sniklas cma_t_integer pad7; 76*e93f7393Sniklas cma_t_integer pad8; 77*e93f7393Sniklas } cma_t_tcb_private; 78*e93f7393Sniklas 79*e93f7393Sniklas /* 80*e93f7393Sniklas * Type describing the "standard prolog" that clients should use 81*e93f7393Sniklas * within their task control blocks. We assume that the client will 82*e93f7393Sniklas * store their "task control block" as a per-thread context under 83*e93f7393Sniklas * the context key specified here. 84*e93f7393Sniklas */ 85*e93f7393Sniklas typedef struct CMA_T_TCB_PROLOG { 86*e93f7393Sniklas cma_t_tcb_sentinel sentinel; /* Validity sentinel */ 87*e93f7393Sniklas cma_t_thread client_thread; /* Thread corresonding to task */ 88*e93f7393Sniklas cma_t_key client_key; /* Context key this is stored under */ 89*e93f7393Sniklas cma_t_address reserved1; /* Must be zero, reserved to CMA */ 90*e93f7393Sniklas } cma_t_tcb_prolog; 91*e93f7393Sniklas 92*e93f7393Sniklas /* 93*e93f7393Sniklas * Type defining the layout of all TCBs and TASKS. This format 94*e93f7393Sniklas * ensures that tasks will be self-identifying to the debugger. 95*e93f7393Sniklas * this layout must never change as the CMA DEBUG Clients cannot 96*e93f7393Sniklas * be changed after CMA ships. 97*e93f7393Sniklas */ 98*e93f7393Sniklas typedef struct CMA_T_TCB_HEADER { 99*e93f7393Sniklas cma_t_tcb_private IGNORED; /* TCB fields private to the client */ 100*e93f7393Sniklas cma_t_tcb_prolog prolog; /* The standard prolog goes here */ 101*e93f7393Sniklas } cma_t_tcb_header; 102*e93f7393Sniklas 103*e93f7393Sniklas 104*e93f7393Sniklas /* 105*e93f7393Sniklas * Type describing the kinds of information that a CMA debug 106*e93f7393Sniklas * client can GET about a thread. 107*e93f7393Sniklas */ 108*e93f7393Sniklas typedef enum CMA_T_DEBUG_GET { 109*e93f7393Sniklas /* 110*e93f7393Sniklas * All of the following items use a buffer whose size is 111*e93f7393Sniklas * four bytes. (That is four must be passed as the buffer_size 112*e93f7393Sniklas * parameter to cma_debug_get.) 113*e93f7393Sniklas */ 114*e93f7393Sniklas cma_c_debget_guardsize = 1, /* Current guard size (bytes) */ 115*e93f7393Sniklas cma_c_debget_is_held = 2, /* Is it on hold? */ 116*e93f7393Sniklas cma_c_debget_is_initial = 3, /* Is it the initial thread? */ 117*e93f7393Sniklas cma_c_debget_number = 4, /* Thread's number */ 118*e93f7393Sniklas cma_c_debget_stack_ptr = 5, /* Current stack pointer */ 119*e93f7393Sniklas cma_c_debget_stack_base = 6, /* Stack base address */ 120*e93f7393Sniklas cma_c_debget_stack_top = 7, /* Stack top address */ 121*e93f7393Sniklas cma_c_debget_sched_state = 8, /* Scheduler state 122*e93f7393Sniklas * 0 - run 123*e93f7393Sniklas * 1 - ready 124*e93f7393Sniklas * 2 - blocked 125*e93f7393Sniklas * 3 - terminated 126*e93f7393Sniklas */ 127*e93f7393Sniklas cma_c_debget_reserve_size = 9, /* Size of stack reserve (bytes) */ 128*e93f7393Sniklas cma_c_debget_base_prio = 10, /* Base priority */ 129*e93f7393Sniklas cma_c_debget_priority = 11, /* Current priority */ 130*e93f7393Sniklas cma_c_debget_regs = 12, /* Register set (and proc. state) */ 131*e93f7393Sniklas cma_c_debget_alt_pending = 13, /* Alert is pending */ 132*e93f7393Sniklas cma_c_debget_alt_a_enable = 14, /* Asynch alert delivery enabled */ 133*e93f7393Sniklas cma_c_debget_alt_g_enable = 15, /* General alert delivery enabled */ 134*e93f7393Sniklas cma_c_debget_substate = 16, /* Substate (or wait state) */ 135*e93f7393Sniklas cma_c_debget_object_addr = 17, /* Address of thread object */ 136*e93f7393Sniklas cma_c_debget_thkind = 18, /* Kind of thread */ 137*e93f7393Sniklas cma_c_debget_detached = 19, /* Thread is detached */ 138*e93f7393Sniklas cma_c_debget_tcb_size = 20, /* TCB size */ 139*e93f7393Sniklas cma_c_debget_start_pc = 21, /* Start address */ 140*e93f7393Sniklas cma_c_debget_next_pc = 22, /* Next instruction */ 141*e93f7393Sniklas cma_c_debget_policy = 23, /* Sched policy */ 142*e93f7393Sniklas cma_c_debget_stack_yellow = 24, /* Addr of start of guard area */ 143*e93f7393Sniklas cma_c_debget_stack_default = 25 /* True if on default stack */ 144*e93f7393Sniklas 145*e93f7393Sniklas } cma_t_debug_get; 146*e93f7393Sniklas 147*e93f7393Sniklas /* 148*e93f7393Sniklas * Type describing the kinds of information that a CMA debug 149*e93f7393Sniklas * client can SET (or change) about a thread using cma_debug_set. 150*e93f7393Sniklas */ 151*e93f7393Sniklas typedef enum CMA_T_DEBUG_SET { 152*e93f7393Sniklas /* 153*e93f7393Sniklas * All of the following items use a buffer whose size is 154*e93f7393Sniklas * four bytes. (That is four must be passed as the buffer_size 155*e93f7393Sniklas * parameter to cma_debug_set.) 156*e93f7393Sniklas */ 157*e93f7393Sniklas cma_c_debset_priority = 1, /* Set the priority */ 158*e93f7393Sniklas cma_c_debset_policy = 2, /* Set the sched policy */ 159*e93f7393Sniklas cma_c_debset_hold = 3, /* Put thread on hold */ 160*e93f7393Sniklas cma_c_debset_regs = 4 /* Set the regs and proc. state */ 161*e93f7393Sniklas 162*e93f7393Sniklas } cma_t_debug_set; 163*e93f7393Sniklas 164*e93f7393Sniklas 165*e93f7393Sniklas /* 166*e93f7393Sniklas * GLOBAL DATA 167*e93f7393Sniklas * 168*e93f7393Sniklas * none 169*e93f7393Sniklas */ 170*e93f7393Sniklas 171*e93f7393Sniklas /* 172*e93f7393Sniklas * EXTERNAL INTERFACES 173*e93f7393Sniklas */ 174*e93f7393Sniklas 175*e93f7393Sniklas /* 176*e93f7393Sniklas * Routine to register with the CMA debug dispatcher. 177*e93f7393Sniklas */ 178*e93f7393Sniklas extern void cma_debug_register (cma_t_address,cma_t_key,cma_t_integer,cma_t_boolean); 179*e93f7393Sniklas 180*e93f7393Sniklas /* 181*e93f7393Sniklas * Routine to get get thread state needed by the CMA debug client. 182*e93f7393Sniklas */ 183*e93f7393Sniklas extern void cma_debug_get (cma_t_thread *,cma_t_debug_get,cma_t_address,cma_t_integer); 184*e93f7393Sniklas 185*e93f7393Sniklas /* 186*e93f7393Sniklas * Get thread context given an sp and a key 187*e93f7393Sniklas */ 188*e93f7393Sniklas extern void cma_debug_get_sp_context (cma_t_address,cma_t_key,cma_t_address *); 189*e93f7393Sniklas 190*e93f7393Sniklas /* 191*e93f7393Sniklas * Routine to set thread state as needed by the CMA debug client. 192*e93f7393Sniklas */ 193*e93f7393Sniklas extern void cma_debug_set (cma_t_thread *,cma_t_debug_set,cma_t_address,cma_t_integer); 194*e93f7393Sniklas 195*e93f7393Sniklas #endif 196