示例#1
0
/* Format access codes nicely and try to make an educated guess regarding memory-region */
static void access_output(int acc, long long from, long long to, void *stack_frame)
{
    if (acc == 1)      /*  read  only  */
    {
        if (is_code(from, to))
            printf("(CODE) ");
        else
            printf("(UNKN) ");

        printf("read access from \t \t 0x%08llx to 0x%08llx\n", from, to);

    }
    else if (acc == 2) /* read & write */
    {
        if (is_data(from, to))
            printf("(DATA) ");
        else if (is_heap(from, to))
            printf("(HEAP) ");
        else if (is_stck(from, to, stack_frame))
            printf("(STCK) ");
        else
            printf("(UNKN) ");

        printf("read and write access from \t 0x%08llx to 0x%08llx\n", from, to);
    }
    return;
}
示例#2
0
文件: slave.c 项目: Chen-Zhe/MDP-Grp2
// If it's not a data byte, beeps, backs up one, and returns true.
char check_data_byte(char byte)
{
	if(is_data(byte))
		return 0;

	play("o3c");

	clear();
	print("Bad data");
	lcd_goto_xy(0,1);
	print_hex_byte(byte);

	previous_byte();
	return 1;
}
示例#3
0
文件: wavData.c 项目: liuyang1/test
int main( int argc, char **argv ) {
	if (argc <= 1) {
		usage( argv[0] );
		return 0;
	}

	char *fn_in = argv[1];
	FILE *fp_in = fopen( fn_in, "rb" );
	if (fp_in == NULL) {
		fprintf( stderr, "cannot open file=%s\n", fn_in );
		goto error;
	}

	// search 'data' header
	char fourcc[BYTES] = {0};
	int c;
	size_t i, j;
	for (i = 0; !is_data( fourcc, i ); i++ ) {
		c = fgetc( fp_in );
		if (c == EOF) {
			fprintf( stderr, "file=%s i=%lu: file is too short\n", fn_in, i );
			goto error;
		}
		fourcc[i % BYTES] = c;
	}
	// eat 4 bytes, which store data's length
	for (j = 0; j != BYTES; i++, j++) {
		fgetc( fp_in );
	}

#define		FILENAME_LEN	4096
	char fn_out[FILENAME_LEN] = {0};
	int len = snprintf( fn_out, FILENAME_LEN, "%s.raw", fn_in );
	if (len == FILENAME_LEN) {
		fprintf( stderr, "output filename=%s is too long\n", fn_out );
		goto error;
	}
	FILE *fp_out = fopen( fn_out, "wb" );
	trans( fp_in, fp_out );

	fclose( fp_in );
	fclose( fp_out );
	return 0;
error:
	fclose( fp_in );
	return -1;
}
address* Relocation::pd_address_in_code() {
  // All embedded Intel addresses are stored in 32-bit words.
  // Since the addr points at the start of the instruction,
  // we must parse the instruction a bit to find the embedded word.
  assert(is_data(), "must be a DataRelocation");
  typedef Assembler::WhichOperand WhichOperand;
  WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm/imm32
#ifdef AMD64
  assert(which == Assembler::disp32_operand ||
         which == Assembler::call32_operand ||
         which == Assembler::imm_operand, "format unpacks ok");
  // The "address" in the code is a displacement can't return it as
  // and address* since it is really a jint*
  guarantee(which == Assembler::imm_operand, "must be immediate operand");
#else
  assert(which == Assembler::disp32_operand || which == Assembler::imm_operand, "format unpacks ok");
#endif // AMD64
  return (address*) Assembler::locate_operand(addr(), which);
}
address Relocation::pd_get_address_from_code() {
#ifdef AMD64
  // All embedded Intel addresses are stored in 32-bit words.
  // Since the addr points at the start of the instruction,
  // we must parse the instruction a bit to find the embedded word.
  assert(is_data(), "must be a DataRelocation");
  typedef Assembler::WhichOperand WhichOperand;
  WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm/imm32
  assert(which == Assembler::disp32_operand ||
         which == Assembler::call32_operand ||
         which == Assembler::imm_operand, "format unpacks ok");
  if (which != Assembler::imm_operand) {
    address ip = addr();
    address disp = Assembler::locate_operand(ip, which);
    address next_ip = Assembler::locate_next_instruction(ip);
    address a = next_ip + *(int32_t*) disp;
    return a;
  }
#endif // AMD64
  return *pd_address_in_code();
}
示例#6
0
void AttributeType::attr_free() {
    if (size()) {
        if (is_string()) {
            delete [] u_.string;
        } else if (is_data()) {
            delete [] u_.data;
        } else if (is_list()) {
            for (unsigned i = 0; i < size(); i++) {
                u_.list[i].attr_free();
            }
            delete [] u_.list;
        } else if (is_dict()) {
            for (unsigned i = 0; i < size(); i++) {
                u_.dict[i].key_.attr_free();
                u_.dict[i].value_.attr_free();
            }
            delete [] u_.dict;
        }
    }
    kind_ = Attr_Invalid;
    size_ = 0;
}
示例#7
0
bool bare_expr_type::operator>=(const bare_expr_type& bare_type) const {
  if (is_data() == bare_type.is_data())
    return order_id() >= bare_type.order_id();
  return is_data() >= bare_type.is_data();
}