Beispiel #1
0
void run_debugger(void) {
	int i;
    show_mainui();
    ui_refresh();

    ice.regs->flags &= ~TF_MASK;
    
    if(ice.regs->int_no != 1)
		output_print("Break due to INT 0x%lX", ice.regs->int_no);
	
	fn_show_stack = fn_kallsyms_lookup_name("show_stack");
	
	if(fn_show_stack){
		//fn_show_stack(current, ice.regs->sp);
	}else{
		printk(KERN_ALERT "not found show stack\n");
	}
	
    while(1) {
        if(exec_command(get_command())) {
            clear_command();
            break;
        }

        clear_command();
        //for (i = 0; i < 100000000; i++);
        //break;
    }

    unhook_idt(0xef);
    ice.running_state = NOT_RUNNING;
}
Beispiel #2
0
void ui_attach_impl(UI *ui)
{
  if (ui_count == MAX_UI_COUNT) {
    abort();
  }
  if (!ui->ui_ext[kUIMultigrid] && !ui->ui_ext[kUIFloatDebug]) {
    ui_comp_attach(ui);
  }

  uis[ui_count++] = ui;
  ui_refresh_options();

  for (UIExtension i = kUIGlobalCount; (int)i < kUIExtCount; i++) {
    ui_set_ext_option(ui, i, ui->ui_ext[i]);
  }

  bool sent = false;
  if (ui->ui_ext[kUIHlState]) {
    sent = highlight_use_hlstate();
  }
  if (!sent) {
    ui_send_all_hls(ui);
  }
  ui_refresh();
}
Beispiel #3
0
void ui_detach(UI *ui)
{
  size_t shift_index = MAX_UI_COUNT;

  // Find the index that will be removed
  for (size_t i = 0; i < ui_count; i++) {
    if (uis[i] == ui) {
      shift_index = i;
      break;
    }
  }

  if (shift_index == MAX_UI_COUNT) {
    abort();
  }

  // Shift UIs at "shift_index"
  while (shift_index < ui_count - 1) {
    uis[shift_index] = uis[shift_index + 1];
    shift_index++;
  }

  if (--ui_count) {
    ui_refresh();
  }
}
Beispiel #4
0
void ui_attach(UI *ui)
{
  if (ui_count == MAX_UI_COUNT) {
    abort();
  }

  uis[ui_count++] = ui;
  ui_refresh();
}
Beispiel #5
0
Datei: ui.c Projekt: SLieng/nvm
void ui_attach_impl(UI *ui)
{
  if (ui_count == MAX_UI_COUNT) {
    abort();
  }

  uis[ui_count++] = ui;
  ui_refresh_options();
  ui_refresh();
}
Beispiel #6
0
void ui_set_ext_option(UI *ui, UIExtension ext, bool active)
{
  if (ext < kUIGlobalCount) {
    ui_refresh();
    return;
  }
  if (ui->option_set) {
    ui->option_set(ui, cstr_as_string((char *)ui_ext_names[ext]),
                   BOOLEAN_OBJ(active));
  }
}
Beispiel #7
0
void ui_set_ext_option(UI *ui, UIExtension ext, bool active)
{
  if (ext < kUIGlobalCount) {
    ui_refresh();
    return;
  }
  if (ui->option_set && (ui_ext_names[ext][0] != '_' || active)) {
    ui->option_set(ui, cstr_as_string((char *)ui_ext_names[ext]),
                   BOOLEAN_OBJ(active));
  }
  if (ext == kUITermColors) {
    ui_default_colors_set();
  }
}
Beispiel #8
0
static void ui_set_option(UI *ui, bool init, String name, Object value,
                          Error *error)
{
  if (strequal(name.data, "rgb")) {
    if (value.type != kObjectTypeBoolean) {
      api_set_error(error, kErrorTypeValidation, "rgb must be a Boolean");
      return;
    }
    ui->rgb = value.data.boolean;
    // A little drastic, but only legacy uis need to use this option
    if (!init) {
      ui_refresh();
    }
    return;
  }

  // LEGACY: Deprecated option, use `ext_cmdline` instead.
  bool is_popupmenu = strequal(name.data, "popupmenu_external");

  for (UIExtension i = 0; i < kUIExtCount; i++) {
    if (strequal(name.data, ui_ext_names[i])
        || (i == kUIPopupmenu && is_popupmenu)) {
      if (value.type != kObjectTypeBoolean) {
        snprintf((char *)IObuff, IOSIZE, "%s must be a Boolean",
                 name.data);
        api_set_error(error, kErrorTypeValidation, (char *)IObuff);
        return;
      }
      bool boolval = value.data.boolean;
      if (!init && i == kUINewgrid && boolval != ui->ui_ext[i]) {
        // There shouldn't be a reason for an UI to do this ever
        // so explicitly don't support this.
        api_set_error(error, kErrorTypeValidation,
                      "ext_newgrid option cannot be changed");
      }
      ui->ui_ext[i] = boolval;
      if (!init) {
        ui_set_ext_option(ui, i, boolval);
      }
      return;
    }
  }

  api_set_error(error, kErrorTypeValidation, "No such UI option: %s",
                name.data);
}
Beispiel #9
0
void
cons_debug(const char * const msg, ...)
{
    if (strcmp(PACKAGE_STATUS, "development") == 0) {
        va_list arg;
        va_start(arg, msg);
        GString *fmt_msg = g_string_new(NULL);
        g_string_vprintf(fmt_msg, msg, arg);
        win_print_time(console, '-');
        wprintw(console->win, "%s\n", fmt_msg->str);
        g_string_free(fmt_msg, TRUE);
        va_end(arg);

        ui_console_dirty();
        cons_alert();

        ui_current_page_off();
        ui_refresh();
    }
}
Beispiel #10
0
static Object remote_ui_try_resize(uint64_t channel_id, uint64_t request_id,
                                   Array args, Error *error)
{
  if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
    api_set_error(error, Exception, _("UI is not attached for channel"));
  }

  if (args.size != 2 || args.items[0].type != kObjectTypeInteger
      || args.items[1].type != kObjectTypeInteger
      || args.items[0].data.integer <= 0 || args.items[1].data.integer <= 0) {
    api_set_error(error, Validation,
                  _("Invalid arguments. Expected: "
                    "(uint width > 0, uint height > 0)"));
    return NIL;
  }

  UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
  ui->width = (int)args.items[0].data.integer;
  ui->height = (int)args.items[1].data.integer;
  ui_refresh();
  return NIL;
}
Beispiel #11
0
static void ui_refresh_event(void **argv)
{
  ui_refresh();
}
Beispiel #12
0
int main(int argc, char *argv[]) {
  FILE *fp;
  Result res;
  Entry *root;
  char *path, *locale;
  int opt;

#ifdef SCR_WIDTH
  ui_scr_width = SCR_WIDTH;
#else
  ui_scr_width = 0;
#endif

  locale = "";
  while ((opt = getopt(argc, argv, "hvl:w:b")) != -1) {
    switch (opt) {
      case 'b':
        use_term_colors = !use_term_colors;
        break;
      case 'w':
        ui_scr_width = atoi(optarg);
        if (ui_scr_width < 0) {
          fprintf(stderr, "WARN: Wrong width value, fixed-column is off\n");
          fprintf(stderr, "Press enter to continue.\n");
          fgetc(stdin);
          ui_scr_width = 0;
        }
        break;
      case 'l':
        locale = optarg;
        break;
      case 'v':
        version();
        break;
      case 'h':
      default:
        usage(argv[0]);
        break;
    }
  }

  fp = NULL;

  if (setlocale(LC_ALL, locale) == NULL) {
    fprintf(stderr, "WARN: Couldn't change LC_ALL to '%s'\n", locale);
    fprintf(stderr, "Press enter to continue.\n");
    fgetc(stdin);
  }

  if (optind < argc) {
    fp = fopen(argv[optind], "r");
    if (fp == NULL) {
      perror("Can't open your file");
      exit(1);
    }
    path = argv[optind];
  }
#ifdef DEFAULT_FILE
  else {
    fp = fopen(DEFAULT_FILE, "r");
    path = DEFAULT_FILE;
  }
#endif

  UI_File.path = NULL;
  if (fp) {
    res = data_load(fp);
    UI_File.loaded = true;
    UI_File.path = realpath(path, NULL);
    if (!UI_File.path) {
      perror("Couldn't resolve path");
      exit(3);
    }
    fclose(fp);
  } else {
    res = entry_new(32);
    UI_File.loaded = false;
  }

  if (!res.success) {
    fwprintf(stderr, L"ERROR: %S.\n", res.msg);
    perror("Unix error");
    exit(2);
  }

  ui_start();

  root = (Entry *)res.data;
  if (!fp)
    root->length = 0;
  res = ui_set_root(root);
  if (!res.success) {
    fwprintf(stderr, L"ERROR: %S.\n", res.msg);
    perror("Unix error");
    exit(3);
  }
  ui_refresh();

  ui_mainloop();
  ui_stop();

  res = ui_get_root();
  if (!res.success) {
    fwprintf(stderr, L"ERROR: %S.\n", res.msg);
    perror("Unix error");
    exit(4);
  }

  data_unload((Entry *)res.data);
  free(UI_File.path);

  return 0;
}