示例#1
0
文件: ptrace04.c 项目: GOEUM/ltp
int main(int argc, char *argv[])
{
	char *msg;

	if (ARRAY_SIZE(regs) == 0)
		tst_brkm(TCONF, NULL, "test not supported for your arch (yet)");

	if ((msg = parse_opts(argc, argv, NULL, NULL)))
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	make_a_baby(argc, argv);

	/* first compare register states when execl() syscall starts */
	tst_resm(TINFO, "Before exec() in child");
	compare_registers(0x00);
	compare_registers(0xff);

	/* then compare register states after execl() syscall finishes */
	tst_resm(TINFO, "After exec() in child");
	errno = 0;
	if (ptrace(PTRACE_SYSCALL, pid, NULL, NULL) && errno) {
		tst_resm(TFAIL, "PTRACE_SYSCALL failed: %s", strerror(errno));
		tst_exit();
	}
	compare_registers(0x00);
	compare_registers(0xff);

	/* hopefully this worked */
	ptrace(PTRACE_KILL, pid, NULL, NULL);

	tst_exit();
}
示例#2
0
文件: public12.c 项目: Foshie/Classes
int main() {
  Mem mem[SZ]= {0};
  short registers[NUM_REGISTERS]= {0};
  short exp_registers[NUM_REGISTERS]= {0, 3, 5, 9, 14, 4, 0xfe, 0xa};
  int num_instructions;
  Status ret;

  num_instructions= assemble("public12.a", &mem[10]);

  if (num_instructions == 0)
    printf("Regretfully the program couldn't be assembled.  Bye.\n");
  else {

    ret= execute_program(mem, registers, 20, num_instructions, 0);

    if (ret != TERMINATED)
      printf("execute_program() returned unexpected value (%d).\n", ret);
    else

      if ((ret= compare_registers(registers, exp_registers, 0, 8)) != -1) {

        printf("Registers appear incorrect after execute_program() call.\n");
        printf("First incorrect register is %d (%d instead of %d).\n",
               ret, registers[ret], exp_registers[ret]);

      } else printf("Registers are correct after execute_program() call!\n");

  }

  return 0;
}
示例#3
0
文件: public03.c 项目: Foshie/Classes
int main() {
  Mem mem[SZ];
  short registers[NUM_REGISTERS]= {0, 11, 9, 7, 5, 2, 0, 0};
  short exp_registers[NUM_REGISTERS]= {0, 0, 1, 1, 1, 5};
  int num_instructions;
  Status ret;

  num_instructions= assemble("public03.a", mem);

  if (num_instructions == 0)
    printf("Regretfully the program couldn't be assembled.  Bye.\n");
  else {

    ret= execute_program(mem, registers, 0, num_instructions, 0);

    if (ret != ACTIVE)  /* because there's no halt instruction */
      printf("execute_program() returned unexpected value (%d).\n", ret);
    else
      if ((ret= compare_registers(registers, exp_registers, 1, 5)) != -1) {
        printf("Registers appear incorrect after execute_program() call.\n");
        printf("First incorrect register is %d (%d instead of %d).\n",
               ret, registers[ret], exp_registers[ret]);
      } else printf("Registers are correct after execute_program() call!\n");

  }

  return 0;
}