Exemplo n.º 1
0
Arquivo: main.c Projeto: samsymons/TDB
void start_debugger(pid_t target_pid) {
  int status;
  wait(&status);

  struct user_regs_struct initial_registers;
  trace_get_registers(target_pid, &initial_registers);

  // Peek at a specific address:

  unsigned bp_addr = 0x4000b0;
  breakpoint *bp = breakpoint_create(target_pid, (void *)bp_addr);

  trace_continue(target_pid);
  wait(&status);

  while (1) {
    if (WIFSTOPPED(status)) {
      struct user_regs_struct registers;
      trace_get_registers(target_pid, &registers);
      printf("\nReached breakpoint at 0x%08llx\n", registers.rip);

      breakpoint_handle(target_pid, bp);

      int requesting_input = true;

      while (requesting_input) {
        input_option input = request_input(NULL);

        if (input == INPUT_CONTINUE) {
          trace_continue(target_pid);
          requesting_input = false;
        }
        else if (input == INPUT_SINGLE_STEP) {
          trace_single_step(target_pid);
          requesting_input = false;
        }
      }

      int resume_status;
      wait(&resume_status);

      if (WIFEXITED(resume_status)) {
        printf("Process %d exited\n", target_pid);
        return;
      }
      else if (WIFSTOPPED(resume_status)) {
        printf("Process %d stopped\n", target_pid);
        return;
      }
    }
    else if (WIFEXITED(status)) {
      printf("Process %d exited\n", target_pid);
      return;
    }
    else {
      puts("Returning");
      return;
    }
  }
}
Exemplo n.º 2
0
static int pptp_connect(struct vpn_provider *provider,
			struct connman_task *task, const char *if_name,
			vpn_provider_connect_cb_t cb, const char *dbus_sender,
			void *user_data)
{
	const char *username, *password;
	int err;

	DBG("iface %s provider %p user %p", if_name, provider, user_data);

	if (connman_task_set_notify(task, "getsec",
					pptp_get_sec, provider)) {
		err = -ENOMEM;
		goto error;
	}

	username = vpn_provider_get_string(provider, "PPTP.User");
	password = vpn_provider_get_string(provider, "PPTP.Password");

	DBG("user %s password %p", username, password);

	if (!username || !password) {
		struct pptp_private_data *data;

		data = g_try_new0(struct pptp_private_data, 1);
		if (!data)
			return -ENOMEM;

		data->task = task;
		data->if_name = g_strdup(if_name);
		data->cb = cb;
		data->user_data = user_data;

		err = request_input(provider, request_input_cb, dbus_sender,
									data);
		if (err != -EINPROGRESS) {
			free_private_data(data);
			goto done;
		}
		return err;
	}

done:
	return run_connect(provider, task, if_name, cb, user_data,
							username, password);

error:
	if (cb)
		cb(provider, user_data, err);

	return err;
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: samsymons/TDB
void handle_user_input(char *program_name) {
  while (1) {
    input_option input = request_input(NULL);

    if (input == INPUT_RUN) {
      begin_debugging(program_name);
    }
    else if (input == INPUT_CREATE_BREAKPOINT) {
      puts("New breakpoint!");
    }
    else if (input == INPUT_REMOVE_BREAKPOINT) {
      puts("Removing breakpoint!");
    }
    else if (input == INPUT_QUIT) {
      exit(0);
    }
    else {
      puts("Unknown input");
    }
  }
}