⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdb-5.3-bdm-m68k.patch

📁 WaitForSingleObject 摩托罗拉的68k源程序
💻 PATCH
📖 第 1 页 / 共 4 页
字号:
+    if (cnt <= 1)  {+      return(1);+    }+  }++  return(-1);+}++int+cf_insert_hw_breakpoint(addr, shadow)+  CORE_ADDR addr;+  char *shadow;+{+  unsigned long tdr;++  if (cpu_type != BDM_COLDFIRE)  {+    return(-1);+  }++  if (cf_breakpoint_count < CF_BREAKPOINT_MAX)  {+    cf_breakpoints[cf_breakpoint_count].type = hw_execute;+    cf_breakpoints[cf_breakpoint_count].addr = addr;+    cf_breakpoints[cf_breakpoint_count++].len = 2;++    if (bdmReadSystemRegister (BDM_REG_TDR, &tdr) < 0)+      bdm_report_error ();+    tdr = ((tdr & ~TDR_L1_ALL) | (TDR_L1_EBL|TDR_L1_EPC));+    if (bdmWriteSystemRegister (BDM_REG_PBR, addr) < 0)+      bdm_report_error ();+    if (bdmWriteSystemRegister (BDM_REG_PBMR, 0) < 0)+      bdm_report_error ();+    if (bdmWriteSystemRegister (BDM_REG_TDR, tdr) < 0)+      bdm_report_error ();+    if (bdmDebugLevel)+      printf_filtered ("Insert PC Breakpoint @0x%08lx\n", addr);+  }+  else  {+    return(-1);+  }+  return(0);+}++static int+cf_check_breakpoint(type, addr, len)+  enum target_hw_bp_type type;+  CORE_ADDR addr;+  int len;+{+  int i;++  for (i = 0; i < cf_breakpoint_count; i++)  {+    if (cf_breakpoints[i].type == type &&+        cf_breakpoints[i].addr == addr &&+        cf_breakpoints[i].len == len)  {+      for (; i < CF_BREAKPOINT_MAX-1; i++)  {+        cf_breakpoints[i] = cf_breakpoints[i+1];+      }+      cf_breakpoint_count--;+      return(1);+    }+  }+  return(0);+}++int+cf_remove_hw_breakpoint(addr, shadow)+  CORE_ADDR addr;+  char *shadow;+{+  unsigned long tdr;+  unsigned long csr;++  if (cpu_type != BDM_COLDFIRE)  {+    return(-1);+  }++  if (cf_check_breakpoint(hw_execute, addr, 2))  {+    if (bdmReadSystemRegister (BDM_REG_TDR, &tdr) < 0)+      bdm_report_error ();+    tdr &= ~TDR_L1_EPC;+    if ((tdr & TDR_L1_ALL) == 0)  {+      tdr &= ~TDR_L1_EBL;+    }+    if (bdmWriteSystemRegister (BDM_REG_TDR, tdr) < 0)+      bdm_report_error ();+    if (bdmDebugLevel)+      printf_filtered ("Remove PC Breakpoint @0x%08lx\n", addr);+  }+  else  {+    return(-1);+  }+  return(0);+}++#define AATR_READONLY  0x7F85+#define AATR_WRITEONLY 0x7F05+#define AATR_READWRITE 0xFF05++int+cf_insert_watchpoint(addr, len, type)+  CORE_ADDR addr;+  int len;+  enum target_hw_bp_type type;+{+  unsigned long tdr;++  if (cpu_type != BDM_COLDFIRE)  {+    return(-1);+  }++  if (cf_breakpoint_count < CF_BREAKPOINT_MAX)  {+    cf_breakpoints[cf_breakpoint_count].type = type;+    cf_breakpoints[cf_breakpoint_count].addr = addr;+    cf_breakpoints[cf_breakpoint_count++].len = len;++    if (bdmReadSystemRegister (BDM_REG_TDR, &tdr) < 0)+      bdm_report_error ();+    tdr = ((tdr & ~TDR_L1_ALL) | (TDR_L1_EBL|TDR_L1_EAR));+    if (bdmWriteSystemRegister (BDM_REG_ABLR, addr) < 0)+      bdm_report_error ();+    if (bdmWriteSystemRegister (BDM_REG_ABHR, addr+len-1) < 0)+      bdm_report_error ();+    if (type == hw_read)  {+      if (bdmWriteSystemRegister (BDM_REG_AATR, AATR_READONLY) < 0)+        bdm_report_error ();+      if (bdmDebugLevel)+        printf_filtered ("Insert read Watchpoint @0x%08lx-0x%08lx\n",+                         addr, addr+len-1);+    }+    else if (type == hw_write)  {+      if (bdmWriteSystemRegister (BDM_REG_AATR, AATR_WRITEONLY) < 0)+        bdm_report_error ();+      if (bdmDebugLevel)+        printf_filtered ("Insert write Watchpoint @0x%08lx-0x%08lx\n",+                         addr, addr+len-1);+    }+    else  {+      if (bdmWriteSystemRegister (BDM_REG_AATR, AATR_READWRITE) < 0)+        bdm_report_error ();+      if (bdmDebugLevel)+        printf_filtered ("Insert access Watchpoint @0x%08lx-0x%08lx\n",+                         addr, addr+len-1);+    }+    if (bdmWriteSystemRegister (BDM_REG_TDR, tdr) < 0)+      bdm_report_error ();+  }+  else  {+    return(-1);+  }+  return(0);+}++int+cf_remove_watchpoint(addr, len, type)+  CORE_ADDR addr;+  int len;+  enum target_hw_bp_type type;+{+  unsigned long tdr;+  unsigned long csr;++  if (cpu_type != BDM_COLDFIRE)  {+    return(-1);+  }++  if (cf_check_breakpoint(type, addr, len))  {+    if (bdmReadSystemRegister (BDM_REG_TDR, &tdr) < 0)+      bdm_report_error ();+    tdr &= ~TDR_L1_EAR;+    if ((tdr & TDR_L1_ALL) == 0)  {+      tdr &= ~TDR_L1_EBL;+    }+    if (bdmWriteSystemRegister (BDM_REG_TDR, tdr) < 0)+      bdm_report_error ();+    if (bdmDebugLevel)+      printf_filtered ("Remove %s Watchpoint @0x%08lx-0x%08lx\n",+                       (type == hw_read) ? "read" :+                        ((type == hw_write) ? "write" : "access"),+                       addr, addr+len-1);+  }+  else  {+    return(-1);+  }+  return(0);+}++int+cf_stopped_data_address()+{+  unsigned long tdr;+  unsigned long ablr;++  if (cpu_type != BDM_COLDFIRE)  {+    return(-1);+  }++  if (bdmReadSystemRegister (BDM_REG_TDR, &tdr) < 0)+    bdm_report_error ();+  if (bdmReadSystemRegister (BDM_REG_ABLR, &ablr) < 0)+    bdm_report_error ();++  if (tdr & TDR_L1_EAR)  {+    return(ablr);+  }+  return(0);+}++/* This is called not only when we first attach, but also when the+   user types "run" after having attached.  */+void+bdm_create_inferior (char *execfile, char *args, char **env)+{+  char *prg_file = NULL;+  unsigned long entry_pt;++  clear_proceed_status ();+  init_wait_for_inferior ();+  if (*args) {+    prg_file = args;+  }+  else {+    prg_file = execfile;+  }+  if (!(prg_file) && !(bdm_prog_loaded))+    error ("No program specified to run\n");+  else+  {+    if (!bdm_no_load) {+      if (bdm_prog_loaded)+        printf_filtered ("Note: `%s' has already been loaded.\n",+                         bdm_prog_loaded);+      if (query ("Do you want to download `%s'?", prg_file))+        bdm_load (prg_file, 0);+      if (bdmReadSystemRegister (BDM_REG_RPC, &entry_pt) < 0)+        bdm_report_error ();+    }+    proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);+  }+  inferior_ptid = pid_to_ptid (1);+}++/*+ * Fetch register REGNO, or all user registers if REGNO is -1.+ */+static void+bdm_fetch_register (int regno)+{+  unsigned long l;+  char cbuf[4];+  int ret;++  if (regno < 0) {+    for (regno = 0 ; regno < NUM_REGS ; regno++)+      bdm_fetch_register (regno);+  }+  else {+    /*+     * When the target is running the +     * cpu registers can not be accessed.+     */+    if (bdm_gdb_no_wait && (bdm_get_status () == 0)) {+      l = 0;+      ret = 0;+     }+    else {+      if (regno < 16) {+        ret = bdmReadRegister (regno, &l);+      }+      else {+        if ((regno - 16) < (sizeof (reg_to_dev_num) / sizeof (int))) {+          ret = bdmReadSystemRegister (reg_to_dev_num[regno - 16], &l);+        }+        else {+          error ("Bad register number (%d)", regno); +          return;+        }+      }+    }+    if (ret < 0)+      bdm_report_error ();+    cbuf[0] = l >> 24;+    cbuf[1] = l >> 16;+    cbuf[2] = l >> 8;+    cbuf[3] = l;+    supply_register (regno, cbuf);+  }+}++void+bdm_prepare_to_store (void)+{+  /* Do nothing, since we can store individual regs */+}++/*+ * Store register REGNO, or all user registers if REGNO == -1.+ */+void+bdm_store_register (int regno)+{+  unsigned long l;+  int ret;++  if (bdm_gdb_no_wait && (bdm_get_status () == 0))+    return;+  +  if (regno == -1) {+    for (regno = 0 ; regno < NUM_REGS ; regno++)+      bdm_store_register (regno);+  }+  else {+    l = read_register (regno);+    if (regno < 16) {+      ret = bdmWriteRegister (regno, l);+    }+    else {+      if ((regno - 16) < (sizeof (reg_to_dev_num) / sizeof (int))) {+        ret = bdmWriteSystemRegister (reg_to_dev_num[regno - 16], l);+      }+      else {+        error ("Bad register number (%d)", regno); +        return;+      }+    }+    if (ret < 0)+      bdm_report_error ();+  }+}++/*+ * Transfer memory contents between target and host+ */+static int+bdm_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr,+                          int len, int write,+                          struct  mem_attrib *attrib,+                          struct target_ops *t)+{+  int ret;++  if (write)+    ret = bdmWriteMemory (memaddr, myaddr, len);+  else+    ret = bdmReadMemory (memaddr, myaddr, len);+  if (ret < 0)+    bdm_report_error ();+  return len;+}++static void+bdm_files_info (struct target_ops *t)+{+  printf_filtered ("target %s is attached to %s\n", t->to_shortname, dev_name);+  if (bdm_prog_loaded) {+    printf_filtered ("and running program %s\n", bdm_prog_loaded);+  }+  else {+    printf_filtered ("no program loaded\n");+  }+}++/*+ * Load a file.+ */+static void+bdm_load (char *args, int from_tty)+{+  char *p;++  if (bdm_prog_loaded) {+    free (bdm_prog_loaded);+    bdm_prog_loaded = NULL;+  }+  if (!args) {+    error (+     "The bdmload command must include the filename to load.\n"+           "You may want to use 'run', which uses the file given\n"+         "on the command line when gdb was invoked.");+  }+  if ((bdm_get_status () & BDM_TARGETSTOPPED) == 0)+    bdm_stop_chip ();++  /* strip off additional (unwanted) arguments after file name */+  for (p = args; (*p != '\0') && (!isspace (*p)); p++) ;+  *p = '\0';++  if (loadExecutable (args) < 0)+    error ("%s", downloadErrorString);+  bdm_prog_loaded = savestring (args, strlen (args));+}++/*+ * Toggle the no load variable.+ */+static void+bdm_toggle_no_load (char *args, int from_tty)+{+  if (bdm_no_load) {+    bdm_no_load = 0;+    printf_filtered ("Image not loaded on run\n");+  }+  else {+    bdm_no_load = 1;+    printf_filtered ("Image loaded on run\n");+  }+}++/*+ * Select a CPU32 processor register set.+ */+static void+bdm_select_cpu32 (char *args, int from_tty)+{+  bdm_reg_names = cpu32_reg_names;+}++struct target_ops bdm_ops;++static void+init_bdm_ops(void)+{+  bdm_ops.to_shortname = "bdm";+  bdm_ops.to_longname = "CPU32 and Coldfire Background Debug Mode Interface for downloading and remote debugging";+  bdm_ops.to_doc = "Uses the Public Domain Background Debug Mode Interface connected to the\n"+"BDM-port of the CPU32 or Coldfire based microcontroller and to a parallel port\n"+"of the PC.\n"+"Usage: target bdm <device>\n"+"where <device> is the BDM character special file (e.g. /dev/bdm0).";+  bdm_ops.to_open = bdm_open;+  bdm_ops.to_close = bdm_close;+  bdm_ops.to_detach = bdm_detach;+  bdm_ops.to_resume = bdm_resume;+  bdm_ops.to_wait = bdm_wait;+  bdm_ops.to_fetch_registers = bdm_fetch_register;+  bdm_ops.to_store_registers = bdm_store_register;+  bdm_ops.to_prepare_to_store = bdm_prepare_to_store;+  bdm_ops.to_xfer_memory = bdm_xfer_inferior_memory;+  bdm_ops.to_files_info = bdm_files_info;+  bdm_ops.to_insert_breakpoint = memory_insert_breakpoint;+  bdm_ops.to_remove_breakpoint = memory_remove_breakpoint;+  bdm_ops.to_kill = bdm_kill;+  bdm_ops.to_load = bdm_load;+  bdm_ops.to_stop = bdm_stop_chip;+  bdm_ops.to_create_inferior = bdm_create_inferior;+  bdm_ops.to_mourn_inferior = generic_mourn_inferior;+  bdm_ops.to_can_run = bdm_can_run;+  bdm_ops.to_stratum = process_stratum;+  bdm_ops.to_has_all_memory = 1;+  bdm_ops.to_has_memory = 1;+  bdm_ops.to_has_stack = 1;+  bdm_ops.to_has_registers = 1;+  bdm_ops.to_has_execution = 1;+  bdm_ops.to_magic = OPS_MAGIC;+};++void+_initialize_remote_bdmcf (void)+{+  init_bdm_ops ();+  add_com ("bdm_reset", class_obscure,+     (void (*)(char *, int))bdm_reset,+     "Reset target and enter BDM mode.");+  add_com ("bdm_release", class_obscure,+     (void (*)(char *, int))bdm_release_chip,+     "Reset target without BDM-mode.");+  add_com ("bdm_status", class_obscure,+     (void (*)(char *, int))bdm_get_status_interactive,+     "Show status of bdm interface\n");+  add_com ("bdm_setdelay", class_obscure,+     bdm_setdelay_interactive,+     "set delay for download");+  add_com ("bdm_setdebug", class_obscure,+     bdm_setdebug_interactive,+     "enable/disable BDM diagnostic messages");+  add_com ("bdm_setdriverdebug", class_obscure,+     bdm_setdriverdebug_interactive,+     "enable/disable BDM driver diagnostic messages");+  add_com ("bdm_no_wait", class_obscure,+     bdm_set_no_wait,+     "Cause GDB to not wait for the target to stop when running.");+  add_com ("bdm_wait", class_obscure,+     bdm_set_wait,+     "Cause GDB to wait for the target to stop when running.");+  add_com ("bdm_stop", class_obscure,+     bdm_issue_stop,+     "Stop the target if running.");+  add_com ("bdm-select-cpu32", class_obscure,+     bdm_select_cpu32,+     "Selects the CPU32 register set rather than the default CPU32+.");+  add_com ("bdm-no-load", class_obscure,+     bdm_toggle_no_load,+     "Toggle the loading of the program to memory when asked to run.");+           +  add_target (&bdm_ops);+}diff -Nru insight-5.3.orig/gdb/infcmd.c insight-5.3/gdb/infcmd.c--- insight-5.3.orig/gdb/infcmd.c	2003-11-18 23:46:48.000000000 +0100+++ insight-5.3/gdb/infcmd.c	2003-11-19 10:19:02.000000000 +0100@@ -1337,8 +1337,10 @@ 			    "finish_command: function has no target type");  	  /* FIXME: Shouldn't we do the cleanups before returning? */-	  if (TYPE_CODE (value_type) == TYPE_CODE_VOID)+	  if (TYPE_CODE (value_type) == TYPE_CODE_VOID) {+	    do_cleanups (old_chain); 	    return;+	  }  	  funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function)); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -