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

Collapse All | Expand All

(-)file_not_specified_in_diff (-29 / +99 lines)
Line  Link Here
0
-- a/gdb/breakpoint.c
0
++ b/gdb/breakpoint.c
Lines 1028-1034 update_watchpoint (struct breakpoint *b, int reparse) Link Here
1028
		  addr = value_address (v);
1028
		  addr = value_address (v);
1029
		  len = TYPE_LENGTH (value_type (v));
1029
		  len = TYPE_LENGTH (value_type (v));
1030
		  type = hw_write;
1030
		  type = hw_write;
1031
		  if (b->type == bp_read_watchpoint)
1031
		  if (v == val_chain && value_lazy (v))
1032
		    type = hw_mmap;
1033
		  else if (b->type == bp_read_watchpoint)
1032
		    type = hw_read;
1034
		    type = hw_read;
1033
		  else if (b->type == bp_access_watchpoint)
1035
		  else if (b->type == bp_access_watchpoint)
1034
		    type = hw_access;
1036
		    type = hw_access;
Lines 1287-1295 Note: automatically using hardware breakpoints for read-only addresses.\n")); Link Here
1287
	      watchpoints.  It's not clear that it's necessary... */
1289
	      watchpoints.  It's not clear that it's necessary... */
1288
	   && bpt->owner->disposition != disp_del_at_next_stop)
1290
	   && bpt->owner->disposition != disp_del_at_next_stop)
1289
    {
1291
    {
1290
      val = target_insert_watchpoint (bpt->address, 
1292
      if (bpt->watchpoint_type == hw_mmap)
1291
				      bpt->length,
1293
      	{
1292
				      bpt->watchpoint_type);
1294
	  struct inferior *inf = current_inferior ();
1295
1296
	  inf->trap_syscalls = 1;
1297
	  val = 0;
1298
	}
1299
      else
1300
	val = target_insert_watchpoint (bpt->address, 
1301
					bpt->length,
1302
					bpt->watchpoint_type);
1293
      bpt->inserted = (val != -1);
1303
      bpt->inserted = (val != -1);
1294
    }
1304
    }
1295
1305
Lines 1796-1803 remove_breakpoint (struct bp_location *b, insertion_state_t is) Link Here
1796
      struct value *n;
1806
      struct value *n;
1797
1807
1798
      b->inserted = (is == mark_inserted);
1808
      b->inserted = (is == mark_inserted);
1799
      val = target_remove_watchpoint (b->address, b->length, 
1809
      if (b->watchpoint_type == hw_mmap)
1800
				      b->watchpoint_type);
1810
      	val = 0;
1811
      else
1812
	val = target_remove_watchpoint (b->address, b->length, 
1813
					b->watchpoint_type);
1801
1814
1802
      /* Failure to remove any of the hardware watchpoints comes here.  */
1815
      /* Failure to remove any of the hardware watchpoints comes here.  */
1803
      if ((is == mark_uninserted) && (b->inserted))
1816
      if ((is == mark_uninserted) && (b->inserted))
Lines 2783-2788 watchpoints_triggered (struct target_waitstatus *ws) Link Here
2783
  return 1;
2796
  return 1;
2784
}
2797
}
2785
2798
2799
void
2800
mmap_watchpoints_triggered (void)
2801
{
2802
  struct breakpoint *b;
2803
2804
  ALL_BREAKPOINTS (b)
2805
    if (b->type == bp_hardware_watchpoint)
2806
      {
2807
	struct bp_location *loc;
2808
2809
	for (loc = b->loc; loc; loc = loc->next)
2810
	  if (loc->watchpoint_type == hw_mmap)
2811
	    {
2812
	      b->watchpoint_triggered = watch_triggered_yes;
2813
	      break;
2814
	    }
2815
      }
2816
}
2817
2786
/* Possible return values for watchpoint_check (this can't be an enum
2818
/* Possible return values for watchpoint_check (this can't be an enum
2787
   because of check_errors).  */
2819
   because of check_errors).  */
2788
/* The watchpoint has been deleted.  */
2820
/* The watchpoint has been deleted.  */
Lines 6333-6339 watch_command_1 (char *arg, int accessflag, int from_tty) Link Here
6333
  struct symtab_and_line sal;
6365
  struct symtab_and_line sal;
6334
  struct expression *exp;
6366
  struct expression *exp;
6335
  struct block *exp_valid_block;
6367
  struct block *exp_valid_block;
6336
  struct value *val, *mark;
6368
  struct value *val, *mark, *result;
6337
  struct frame_info *frame;
6369
  struct frame_info *frame;
6338
  char *exp_start = NULL;
6370
  char *exp_start = NULL;
6339
  char *exp_end = NULL;
6371
  char *exp_end = NULL;
