#include "ddb.h"
#include "db_access.h"
+#include "extra.h"
+
/*
* Access unaligned data items on aligned (longword)
* boundaries.
src = (char *)addr;
while (--size >= 0)
- *data++ = *src++;
+ *data++ = text_read_ub(src++);
}
* Instruction disassembler.
*/
+#if 0
#include <linux/kernel.h>
+#endif
#include "ddb.h"
#include "db_access.h"
result = db_get_value((loc), (size), (is_signed)); \
(loc) += (size);
-//static db_addr_t
+/*static db_addr_t
// db_disasm_esc __P((db_addr_t loc, int inst, int short_addr,
// int size, const char *seg));
//static void db_print_address __P((const char *seg, int size,
// struct i_addr *addrp));
+*/
static db_addr_t
db_read_address __P((db_addr_t loc, int short_addr,
int regmodrm, struct i_addr *addrp));
seg = "%gs";
break;
case 0xf0:
+#if 0
// db_printf("lock ");
+#endif
break;
case 0xf2:
+#if 0
// db_printf("repne ");
+#endif
break;
case 0xf3:
+#if 0
// db_printf("repe "); /* XXX repe VS rep */
+#endif
break;
default:
prefix = FALSE;
get_value_inc(regmodrm, loc, 1, FALSE);
loc = db_read_address(loc, short_addr, regmodrm, &address);
modAddr=prev_loc;
+#if 0
// printf("modrm at %x, offset %d\n", loc, loc-prev_loc);
+#endif
}
i_name = ip->i_name;
switch (i_mode & 0xFF) {
case E:
+#if 0
// db_print_address(seg, size, &address);
+#endif
break;
case Eind:
+#if 0
// db_print_address(seg, size, &address);
+#endif
break;
case El:
+#if 0
// db_print_address(seg, LONG, &address);
+#endif
break;
case Ew:
+#if 0
// db_print_address(seg, WORD, &address);
+#endif
break;
case Eb:
+#if 0
// db_print_address(seg, BYTE, &address);
+#endif
break;
case R:
+#if 0
// db_printf("%s", db_reg[size][f_reg(regmodrm)]);
+#endif
break;
case Rw:
+#if 0
// db_printf("%s", db_reg[WORD][f_reg(regmodrm)]);
+#endif
break;
case Ri:
+#if 0
// db_printf("%s", db_reg[size][f_rm(inst)]);
+#endif
break;
case Ril:
+#if 0
// db_printf("%s", db_reg[LONG][f_rm(inst)]);
+#endif
break;
case S:
+#if 0
// db_printf("%s", db_seg_reg[f_reg(regmodrm)]);
+#endif
break;
case Si:
+#if 0
// db_printf("%s", db_seg_reg[f_reg(inst)]);
+#endif
break;
case A:
+#if 0
// db_printf("%s", db_reg[size][0]); /* acc */
+#endif
break;
case BX:
get_value_inc(displ, loc, len, FALSE);
if (seg) ;
else
+#if 0
// db_printsym((db_addr_t)displ, DB_STGY_ANY);
+#endif
break;
case Db:
displ += loc;
if (size == WORD)
displ &= 0xFFFF;
+#if 0
// db_printsym((db_addr_t)displ, DB_STGY_XTRN);
+#endif
break;
case Dl:
displ += loc;
if (size == WORD)
displ &= 0xFFFF;
+#if 0
// db_printsym((db_addr_t)displ, DB_STGY_XTRN);
+#endif
break;
case o1:
break;
}
}
+#if 0
// db_printf("\n");
+#endif
return (loc);
}
#ifndef _MACHINE_DB_MACHDEP_H_
#define _MACHINE_DB_MACHDEP_H_
+#if 0
//#include <machine/frame.h>
//#include <machine/psl.h>
+#endif
#ifndef TRUE
#define TRUE 1
* Author: David B. Golub, Carnegie Mellon University
* Date: 7/90
*/
+#if 0
//#include <sys/param.h>
//#include <sys/systm.h>
+#endif
+#if 0
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/kallsyms.h>
+#endif
#include "ddb.h"
#include "db_sym.h"
#include "swifi.h"
+#include "extra.h"
+
/*
* Multiple symbol tables
*/
cur_value = value;
while(cur_value < sec_end) {
if(verbose) {
+#if 0
// db_printsym(cur_value, DB_STGY_PROC);
// printk(":\t");
+#endif
}
prev_value=cur_value;
modAddr=0;
if(verbose) {
+#if 0
//cur_value=db_disasm(prev_value, FALSE);
+#endif
} else {
cur_value=my_disasm(prev_value, FALSE);
}
if(cur_value-prev_value == 1) {
unsigned char *c;
c=(char *) prev_value;
- if(*c==0xc9) {
+ if(text_read_ub(c)==0xc9) {
if(verbose) printk("bailing out as we hit a leave\n");
found=0;
break;
/* look for repX prefix */
- if(*c==0xf3 || *c==0xf2) {
+ if(text_read_ub(c)==0xf3 || text_read_ub(c)==0xf2) {
if(verbose)
printk("found repX prefix\n");
/* take out repX prefix only */
found=1;
cur_value=prev_value+1;
break;
- } else if( ((*c)&0xf0)==0x70 || (*c>=0xe0 && *c<=0xe2) ) {
+ } else if( (text_read_ub(c)&0xf0)==0x70 ||
+ (text_read_ub(c)>=0xe0 && text_read_ub(c)<=0xe2) ) {
/* look for jXX 8 (7X), loop,jcx (e0-3), jXX 16/32 (0f 8X) */
found=1;
if(verbose)
printk("found jXX rel8, loop or jcx\n");
break;
- } else if(*c==0x66 || *c==0x67) { /* override prefix */
+ } else if(text_read_ub(c)==0x66 ||
+ text_read_ub(c)==0x67) { /* override prefix */
c++;
- } else if(*(c++)==0xf && ((*c)&0xf0)==0x80 ) {
+ } else if(text_read_ub(c++)==0xf && (text_read_ub(c)&0xf0)==0x80 ) {
found=1; /* 0x0f 0x8X */
if(verbose) printk("found branch!\n");
break;
if(cur_value>off && modAddr) {
unsigned char *c;
c=(char *) modAddr;
- if( (*c)>0x3f && (*c)<0xc0 && (((*c)&7)!=5) ) {
+ if( text_read_ub(c)>0x3f && text_read_ub(c)<0xc0 &&
+ (text_read_ub(c)&7)!=5 ) {
found=1;
break;
}
*/
unsigned char *c;
c=(char *) prev_value;
- if( *c==0x8a || *c==0x8b) {
+ if( text_read_ub(c)==0x8a || text_read_ub(c)==0x8b) {
c++;
- if( ((*(c++))&0xc7)==0x45 && ((*c)&0x80)==0 ) {
+ if( ((text_read_ub(c++))&0xc7)==0x45 && (text_read_ub(c)&0x80)==0 ) {
/* 75% chance that we'll choose the next arg */
if(random()&0x3) {
found=1;
*/
unsigned char *c;
c=(char *) prev_value;
- if (((*c & 0xf8) == 0x50) ||
- (*c == 0xff)) {
- if (*c == 0xff) {
+ if (((text_read_ub(c) & 0xf8) == 0x50) ||
+ (text_read_ub(c) == 0xff)) {
+ if (text_read_ub(c) == 0xff) {
c++;
+#if 0
//
// Look for push x(ebp)
- if ((*c & 0x78) != 0x70) {
+#endif
+ if ((text_read_ub(c) & 0x78) != 0x70) {
continue;
}
- //
+ /*
// Skip the offset
- //
+ */
c++;
}
c++;
- if (*c == 0x9d) {
- //
+ if (text_read_ub(c) == 0x9d) {
+ /*
// Increment cur_value to include the
// popf instruction
- //
+ */
cur_value++;
found = 1;
break;
if(found) {
*instr_len=cur_value-prev_value;
off=prev_value;
- if(1 || verbose) {
+ if(verbose) {
printk("%s", name);
if (d) printk("+0x%x", d);
printk(" @ %x, ", value);
printk("instr @ %x, len=%d, ", off, *instr_len);
+#if 0
// db_disasm(prev_value, FALSE);
+#endif
}
return off;
} else {
void db_clear_watchpoints __P((void));
db_addr_t db_disasm __P((db_addr_t loc, boolean_t altfmt));
/* instruction disassembler */
+#if 0
//void db_error __P((char *s));
+#endif
#define db_error printk
int db_expression __P((db_expr_t *valuep));
int db_get_variable __P((db_expr_t *valuep));
unsigned long new;
} swifi_result_t, *pswifi_result_t;
+long
+sys_inject_fault(char * module,
+ unsigned long argFaultType,
+ unsigned long argRandomSeed,
+ unsigned long argNumFaults,
+ pswifi_result_t result_record,
+ unsigned long argInjectFault);
-#endif // _SWIFI_USER_H
+#endif /* _SWIFI_USER_H */
#ifndef _LINUX_SWIFI_H
#define _LINUX_SWIFI_H
+#include <stdlib.h>
+
#include "swifi-user.h"
long
swifi_kmalloc(size_t size, int flags);
+#if 0
void *
swifi___vmalloc(unsigned long size, int gfp_mask, pgprot_t prot);
-
+#endif
-#endif // _LINUX_SWIFI_H
+#endif /* _LINUX_SWIFI_H */