View | Details | Raw Unified | Return to bug 10645 | Differences between
and this patch

Collapse All | Expand All

(-)a/gdb/breakpoint.c (-11 / +43 lines)
Lines 1198-1204 update_watchpoint (struct breakpoint *b, int reparse) Link Here
1198
		  addr = value_address (v);
1198
		  addr = value_address (v);
1199
		  len = TYPE_LENGTH (value_type (v));
1199
		  len = TYPE_LENGTH (value_type (v));
1200
		  type = hw_write;
1200
		  type = hw_write;
1201
		  if (b->type == bp_read_watchpoint)
1201
		  if (v == val_chain && value_lazy (v))
1202
		    type = hw_mmap;
1203
		  else if (b->type == bp_read_watchpoint)
1204
1202
		    type = hw_read;
1205
		    type = hw_read;
1203
		  else if (b->type == bp_access_watchpoint)
1206
		  else if (b->type == bp_access_watchpoint)
1204
		    type = hw_access;
1207
		    type = hw_access;
Lines 1472-1480 Note: automatically using hardware breakpoints for read-only addresses.\n")); Link Here
1472
	      watchpoints.  It's not clear that it's necessary... */
1475
	      watchpoints.  It's not clear that it's necessary... */
1473
	   && bpt->owner->disposition != disp_del_at_next_stop)
1476
	   && bpt->owner->disposition != disp_del_at_next_stop)
1474
    {
1477
    {
1475
      val = target_insert_watchpoint (bpt->address, 
1478
      if (bpt->watchpoint_type == hw_mmap)
1476
				      bpt->length,
1479
	{
1477
				      bpt->watchpoint_type);
1480
	  struct inferior *inf = current_inferior ();
1481
1482
	  inf->trap_syscalls = 1;
1483
	  val = 0;
1484
	}
1485
      else
1486
	val = target_insert_watchpoint (bpt->address,
1487
					bpt->length,
1488
					bpt->watchpoint_type);
1478
      bpt->inserted = (val != -1);
1489
      bpt->inserted = (val != -1);
1479
    }
1490
    }
1480
1491
Lines 2100-2108 remove_breakpoint_1 (struct bp_location *b, insertion_state_t is) Link Here
2100
      struct value *n;
2111
      struct value *n;
2101
2112
2102
      b->inserted = (is == mark_inserted);
2113
      b->inserted = (is == mark_inserted);
2103
      val = target_remove_watchpoint (b->address, b->length, 
2114
      if (b->watchpoint_type == hw_mmap)
2104
				      b->watchpoint_type);
2115
	val = 0;
2105
2116
      else
2117
	val = target_remove_watchpoint (b->address, b->length,
2118
					b->watchpoint_type);
2106
      /* Failure to remove any of the hardware watchpoints comes here.  */
2119
      /* Failure to remove any of the hardware watchpoints comes here.  */
2107
      if ((is == mark_uninserted) && (b->inserted))
2120
      if ((is == mark_uninserted) && (b->inserted))
2108
	warning (_("Could not remove hardware watchpoint %d."),
2121
	warning (_("Could not remove hardware watchpoint %d."),
Lines 3162-3167 watchpoints_triggered (struct target_waitstatus *ws) Link Here
3162
  return 1;
3175
  return 1;
3163
}
3176
}
3164
3177
3178
void
3179
mmap_watchpoints_triggered (void)
3180
{
3181
  struct breakpoint *b;
3182
3183
  ALL_BREAKPOINTS (b)
3184
    if (b->type == bp_hardware_watchpoint)
3185
      {
3186
	struct bp_location *loc;
3187
3188
	for (loc = b->loc; loc; loc = loc->next)
3189
	  if (loc->watchpoint_type == hw_mmap)
3190
	    {
3191
	      b->watchpoint_triggered = watch_triggered_yes;
3192
	      break;
3193
	    }
3194
      }
3195
}
3196
3165
/* Possible return values for watchpoint_check (this can't be an enum
3197
/* Possible return values for watchpoint_check (this can't be an enum
3166
   because of check_errors).  */
3198
   because of check_errors).  */
3167
/* The watchpoint has been deleted.  */
3199
/* The watchpoint has been deleted.  */
Lines 7084-7090 watch_command_1 (char *arg, int accessflag, int from_tty) Link Here
7084
  struct breakpoint *b, *scope_breakpoint = NULL;
7116
  struct breakpoint *b, *scope_breakpoint = NULL;
7085
  struct expression *exp;
7117
  struct expression *exp;
7086
  struct block *exp_valid_block;
7118
  struct block *exp_valid_block;
7087
  struct value *val, *mark;
7119
  struct value *val, *mark, *result;
7088
  struct frame_info *frame;