Lines 6423-6429 watch_command_1 (char *arg, int accessflag, int from_tty) Link Here
6423
6455
6424
  exp_valid_block = innermost_block;
6456
  exp_valid_block = innermost_block;
6425
  mark = value_mark ();
6457
  mark = value_mark ();
6426
  fetch_watchpoint_value (exp, &val, NULL, NULL);
6458
  fetch_watchpoint_value (exp, &val, &result, NULL);
6427
  if (val != NULL)
6459
  if (val != NULL)
6428
    release_value (val);
6460
    release_value (val);
6429
6461
Lines 6455-6461 watch_command_1 (char *arg, int accessflag, int from_tty) Link Here
6455
  mem_cnt = can_use_hardware_watchpoint (val);
6487
  mem_cnt = can_use_hardware_watchpoint (val);
6456
  if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
6488
  if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
6457
    error (_("Expression cannot be implemented with read/access watchpoint."));
6489
    error (_("Expression cannot be implemented with read/access watchpoint."));
6458
  if (mem_cnt != 0)
6490
  if (mem_cnt != 0 || !val)
6459
    {
6491
    {
6460
      i = hw_watchpoint_used_count (bp_type, &other_type_used);
6492
      i = hw_watchpoint_used_count (bp_type, &other_type_used);
6461
      target_resources_ok = 
6493
      target_resources_ok = 
Lines 6470-6476 watch_command_1 (char *arg, int accessflag, int from_tty) Link Here
6470
6502
6471
  /* Change the type of breakpoint to an ordinary watchpoint if a hardware
6503
  /* Change the type of breakpoint to an ordinary watchpoint if a hardware
6472
     watchpoint could not be set.  */
6504
     watchpoint could not be set.  */
6473
  if (!mem_cnt || target_resources_ok <= 0)
6505
  if ((!mem_cnt && val) || target_resources_ok <= 0)
6474
    bp_type = bp_watchpoint;
6506
    bp_type = bp_watchpoint;
6475
6507
6476
  frame = block_innermost_frame (exp_valid_block);
6508
  frame = block_innermost_frame (exp_valid_block);
6477
-- a/gdb/breakpoint.h
6509
++ b/gdb/breakpoint.h
Lines 167-173 enum target_hw_bp_type Link Here
167
    hw_write   = 0, 		/* Common  HW watchpoint */
167
    hw_write   = 0, 		/* Common  HW watchpoint */
168
    hw_read    = 1, 		/* Read    HW watchpoint */
168
    hw_read    = 1, 		/* Read    HW watchpoint */
169
    hw_access  = 2, 		/* Access  HW watchpoint */
169
    hw_access  = 2, 		/* Access  HW watchpoint */
170
    hw_execute = 3		/* Execute HW breakpoint */
170
    hw_execute = 3,		/* Execute HW breakpoint */
171
    hw_mmap    = 4		/* Memory area gets mmap(2)ed.  */
171
  };
172
  };
172
173
173
174
Lines 912-917 extern int deprecated_remove_raw_breakpoint (struct gdbarch *, void *); Link Here
912
   target.  */
913
   target.  */
913
int watchpoints_triggered (struct target_waitstatus *);
914
int watchpoints_triggered (struct target_waitstatus *);
914
915
916
extern void mmap_watchpoints_triggered (void);
917
915
/* Update BUF, which is LEN bytes read from the target address MEMADDR,
918
/* Update BUF, which is LEN bytes read from the target address MEMADDR,
916
   by replacing any memory breakpoints with their shadowed contents.  */
919
   by replacing any memory breakpoints with their shadowed contents.  */
917
void breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, 
920
void breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, 
918
-- a/gdb/gdb_ptrace.h
921
++ b/gdb/gdb_ptrace.h
Lines 92-97 Link Here
92
# endif
92
# endif
93
#endif
93
#endif
94
94
95
#ifndef PT_SYSCALL
96
# define PT_SYSCALL	24	/* Continue and stop at the next (return from)
97
				   syscall.  */
