dbgproto.h 13.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
/*
 * ==========================================================================
 * Copyright (c) 1993, Silicon Graphics, Inc.  All Rights Reserved.
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
 * the contents of this file may not be disclosed to third parties, copied
 * or duplicated in any form, in whole or in part, without the prior written
 * permission of Silicon Graphics, Inc. handleSelectExceptions
 *
 * RESTRICTED RIGHTS LEGEND:
 * Use, duplication or disclosure by the Government is subject to restrictions
 * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
 * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
 * successor clauses in the FAR, DOD or NASA FAR Supplement.  Unpublished
 * rights reserved under the Copyright Laws of the United States.
 * ==========================================================================
 */
#ifndef dbgproto_h
#define dbgproto_h

#ifdef __cplusplus
extern "C" {
#endif

#ident "$Revision: 1.1.1.1 $"

/*
 * NOTE: If you change this file, remember increment the revision below.
 */
#define TV_DBGPROTO_REV 2


#define TV_DBG_MAXREQ_SIZE 1024

/*
 * Higher resolution time information
 */
typedef struct __KKTimeStruct {
    long seconds;
    long nanoseconds;
} KKTimeStruct;

#define MAGIC_PORT 2727 /* clients connect here */

typedef struct __KKObjsStruct {
    TVushort number;        /* number of objects */
    TVid     objects[1];    /* variabel length array of object ids */
} KKObjs;

typedef struct __KKFaultInfoStruct {
    unsigned int  addr;      /* Faulting address on a watchpoint */
    short         major;     /* major classification of fault */
    short         minor;     /* minor classification of fault */
} KKFaultInfo;

typedef struct __KKThreadStatusStruct {
    int            flags;    /* flags */
    short          why;      /* reason for stop */
    short	   what;     /* system call number when why == KK_SYSENTRY */
			     /*  or why == KK_SYSEXIT */
    TVid           tid;      /* thread id */
    TVid           pid;      /* process id */
    unsigned int   instr;    /* current instruction */
    KKFaultInfo    info;     /* info associated with fault */
    int            priority; /* scheduling priority */
    int		   start;    /* used to name the thread */
    int		   rv;	     /* return value from last system call */
    unsigned	   args[6];  /* args to system call */
} KKThreadStatus;

/* values for flags - Thread States */
#define KK_STOPPED      0x1     /* thread is stopped */
#define KK_RUNNABLE     0x2     /* thread is waiting for the cpu */
#define KK_RUNNING      0x4     /* thread is executing in the cpu */
#define KK_WAITING      0x8     /* thread is waiting for non-cpu resource */

/* values for why - reason for being stopped, mutually exclusive */
#define KK_REQUESTED    0x1     /* stopped as a result of stop directive */
#define KK_FAULTED      0x2     /* stopped on incurring a hardware fault */
#define KK_SYSENTRY	0x3	/* stopped on entry to a system call */
#define KK_SYSEXIT	0x4	/* stopped on exit from a system call */
#define KK_NWHY 	0x4	/* number of values for why */

typedef struct __KKRunStruct {
    int          flags;    /* flags */
    unsigned int vaddr;    /* Virtual address at which to resume */
} KKRun;

/* values for flags */
#define KK_STEP        0x1      /* single step thread */
#define KK_VADDR       0x2      /* set PC on resumption from vaddr */
#define KK_ABORT       0x4      /* thread should kill itself when resumed */

typedef struct __KKFaultStruct {
    short majorMask;    /* bit mask giving major fault */
    short minorMask;    /* bit mask giving minor fault */
} KKFault;

/* values for major_ mask */
#define KK_FLTMEM        0x1       /* Memory fault */
#define KK_FLTINSTR      0x2       /* Instruction fault */
#define KK_FLTINTX       0x4       /* Integer exception fault */
#define KK_FLTFPE        0x8       /* Floating point exception fault */

/* types of memory faults */
#define KK_FLTALIGN      0x1       /* Alignment error */
#define KK_FLTACCESS     0x2       /* Memory access violation */
#define KK_FLTBOUNDS     0x4       /* Memory bounds violation */
#define KK_FLTWATCH      0x8       /* User watchpoint */

/* types of instruction faults */
#define KK_FLTILL        0x1       /* Illegal instruction */
#define KK_FLTPRIV       0x2       /* Privileged instruction */
#define KK_FLTTRACE      0x4       /* Trace or breakpoint instruction */

/* types of exception faults - integer and floating point */
#define KK_FLTOVF       0x1       /* overflow */
#define KK_FLTZDIV      0x2       /* zero-divide */

/* types of exceptions - only floating point */
#define KK_FLTUDF      0x4       /* underflow */
#define KK_FLTINXCT    0x8       /* inexact result */
#define KK_FLTINVAL    0xf       /* invalid operand */

typedef struct __KKRegionStruct {
    unsigned int vaddr;		/* Starting virtual address of region */
    unsigned int size;		/* size of region */
    short        flags;		/* access flags */
    unsigned int paddr;		/* physical address of first page in region */
} KKRegion;

/* values for flags - access permissions */
#define KK_READ        0x1      /* read permission */
#define KK_WRITE       0x2      /* write permission */
#define KK_EXEC        0x4      /* execute permission */

#define KK_NGREGS 37

typedef struct __KKGregSetStruct {
    unsigned int gregs[KK_NGREGS];
} KKGregSet;

typedef struct __KKFPregSetStruct {
    union {
        double       dregs[16];      /* 16 64-bit registers */
        float        fregs[32];      /* 32 32-bit registers */
        unsigned int regs[32];       /* 32 64-bit registers */
    } fpregs;
    unsigned int     fpcsr;
    unsigned int     fppad;
} KKFPregSet;

typedef struct __KKRegisterContextStruct {
    KKGregSet        gregs;          /* general register set */
    KKFPregSet       fpregs;         /* floating point register set */
} KKRegisterContext;

typedef struct __KKUsageStruct {
    KKTimeStruct tstamp;	/* Wall clock time */
    KKTimeStruct created;	/* Create time */
    KKTimeStruct states[10];
} KKUsage;

/* values for how in __KKSetCommRequestStruct */
#define KK_TTY	0
#define KK_TCP	1
#define KK_NOP	2

/* specify a range of log events to enable or disable */
typedef struct __KKLogEventSetStruct {
    int		from;
    int		to;
} KKLogEventSet;

/*
 * Request codes
 */

#define _KK_REQ_LDXEQ           0
#define _KK_REQ_LISTPROCS       1
#define _KK_REQ_GETXEQNAME      2
#define _KK_REQ_LSTTHREADS      3
#define _KK_REQ_STATUS          4
#define _KK_REQ_STOPPROC        5
#define _KK_REQ_STOPTHREAD      6
#define _KK_REQ_RUNTHREAD       7
#define _KK_REQ_RUNPROC         8
#define _KK_REQ_KILLPROC        9
#define _KK_REQ_SETFAULT       10
#define _KK_REQ_GETFAULT       11
#define _KK_REQ_NUMREGIONS     12
#define _KK_REQ_GETREGIONS     13
#define _KK_REQ_GETGREGSET     14
#define _KK_REQ_SETGREGSET     15
#define _KK_REQ_GETFPREGSET    16
#define _KK_REQ_SETFPREGSET    17
#define _KK_REQ_READMEM        18
#define _KK_REQ_WRITEMEM       19
#define _KK_REQ_SETBKPT        20
#define _KK_REQ_CLRBKPT        21
#define _KK_REQ_LISTBKPTS      22
#define _KK_REQ_NUMWATCH       23
#define _KK_REQ_SETWATCH       24
#define _KK_REQ_GETWATCH       25
#define _KK_REQ_USAGE          26
#define _KK_REQ_GETPATHLIST    27
#define _KK_REQ_GETFRAME       28
#define _KK_REQ_REBOOT	       29
#define _KK_REQ_SETCOMM        30
#define _KK_REQ_SETSYSENTRY    31
#define _KK_REQ_GETSYSENTRY    32
#define _KK_REQ_SETSYSEXIT     33
#define _KK_REQ_GETSYSEXIT     34
#define _KK_REQ_ENABLELOG      35
#define _KK_REQ_DISABLELOG     36
#define _KK_REQ_FLUSHLOG       37
#define _KK_REQ_NEWLOG         38
#define _KK_REQ_AMCMD 	       39
#define _KK_REQ_COUNT          40             /* must be last */

/* for the type field in KKHeader */
#define _KK_REQUEST		0
#define _KK_REPLY		1
#define _KK_EXCEPTION		2
#define _KK_THREAD_EXIT		3
#define _KK_PROCESS_EXIT	4
#define _KK_FLUSH_BUFFER	5

typedef struct __KKHeaderStruct {
    int		length;
    char	code;
    char	type;
    short	error;
    char	rev;
    char	notused1;
    short	notused2;
} KKHeader;

/*
 *   Request Structures
 */
typedef struct __KKLoadExecutableRequestStruct {
    KKHeader header;
    char     str[1];
} KKLoadExecutableRequest;

typedef struct __KKObjectRequestStruct {
    KKHeader header;
    TVid     object;
} KKObjectRequest;

typedef struct __KKRunThreadRequestStruct {
    KKHeader header;
    TVid     tid;
    KKRun    actions;
} KKRunThreadRequest;

typedef struct __KKFaultRequestStruct {
    KKHeader header;
    TVid     tid;
    KKFault  fault;
    TVuchar  stopAllThreads;
} KKFaultRequest;

typedef struct __KKGRegsetRequestStruct {
    KKHeader  header;
    TVid      tid;
    KKGregSet registers;
} KKGRegsetRequest;

typedef struct __KKFPRegsetRequestStruct {
    KKHeader   header;
    TVid       tid;
    KKFPregSet registers;
} KKFPRegsetRequest;

typedef struct __KKReadRequestStruct {
    KKHeader     header;
    TVid         object;
    unsigned int addr;
    unsigned int nbytes;
} KKReadRequest;

typedef struct __KKWriteHeaderStruct {
    KKHeader     header;
    TVid         object;
    unsigned int addr;
    unsigned int nbytes;
} KKWriteHeader;

typedef struct __KKWriteRequestStruct {
    KKWriteHeader	writeHeader;
    char         	buffer[1];
} KKWriteRequest;

typedef struct __KKSetBkptRequestStruct {
    KKHeader     header;
    TVid         object;
    unsigned     int addr;
} KKSetBkptRequest;

typedef struct __KKClrBkptRequestStruct {
    KKHeader     header;
    TVid         object;
    TVid         bp;
} KKClrBkptRequest;

typedef struct __KKWatchRequestStruct {
    KKHeader     header;
    TVid         object;
    unsigned int number;
    KKRegion     wp[1];
} KKWatchRequest;

typedef struct __KKSetCommRequestStruct {
    KKHeader     header;
    unsigned int how;
    unsigned int addr;
} KKSetCommRequest;

typedef struct __KKSysCallSetStruct {
    __uint32_t	word[8];
} KKSysCallSet;

typedef struct __KKSysCallRequestStruct {
    KKHeader	 header;
    TVid	 pid;
    KKSysCallSet syscallset;
} KKSysCallRequest;

typedef struct __KKLogEventRequestStruct {
    KKHeader     	header;
    TVid         	pid;
    unsigned int 	numSet;
    KKLogEventSet	set[1];
} KKLogEventRequest;

typedef struct __KKNewLogRequestStruct {
    KKHeader header;
    char     str[1];
} KKNewLogRequest;

/*
 * Macros for manipulating sets of flags.
 * sp must be a pointer to KKSysCallSet. 
 * flag must be a member of the enumeration corresponding to *sp.
 */

/* turn on all flags in set */
#define TVFILLSET(sp) \
	{ int _i_ = sizeof(*(sp))/sizeof(unsigned int); \
		while(_i_) ((unsigned int*)(sp))[--_i_] = 0xFFFFFFFF; }

/* turn off all flags in set */
#define TVEMPTYSET(sp) \
	{ int _i_ = sizeof(*(sp))/sizeof(unsigned int); \
		while(_i_) ((unsigned int*)(sp))[--_i_] = 0; }

/* is this set empty? */
#define TVISEMPTYSET(set) \
	(setisempty(set, sizeof(*(set))/sizeof(unsigned int)))

/* turn on specified flag in set */
#define TVADDSET(sp, flag) \
	(((unsigned)((flag)) < 32*sizeof(*(sp))/sizeof(unsigned int)) \
	&& (((unsigned int*)(sp))[((flag))/32] |= (1<<(((flag))%32))))

/* turn off specified flag in set */
#define TVDELSET(sp, flag) \
	(((unsigned)((flag)) < 32*sizeof(*(sp))/sizeof(unsigned int)) \
	&& (((unsigned int*)(sp))[((flag))/32] &= ~(1<<(((flag))%32))))

/* query: != 0 iff flag is turned on in set */
#define TVISMEMBER(sp, flag) \
	(((unsigned)((flag)) < 32*sizeof(*(sp))/sizeof(unsigned int)) \
	&& (((unsigned int*)(sp))[((flag))/32] & (1<<(((flag))%32))))


/*
 *  Event Structures
 */

typedef struct __KKObjectEventStruct {
    KKHeader     header;
    TVid         object;
} KKObjectEvent;

typedef struct __KKObjsEventStruct {
    KKHeader     header;
    TVid         object;
    KKObjs       objs;
} KKObjsEvent;

typedef struct __KKBufferEventStruct {
    KKHeader     header;
    TVid         object;
    char         buffer[1];
} KKBufferEvent;

typedef struct __KKStatusEventStruct {
    KKHeader       header;
    KKThreadStatus status;
} KKStatusEvent;

typedef struct __KKFaultEventStruct {
    KKHeader     header;
    TVid         tid;
    KKFault      fault;
    TVuchar      stopAllThreads;
} KKFaultEvent;

typedef struct __KKNumberEventStruct {
    KKHeader     header;
    TVid         object;
    unsigned int number;
} KKNumberEvent;

typedef struct __KKRegionEventStruct {
    KKHeader     header;
    TVid         object;
    unsigned int number;
    KKRegion     regions[1];
} KKRegionEvent;

typedef struct __KKGregEventStruct {
    KKHeader     header;
    TVid         tid;
    KKGregSet    registers;
} KKGregEvent;

typedef struct __KKFPregEventStruct {
    KKHeader     header;
    TVid         tid;
    KKFPregSet   registers;
} KKFPregEvent;

typedef struct __KKBkptEventStruct {
    KKHeader     header;
    TVid         object;
    TVid         bp;
    unsigned int instruction;
} KKBkptEvent;

typedef struct __KKUsageEventStruct {
    KKHeader     header;
    TVid         tid;
    KKUsage      usage;
} KKUsageEvent;

typedef struct __KKFlushEventStruct {
    KKHeader     header;
    int		 bufferType;
    char         buffer[1];
} KKFlushEvent;

typedef KKSysCallRequest KKSysCallEvent;

#ifdef __cplusplus
}
#endif

#endif /* dbgproto_h */