7120
  struct frame_info *frame;
7089
  char *exp_start = NULL;
7121
  char *exp_start = NULL;
7090
  char *exp_end = NULL;
7122
  char *exp_end = NULL;
Lines 7171-7177 watch_command_1 (char *arg, int accessflag, int from_tty) Link Here
7171
7203
7172
  exp_valid_block = innermost_block;
7204
  exp_valid_block = innermost_block;
7173
  mark = value_mark ();
7205
  mark = value_mark ();
7174
  fetch_watchpoint_value (exp, &val, NULL, NULL);
7206
  fetch_watchpoint_value (exp, &val, &result, NULL);
7175
  if (val != NULL)
7207
  if (val != NULL)
7176
    release_value (val);
7208
    release_value (val);
7177
7209
Lines 7206-7212 watch_command_1 (char *arg, int accessflag, int from_tty) Link Here
7206
  mem_cnt = can_use_hardware_watchpoint (val);
7238
  mem_cnt = can_use_hardware_watchpoint (val);
7207
  if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
7239
  if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
7208
    error (_("Expression cannot be implemented with read/access watchpoint."));
7240
    error (_("Expression cannot be implemented with read/access watchpoint."));
7209
  if (mem_cnt != 0)
7241
  if (mem_cnt != 0 || !val)
7210
    {
7242
    {
7211
      i = hw_watchpoint_used_count (bp_type, &other_type_used);
7243
      i = hw_watchpoint_used_count (bp_type, &other_type_used);
7212
      target_resources_ok = 
7244
      target_resources_ok = 
Lines 7221-7227 watch_command_1 (char *arg, int accessflag, int from_tty) Link Here
7221
7253
7222
  /* Change the type of breakpoint to an ordinary watchpoint if a hardware
7254
  /* Change the type of breakpoint to an ordinary watchpoint if a hardware
7223
     watchpoint could not be set.  */
7255
     watchpoint could not be set.  */
7224
  if (!mem_cnt || target_resources_ok <= 0)
7256
  if ((!mem_cnt && val) || target_resources_ok <= 0)
7225
    bp_type = bp_watchpoint;
7257
    bp_type = bp_watchpoint;
7226
7258
7227
  frame = block_innermost_frame (exp_valid_block);
7259
  frame = block_innermost_frame (exp_valid_block);
(-)a/gdb/breakpoint.h (-1 / +4 lines)
Lines 168-174 enum target_hw_bp_type Link Here
168
    hw_write   = 0, 		/* Common  HW watchpoint */
168
    hw_write   = 0, 		/* Common  HW watchpoint */
169
    hw_read    = 1, 		/* Read    HW watchpoint */
169
    hw_read    = 1, 		/* Read    HW watchpoint */
170
    hw_access  = 2, 		/* Access  HW watchpoint */
170
    hw_access  = 2, 		/* Access  HW watchpoint */
171
    hw_execute = 3		/* Execute HW breakpoint */
171
    hw_execute = 3,		/* Execute HW breakpoint */
172
    hw_mmap    = 4		/* Memory area gets mmap(2)ed.  */
172
  };
173
  };
173
174
174
175
Lines 957-962 extern int deprecated_remove_raw_breakpoint (struct gdbarch *, void *); Link Here
957
   target.  */
958
   target.  */
958
int watchpoints_triggered (struct target_waitstatus *);
959
int watchpoints_triggered (struct target_waitstatus *);
959
960
961
extern void mmap_watchpoints_triggered (void);
962
960
/* Update BUF, which is LEN bytes read from the target address MEMADDR,
963
/* Update BUF, which is LEN bytes read from the target address MEMADDR,
961
   by replacing any memory breakpoints with their shadowed contents.  */
964
   by replacing any memory breakpoints with their shadowed contents.  */
962
void breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, 
965
void breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, 
(-)a/gdb/gdb_ptrace.h (+6 lines)
Lines 92-97 Link Here
92
# endif
92
# endif
93
#endif
93
#endif
94
94
95
96
#ifndef PT_SYSCALL
97
# define PT_SYSCALL	24	/* Continue and stop at the next (return from)
98
				   syscall.  */