98
#endif
99
95
/* Not all systems support attaching and detaching.   */
100
/* Not all systems support attaching and detaching.   */
96
101
97
#ifndef PT_ATTACH
102
#ifndef PT_ATTACH
98
-- a/gdb/inf-ptrace.c
103
++ b/gdb/inf-ptrace.c
Lines 339-345 inf_ptrace_resume (struct target_ops *ops, Link Here
339
       single-threaded processes, so simply resume the inferior.  */
339
       single-threaded processes, so simply resume the inferior.  */
340
    pid = ptid_get_pid (inferior_ptid);
340
    pid = ptid_get_pid (inferior_ptid);
341
341
342
  if (step)
342
  if (step == 2)
343
    request = PT_SYSCALL;
344
  else if (step)
343
    {
345
    {
344
      /* If this system does not support PT_STEP, a higher level
346
      /* If this system does not support PT_STEP, a higher level
345
         function will have called single_step() to transmute the step
347
         function will have called single_step() to transmute the step
346
-- a/gdb/inferior.h
348
++ b/gdb/inferior.h
Lines 425-430 struct inferior Link Here
425
425
426
  /* Private data used by the target vector implementation.  */
426
  /* Private data used by the target vector implementation.  */
427
  struct private_inferior *private;
427
  struct private_inferior *private;
428
429
  unsigned trap_syscalls : 1;
428
};
430
};
429
431
430
/* Create an empty inferior list, or empty the existing one.  */
432
/* Create an empty inferior list, or empty the existing one.  */
431
-- a/gdb/infrun.c
433
++ b/gdb/infrun.c
Lines 1211-1217 a command like `return' or `jump' to continue execution.")); Link Here
1211
    }
1211
    }
1212
1212
1213
  /* Do we need to do it the hard way, w/temp breakpoints?  */
1213
  /* Do we need to do it the hard way, w/temp breakpoints?  */
1214
  if (step)
1214
  if (step == 1)
1215
    step = maybe_software_singlestep (gdbarch, pc);
1215
    step = maybe_software_singlestep (gdbarch, pc);
1216
1216
1217
  if (should_resume)
1217
  if (should_resume)
Lines 1380-1385 clear_proceed_status (void) Link Here
1380
  
1380
  
1381
      inferior = current_inferior ();
1381
      inferior = current_inferior ();
1382
      inferior->stop_soon = NO_STOP_QUIETLY;
1382
      inferior->stop_soon = NO_STOP_QUIETLY;
1383
      inferior->trap_syscalls = 0;
1383
    }
1384
    }
1384
1385
1385
  stop_after_trap = 0;
1386
  stop_after_trap = 0;
Lines 1478-1483 proceed (CORE_ADDR addr, enum target_signal siggnal, int step) Link Here
1478
  struct thread_info *tp;
1479
  struct thread_info *tp;
1479
  CORE_ADDR pc;
1480
  CORE_ADDR pc;
1480
  int oneproc = 0;
1481
  int oneproc = 0;
1482
  struct inferior *inf;
1481
1483
1482
  /* If we're stopped at a fork/vfork, follow the branch set by the
1484
  /* If we're stopped at a fork/vfork, follow the branch set by the
1483
     "set follow-fork-mode" command; otherwise, we'll just proceed
1485
     "set follow-fork-mode" command; otherwise, we'll just proceed
Lines 1640-1647 proceed (CORE_ADDR addr, enum target_signal siggnal, int step) Link Here
1640
  /* Reset to normal state.  */
1642
  /* Reset to normal state.  */
1641
  init_infwait_state ();
1643
  init_infwait_state ();
1642
1644
1645
  inf = current_inferior ();
1646
1643
  /* Resume inferior.  */
1647
  /* Resume inferior.  */
1644
  resume (oneproc || step || bpstat_should_step (), tp->stop_signal);
1648
  resume (oneproc || step || bpstat_should_step () ? 1 : (inf->trap_syscalls ? 2 : 0), tp->stop_signal);
1645
1649
1646
  /* Wait for it to stop (if not standalone)
1650
  /* Wait for it to stop (if not standalone)
1647
     and in any case decode why it stopped, and act accordingly.  */
1651
     and in any case decode why it stopped, and act accordingly.  */
Lines 3052-3057 targets should add new threads to the thread list themselves in non-stop mode.") Link Here
3052
  else
3056
  else
3053
    stopped_by_watchpoint = watchpoints_triggered (&ecs->ws);
3057
    stopped_by_watchpoint = watchpoints_triggered (&ecs->ws);
3054
3058
3059
  if (ecs->ws.kind == TARGET_WAITKIND_STOPPED
3060
      && ecs->ws.value.sig == TARGET_SIGNAL_TRAP)
3061
    {
3062
      struct inferior *inferior = current_inferior ();
3063
3064
      if (inferior->trap_syscalls)
3065
	mmap_watchpoints_triggered ();
3066
    }
3067
3055
  /* If necessary, step over this watchpoint.  We'll be back to display
3068
  /* If necessary, step over this watchpoint.  We'll be back to display
3056
     it in a moment.  */
3069
     it in a moment.  */
3057
  if (stopped_by_watchpoint
3070
  if (stopped_by_watchpoint
3058
-- a/gdb/linux-nat.c
3071
++ b/gdb/linux-nat.c
Lines 1654-1659 resume_set_callback (struct lwp_info *lp, void *data) Link Here
1654
  return 0;
1654
  return 0;
1655
}
1655
}
1656
1656
1657
static const char *
1658
step_string (int step)
1659
{
1660
  switch (step)
1661
  {
1662
    case 0:
1663
      return "PTRACE_CONT";
1664
    case 1:
1665
      return "PTRACE_SINGLESTEP";
1666
    case 2:
1667
      return "PTRACE_SYSCALL";
1668
    default:
1669
      gdb_assert (0);
1670
  }
1671
}
1672
1657
static void
1673
static void
1658
linux_nat_resume (struct target_ops *ops,
1674
linux_nat_resume (struct target_ops *ops,
1659
		  ptid_t ptid, int step, enum target_signal signo)
1675
		  ptid_t ptid, int step, enum target_signal signo)
Lines 1770-1776 linux_nat_resume (struct target_ops *ops, Link Here
1770
  if (debug_linux_nat)
1786
  if (debug_linux_nat)
1771
    fprintf_unfiltered (gdb_stdlog,
1787
    fprintf_unfiltered (gdb_stdlog,
1772
			"LLR: %s %s, %s (resume event thread)\n",
1788
			"LLR: %s %s, %s (resume event thread)\n",
1773
			step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
1789
			step_string (step),
1774
			target_pid_to_str (ptid),
1790
			target_pid_to_str (ptid),
1775
			signo ? strsignal (signo) : "0");
1791
			signo ? strsignal (signo) : "0");
1776
1792
Lines 2672-2679 linux_nat_filter_event (int lwpid, int status, int options) Link Here
2672
      if (debug_linux_nat)
2688
      if (debug_linux_nat)
2673
	fprintf_unfiltered (gdb_stdlog,
2689
	fprintf_unfiltered (gdb_stdlog,
2674
			    "LLW: %s %s, 0, 0 (discard SIGSTOP)\n",
2690
			    "LLW: %s %s, 0, 0 (discard SIGSTOP)\n",
2675
			    lp->step ?
2691
			    step_string (lp->step),
2676
			    "PTRACE_SINGLESTEP" : "PTRACE_CONT",
2677
			    target_pid_to_str (lp->ptid));
2692
			    target_pid_to_str (lp->ptid));
2678
2693
2679
      lp->stopped = 0;
2694
      lp->stopped = 0;
Lines 2702-2709 linux_nat_filter_event (int lwpid, int status, int options) Link Here
2702
      if (debug_linux_nat)
2717
      if (debug_linux_nat)
2703
	fprintf_unfiltered (gdb_stdlog,
2718
	fprintf_unfiltered (gdb_stdlog,
2704
			    "LLW: %s %s, 0, 0 (discard SIGINT)\n",
2719
			    "LLW: %s %s, 0, 0 (discard SIGINT)\n",
2705
			    lp->step ?
2720
			    step_string (lp->step),
2706
			    "PTRACE_SINGLESTEP" : "PTRACE_CONT",
2707
			    target_pid_to_str (lp->ptid));
2721
			    target_pid_to_str (lp->ptid));
2708
2722
2709
      lp->stopped = 0;
2723
      lp->stopped = 0;
Lines 2841-2847 retry: Link Here
2841
      if (debug_linux_nat)
2855
      if (debug_linux_nat)
2842
	fprintf_unfiltered (gdb_stdlog,
2856
	fprintf_unfiltered (gdb_stdlog,
2843
			    "LLW: %s %s, 0, 0 (expect SIGSTOP)\n",
2857
			    "LLW: %s %s, 0, 0 (expect SIGSTOP)\n",
2844
			    lp->step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
2858
			    step_string (lp->step),
2845
			    target_pid_to_str (lp->ptid));
2859
			    target_pid_to_str (lp->ptid));
2846
      lp->stopped = 0;
2860
      lp->stopped = 0;
2847
      gdb_assert (lp->resumed);
2861
      gdb_assert (lp->resumed);
Lines 3024-3031 retry: Link Here
3024
	  if (debug_linux_nat)
3038
	  if (debug_linux_nat)
3025
	    fprintf_unfiltered (gdb_stdlog,
3039
	    fprintf_unfiltered (gdb_stdlog,
3026
				"LLW: %s %s, %s (preempt 'handle')\n",
3040
				"LLW: %s %s, %s (preempt 'handle')\n",
3027
				lp->step ?
3041
				step_string (lp->step),
3028
				"PTRACE_SINGLESTEP" : "PTRACE_CONT",
3029
				target_pid_to_str (lp->ptid),
3042
				target_pid_to_str (lp->ptid),
3030
				signo ? strsignal (signo) : "0");
3043
				signo ? strsignal (signo) : "0");
3031
	  lp->stopped = 0;
3044
	  lp->stopped = 0;

Return to bug 10645