99
#endif
100
95
/* Not all systems support attaching and detaching.   */
101
/* Not all systems support attaching and detaching.   */
96
102
97
#ifndef PT_ATTACH
103
#ifndef PT_ATTACH
(-)a/gdb/inf-ptrace.c (-1 / +4 lines)
Lines 346-352 inf_ptrace_resume (struct target_ops *ops, Link Here
346
  else
346
  else
347
    request = PT_CONTINUE;
347
    request = PT_CONTINUE;
348
348
349
  if (step)
349
  if (step == 2)
350
    request = PT_SYSCALL;
351
  else if (step)
352
350
    {
353
    {
351
      /* If this system does not support PT_STEP, a higher level
354
      /* If this system does not support PT_STEP, a higher level
352
         function will have called single_step() to transmute the step
355
         function will have called single_step() to transmute the step
(-)a/gdb/inferior.h (+2 lines)
Lines 478-483 struct inferior Link Here
478
  /* Per inferior data-pointers required by other GDB modules.  */
478
  /* Per inferior data-pointers required by other GDB modules.  */
479
  void **data;
479
  void **data;
480
  unsigned num_data;
480
  unsigned num_data;
481
482
  unsigned trap_syscalls : 1;
481
};
483
};
482
484
483
/* Keep a registry of per-inferior data-pointers required by other GDB
485
/* Keep a registry of per-inferior data-pointers required by other GDB
(-)a/gdb/infrun.c (-2 / +17 lines)
Lines 1436-1442 a command like `return' or `jump' to continue execution.")); Link Here
1436
    }
1436
    }
1437
1437
1438
  /* Do we need to do it the hard way, w/temp breakpoints?  */
1438
  /* Do we need to do it the hard way, w/temp breakpoints?  */
1439
  else if (step)
1439
  else if (step == 1)
1440
    step = maybe_software_singlestep (gdbarch, pc);
1440
    step = maybe_software_singlestep (gdbarch, pc);
1441
1441
1442
  if (should_resume)
1442
  if (should_resume)
Lines 1608-1613 clear_proceed_status (void) Link Here
1608
1608
1609
      inferior = current_inferior ();
1609
      inferior = current_inferior ();
1610
      inferior->stop_soon = NO_STOP_QUIETLY;
1610
      inferior->stop_soon = NO_STOP_QUIETLY;
1611
      inferior->trap_syscalls = 0;
1611
    }
1612
    }
1612
1613
1613
  stop_after_trap = 0;
1614
  stop_after_trap = 0;
Lines 1708-1713 proceed (CORE_ADDR addr, enum target_signal siggnal, int step) Link Here
1708
  CORE_ADDR pc;
1709
  CORE_ADDR pc;
1709
  struct address_space *aspace;
1710
  struct address_space *aspace;
1710
  int oneproc = 0;
1711
  int oneproc = 0;
1712
  struct inferior *inf;
1711
1713
1712
  /* If we're stopped at a fork/vfork, follow the branch set by the
1714
  /* If we're stopped at a fork/vfork, follow the branch set by the
1713
     "set follow-fork-mode" command; otherwise, we'll just proceed
1715
     "set follow-fork-mode" command; otherwise, we'll just proceed
Lines 1871-1878 proceed (CORE_ADDR addr, enum target_signal siggnal, int step) Link Here
1871
  /* Reset to normal state.  */
1873
  /* Reset to normal state.  */
1872
  init_infwait_state ();
1874
  init_infwait_state ();
1873
1875
1876
  inf = current_inferior ();
1877
1874
  /* Resume inferior.  */
1878
  /* Resume inferior.  */
1875
  resume (oneproc || step || bpstat_should_step (), tp->stop_signal);
1879
  resume (oneproc || step || bpstat_should_step () ? 1 :
1880
	  (inf->trap_syscalls ? 2 : 0),
1881
	  tp->stop_signal);
1876
1882
1877
  /* Wait for it to stop (if not standalone)
1883
  /* Wait for it to stop (if not standalone)
1878
     and in any case decode why it stopped, and act accordingly.  */
1884
     and in any case decode why it stopped, and act accordingly.  */
Lines 3405-3410 targets should add new threads to the thread list themselves in non-stop mode.") Link Here
3405
  else
3411
  else
3406
    stopped_by_watchpoint = watchpoints_triggered (&ecs->ws);
3412
    stopped_by_watchpoint = watchpoints_triggered (&ecs->ws);
3407
3413
3414
  if (ecs->ws.kind == TARGET_WAITKIND_STOPPED
3415
      && ecs->ws.value.sig == TARGET_SIGNAL_TRAP)
3416
    {
3417
      struct inferior *inferior = current_inferior ();
3418
3419
      if (inferior->trap_syscalls)
3420
	mmap_watchpoints_triggered ();
3421
    }
3422
3408
  /* If necessary, step over this watchpoint.  We'll be back to display
3423
  /* If necessary, step over this watchpoint.  We'll be back to display
3409
     it in a moment.  */
3424
     it in a moment.  */
3410
  if (stopped_by_watchpoint
3425
  if (stopped_by_watchpoint
(-)a/gdb/linux-nat.c (-9 / +21 lines)
Lines 1908-1913 resume_set_callback (struct lwp_info *lp, void *data) Link Here
1908
  return 0;
1908
  return 0;
1909
}
1909
}
1910
1910
1911
static const char *
1912
step_string (int step)
1913
{
1914
  switch (step)
1915
  {
1916
    case 0:
1917
      return "PTRACE_CONT";
1918
    case 1:
1919
      return "PTRACE_SINGLESTEP";
1920
    case 2:
1921
      return "PTRACE_SYSCALL";
1922
    default:
1923
      gdb_assert (0);
1924
  }
1925
}
1926
1911
static void
1927
static void
1912
linux_nat_resume (struct target_ops *ops,
1928
linux_nat_resume (struct target_ops *ops,
1913
		  ptid_t ptid, int step, enum target_signal signo)
1929
		  ptid_t ptid, int step, enum target_signal signo)
Lines 2025-2031 linux_nat_resume (struct target_ops *ops, Link Here
2025
  if (debug_linux_nat)
2041
  if (debug_linux_nat)
2026
    fprintf_unfiltered (gdb_stdlog,
2042
    fprintf_unfiltered (gdb_stdlog,
2027
			"LLR: %s %s, %s (resume event thread)\n",
2043
			"LLR: %s %s, %s (resume event thread)\n",
2028
			step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
2044
			step_string(step),
2029
			target_pid_to_str (ptid),
2045
			target_pid_to_str (ptid),
2030
			signo ? strsignal (signo) : "0");
2046
			signo ? strsignal (signo) : "0");
2031
2047
Lines 3185-3192 linux_nat_filter_event (int lwpid, int status, int options) Link Here
3185
      if (debug_linux_nat)
3201
      if (debug_linux_nat)
3186
	fprintf_unfiltered (gdb_stdlog,
3202
	fprintf_unfiltered (gdb_stdlog,
3187
			    "LLW: %s %s, 0, 0 (discard SIGSTOP)\n",
3203
			    "LLW: %s %s, 0, 0 (discard SIGSTOP)\n",
3188
			    lp->step ?
3204
			    step_string(lp->step),
3189
			    "PTRACE_SINGLESTEP" : "PTRACE_CONT",
3190
			    target_pid_to_str (lp->ptid));
3205
			    target_pid_to_str (lp->ptid));
3191
3206
3192
      lp->stopped = 0;
3207
      lp->stopped = 0;
Lines 3215-3222 linux_nat_filter_event (int lwpid, int status, int options) Link Here
3215
      if (debug_linux_nat)
3230
      if (debug_linux_nat)
3216
	fprintf_unfiltered (gdb_stdlog,
3231
	fprintf_unfiltered (gdb_stdlog,
3217
			    "LLW: %s %s, 0, 0 (discard SIGINT)\n",
3232
			    "LLW: %s %s, 0, 0 (discard SIGINT)\n",
3218
			    lp->step ?
3233
			    step_string(lp->step),
3219
			    "PTRACE_SINGLESTEP" : "PTRACE_CONT",
3220
			    target_pid_to_str (lp->ptid));
3234
			    target_pid_to_str (lp->ptid));
3221
3235
3222
      lp->stopped = 0;
3236
      lp->stopped = 0;
Lines 3350-3356 retry: Link Here
3350
      if (debug_linux_nat)
3364
      if (debug_linux_nat)
3351
	fprintf_unfiltered (gdb_stdlog,
3365
	fprintf_unfiltered (gdb_stdlog,
3352
			    "LLW: %s %s, 0, 0 (expect SIGSTOP)\n",
3366
			    "LLW: %s %s, 0, 0 (expect SIGSTOP)\n",
3353
			    lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
3367
			    step_string(lp->step),
3354
			    target_pid_to_str (lp->ptid));
3368
			    target_pid_to_str (lp->ptid));
3355
      lp->stopped = 0;
3369
      lp->stopped = 0;
3356
      gdb_assert (lp->resumed);
3370
      gdb_assert (lp->resumed);
Lines 3562-3569 retry: Link Here
3562
	  if (debug_linux_nat)
3576
	  if (debug_linux_nat)
3563
	    fprintf_unfiltered (gdb_stdlog,
3577
	    fprintf_unfiltered (gdb_stdlog,
3564
				"LLW: %s %s, %s (preempt 'handle')\n",
3578
				"LLW: %s %s, %s (preempt 'handle')\n",
3565
				lp->step ?
3579
				step_string(lp->step),
3566
				"PTRACE_SINGLESTEP" : "PTRACE_CONT",
3567
				target_pid_to_str (lp->ptid),
3580
				target_pid_to_str (lp->ptid),
3568
				signo ? strsignal (signo) : "0");
3581
				signo ? strsignal (signo) : "0");
3569
	  lp->stopped = 0;
3582
	  lp->stopped = 0;
3570
- 

Return to bug 10645