~ubuntu-branches/debian/jessie/gdb/jessie

« back to all changes in this revision

Viewing changes to gdb/breakpoint.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2010-03-20 01:21:29 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100320012129-t7h25y8zgr8c2369
Tags: 7.1-1
* New upstream release, including:
  - PIE support (Closes: #346409).
  - C++ improvements, including static_cast<> et al, namespace imports,
    and bug fixes in printing virtual base classes.
  - Multi-program debugging.  One GDB can now debug multiple programs
    at the same time.
  - Python scripting improvements, including gdb.parse_and_eval.
  - Updated MIPS Linux signal frame layout (Closes: #570875).
  - No internal error stepping over _dl_debug_state (Closes: #569551).
* Update to Standards-Version: 3.8.4 (no changes required).
* Include more relevant (and smaller) docs in the gdbserver package
  (Closes: #571132).
* Do not duplicate documentation in gdb64, gdb-source, and libgdb-dev.
* Fix crash when switching into TUI mode (Closes: #568489).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4
4
   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
5
 
   2008, 2009 Free Software Foundation, Inc.
 
5
   2008, 2009, 2010 Free Software Foundation, Inc.
6
6
 
7
7
   This file is part of GDB.
8
8
 
112
112
                                              struct symtab_and_line,
113
113
                                              enum bptype);
114
114
 
115
 
static void check_duplicates (struct breakpoint *);
116
 
 
117
115
static void breakpoint_adjustment_warning (CORE_ADDR, CORE_ADDR, int, int);
118
116
 
119
117
static CORE_ADDR adjust_breakpoint_address (struct gdbarch *gdbarch,
120
118
                                            CORE_ADDR bpaddr,
121
119
                                            enum bptype bptype);
122
120
 
123
 
static void describe_other_breakpoints (struct gdbarch *, CORE_ADDR,
 
121
static void describe_other_breakpoints (struct gdbarch *,
 
122
                                        struct program_space *, CORE_ADDR,
124
123
                                        struct obj_section *, int);
125
124
 
 
125
static int breakpoint_address_match (struct address_space *aspace1,
 
126
                                     CORE_ADDR addr1,
 
127
                                     struct address_space *aspace2,
 
128
                                     CORE_ADDR addr2);
 
129
 
126
130
static void breakpoints_info (char *, int);
127
131
 
128
132
static void breakpoint_1 (int, int);
149
153
insertion_state_t;
150
154
 
151
155
static int remove_breakpoint (struct bp_location *, insertion_state_t);
 
156
static int remove_breakpoint_1 (struct bp_location *, insertion_state_t);
152
157
 
153
158
static enum print_stop_action print_it_typical (bpstat);
154
159
 
182
187
 
183
188
static char *ep_parse_optional_if_clause (char **arg);
184
189
 
185
 
static char *ep_parse_optional_filename (char **arg);
186
 
 
187
190
static void catch_exception_command_1 (enum exception_event_kind ex_event, 
188
191
                                       char *arg, int tempflag, int from_tty);
189
192
 
191
194
 
192
195
static void ep_skip_leading_whitespace (char **s);
193
196
 
194
 
static int single_step_breakpoint_inserted_here_p (CORE_ADDR pc);
 
197
static int single_step_breakpoint_inserted_here_p (struct address_space *,
 
198
                                                   CORE_ADDR pc);
195
199
 
196
200
static void free_bp_location (struct bp_location *loc);
197
201
 
323
327
/* Are overlay event breakpoints enabled? */
324
328
static int overlay_events_enabled;
325
329
 
326
 
/* Are we executing startup code?  */
327
 
static int executing_startup;
328
 
 
329
330
/* Walk the following statement or block through all breakpoints.
330
331
   ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
331
332
   breakpoint.  */
337
338
             B ? (TMP=B->next, 1): 0;   \
338
339
             B = TMP)
339
340
 
340
 
/* Similar iterators for the low-level breakpoints.  */
341
 
 
342
 
#define ALL_BP_LOCATIONS(B)  for (B = bp_location_chain; B; B = B->global_next)
343
 
 
344
 
#define ALL_BP_LOCATIONS_SAFE(B,TMP)    \
345
 
        for (B = bp_location_chain;     \
346
 
             B ? (TMP=B->global_next, 1): 0;    \
347
 
             B = TMP)
 
341
/* Similar iterator for the low-level breakpoints.  SAFE variant is not
 
342
   provided so update_global_location_list must not be called while executing
 
343
   the block of ALL_BP_LOCATIONS.  */
 
344
 
 
345
#define ALL_BP_LOCATIONS(B,BP_TMP)                                      \
 
346
        for (BP_TMP = bp_location;                                      \
 
347
             BP_TMP < bp_location + bp_location_count && (B = *BP_TMP); \
 
348
             BP_TMP++)
348
349
 
349
350
/* Iterator for tracepoints only.  */
350
351
 
351
352
#define ALL_TRACEPOINTS(B)  \
352
353
  for (B = breakpoint_chain; B; B = B->next)  \
353
 
    if ((B)->type == bp_tracepoint)
 
354
    if (tracepoint_type (B))
354
355
 
355
356
/* Chains of all breakpoints defined.  */
356
357
 
357
358
struct breakpoint *breakpoint_chain;
358
359
 
359
 
struct bp_location *bp_location_chain;
 
360
/* Array is sorted by bp_location_compare - primarily by the ADDRESS.  */
 
361
 
 
362
static struct bp_location **bp_location;
 
363
 
 
364
/* Number of elements of BP_LOCATION.  */
 
365
 
 
366
static unsigned bp_location_count;
 
367
 
 
368
/* Maximum alignment offset between bp_target_info.PLACED_ADDRESS and ADDRESS
 
369
   for the current elements of BP_LOCATION which get a valid result from
 
370
   bp_location_has_shadow.  You can use it for roughly limiting the subrange of
 
371
   BP_LOCATION to scan for shadow bytes for an address you need to read.  */
 
372
 
 
373
static CORE_ADDR bp_location_placed_address_before_address_max;
 
374
 
 
375
/* Maximum offset plus alignment between
 
376
   bp_target_info.PLACED_ADDRESS + bp_target_info.SHADOW_LEN and ADDRESS for
 
377
   the current elements of BP_LOCATION which get a valid result from
 
378
   bp_location_has_shadow.  You can use it for roughly limiting the subrange of
 
379
   BP_LOCATION to scan for shadow bytes for an address you need to read.  */
 
380
 
 
381
static CORE_ADDR bp_location_shadow_len_after_address_max;
360
382
 
361
383
/* The locations that no longer correspond to any breakpoint,
362
 
   unlinked from bp_location_chain, but for which a hit
 
384
   unlinked from bp_location array, but for which a hit
363
385
   may still be reported by a target.  */
364
386
VEC(bp_location_p) *moribund_locations = NULL;
365
387
 
398
420
    b->hit_count = 0;
399
421
}
400
422
 
 
423
/* Encapsulate tests for different types of tracepoints.  */
 
424
 
 
425
static int
 
426
tracepoint_type (const struct breakpoint *b)
 
427
{
 
428
  return (b->type == bp_tracepoint || b->type == bp_fast_tracepoint);
 
429
}
 
430
  
401
431
/* Default address, symtab and line to put a breakpoint at
402
432
   for "break" command with no arg.
403
433
   if default_breakpoint_valid is zero, the other three are
409
439
CORE_ADDR default_breakpoint_address;
410
440
struct symtab *default_breakpoint_symtab;
411
441
int default_breakpoint_line;
 
442
struct program_space *default_breakpoint_pspace;
 
443
 
412
444
 
413
445
/* *PP is a string denoting a breakpoint.  Get the number of the breakpoint.
414
446
   Advance *PP after the string and any trailing whitespace.
735
767
      }
736
768
  error (_("No breakpoint number %d."), bnum);
737
769
}
738
 
 
 
770
 
 
771
/* Return non-zero if BL->TARGET_INFO contains valid information.  */
 
772
 
 
773
static int
 
774
bp_location_has_shadow (struct bp_location *bl)
 
775
{
 
776
  if (bl->loc_type != bp_loc_software_breakpoint)
 
777
    return 0;
 
778
  if (!bl->inserted)
 
779
    return 0;
 
780
  if (bl->target_info.shadow_len == 0)
 
781
    /* bp isn't valid, or doesn't shadow memory.  */
 
782
    return 0;
 
783
  return 1;
 
784
}
 
785
 
739
786
/* Update BUF, which is LEN bytes read from the target address MEMADDR,
740
 
   by replacing any memory breakpoints with their shadowed contents.  */
 
787
   by replacing any memory breakpoints with their shadowed contents.
 
788
 
 
789
   The range of shadowed area by each bp_location is:
 
790
     b->address - bp_location_placed_address_before_address_max
 
791
     up to b->address + bp_location_shadow_len_after_address_max
 
792
   The range we were requested to resolve shadows for is:
 
793
     memaddr ... memaddr + len
 
794
   Thus the safe cutoff boundaries for performance optimization are
 
795
     memaddr + len <= b->address - bp_location_placed_address_before_address_max
 
796
   and:
 
797
     b->address + bp_location_shadow_len_after_address_max <= memaddr  */
741
798
 
742
799
void
743
800
breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, LONGEST len)
744
801
{
745
 
  struct bp_location *b;
746
 
  CORE_ADDR bp_addr = 0;
747
 
  int bp_size = 0;
748
 
  int bptoffset = 0;
749
 
 
750
 
  ALL_BP_LOCATIONS (b)
 
802
  /* Left boundary, right boundary and median element of our binary search.  */
 
803
  unsigned bc_l, bc_r, bc;
 
804
 
 
805
  /* Find BC_L which is a leftmost element which may affect BUF content.  It is
 
806
     safe to report lower value but a failure to report higher one.  */
 
807
 
 
808
  bc_l = 0;
 
809
  bc_r = bp_location_count;
 
810
  while (bc_l + 1 < bc_r)
 
811
    {
 
812
      struct bp_location *b;
 
813
 
 
814
      bc = (bc_l + bc_r) / 2;
 
815
      b = bp_location[bc];
 
816
 
 
817
      /* Check first B->ADDRESS will not overflow due to the added constant.
 
818
         Then advance the left boundary only if we are sure the BC element can
 
819
         in no way affect the BUF content (MEMADDR to MEMADDR + LEN range).
 
820
 
 
821
         Use the BP_LOCATION_SHADOW_LEN_AFTER_ADDRESS_MAX safety offset so that
 
822
         we cannot miss a breakpoint with its shadow range tail still reaching
 
823
         MEMADDR.  */
 
824
 
 
825
      if (b->address + bp_location_shadow_len_after_address_max >= b->address
 
826
          && b->address + bp_location_shadow_len_after_address_max <= memaddr)
 
827
        bc_l = bc;
 
828
      else
 
829
        bc_r = bc;
 
830
    }
 
831
 
 
832
  /* Now do full processing of the found relevant range of elements.  */
 
833
 
 
834
  for (bc = bc_l; bc < bp_location_count; bc++)
751
835
  {
 
836
    struct bp_location *b = bp_location[bc];
 
837
    CORE_ADDR bp_addr = 0;
 
838
    int bp_size = 0;
 
839
    int bptoffset = 0;
 
840
 
752
841
    if (b->owner->type == bp_none)
753
842
      warning (_("reading through apparently deleted breakpoint #%d?"),
754
843
              b->owner->number);
755
844
 
756
 
    if (b->loc_type != bp_loc_software_breakpoint)
757
 
      continue;
758
 
    if (!b->inserted)
759
 
      continue;
 
845
    /* Performance optimization: any futher element can no longer affect BUF
 
846
       content.  */
 
847
 
 
848
    if (b->address >= bp_location_placed_address_before_address_max
 
849
        && memaddr + len <= b->address
 
850
                            - bp_location_placed_address_before_address_max)
 
851
      break;
 
852
 
 
853
    if (!bp_location_has_shadow (b))
 
854
      continue;
 
855
    if (!breakpoint_address_match (b->target_info.placed_address_space, 0,
 
856
                                   current_program_space->aspace, 0))
 
857
      continue;
 
858
 
760
859
    /* Addresses and length of the part of the breakpoint that
761
860
       we need to copy.  */
762
861
    bp_addr = b->target_info.placed_address;
763
862
    bp_size = b->target_info.shadow_len;
764
 
    if (bp_size == 0)
765
 
      /* bp isn't valid, or doesn't shadow memory.  */
766
 
      continue;
767
863
 
768
864
    if (bp_addr + bp_size <= memaddr)
769
865
      /* The breakpoint is entirely before the chunk of memory we
895
991
    }
896
992
}
897
993
 
 
994
/* Assuming that B is a watchpoint: returns true if the current thread
 
995
   and its running state are safe to evaluate or update watchpoint B.
 
996
   Watchpoints on local expressions need to be evaluated in the
 
997
   context of the thread that was current when the watchpoint was
 
998
   created, and, that thread needs to be stopped to be able to select
 
999
   the correct frame context.  Watchpoints on global expressions can
 
1000
   be evaluated on any thread, and in any state.  It is presently left
 
1001
   to the target allowing memory accesses when threads are
 
1002
   running.  */
 
1003
 
 
1004
static int
 
1005
watchpoint_in_thread_scope (struct breakpoint *b)
 
1006
{
 
1007
  return (ptid_equal (b->watchpoint_thread, null_ptid)
 
1008
          || (ptid_equal (inferior_ptid, b->watchpoint_thread)
 
1009
              && !is_executing (inferior_ptid)));
 
1010
}
 
1011
 
898
1012
/* Assuming that B is a watchpoint:
899
1013
   - Reparse watchpoint expression, if REPARSE is non-zero
900
1014
   - Evaluate expression and store the result in B->val
903
1017
   - Update the list of values that must be watched in B->loc.
904
1018
 
905
1019
   If the watchpoint disposition is disp_del_at_next_stop, then do nothing.
906
 
   If this is local watchpoint that is out of scope, delete it.  */
 
1020
   If this is local watchpoint that is out of scope, delete it.
 
1021
 
 
1022
   Even with `set breakpoint always-inserted on' the watchpoints are removed
 
1023
   + inserted on each stop here.  Normal breakpoints must never be removed
 
1024
   because they might be missed by a running thread when debugging in non-stop
 
1025
   mode.  On the other hand, hardware watchpoints (is_hardware_watchpoint;
 
1026
   processed here) are specific to each LWP since they are stored in each LWP's
 
1027
   hardware debug registers.  Therefore, such LWP must be stopped first in
 
1028
   order to be able to modify its hardware watchpoints.
 
1029
 
 
1030
   Hardware watchpoints must be reset exactly once after being presented to the
 
1031
   user.  It cannot be done sooner, because it would reset the data used to
 
1032
   present the watchpoint hit to the user.  And it must not be done later
 
1033
   because it could display the same single watchpoint hit during multiple GDB
 
1034
   stops.  Note that the latter is relevant only to the hardware watchpoint
 
1035
   types bp_read_watchpoint and bp_access_watchpoint.  False hit by
 
1036
   bp_hardware_watchpoint is not user-visible - its hit is suppressed if the
 
1037
   memory content has not changed.
 
1038
 
 
1039
   The following constraints influence the location where we can reset hardware
 
1040
   watchpoints:
 
1041
 
 
1042
   * target_stopped_by_watchpoint and target_stopped_data_address are called
 
1043
     several times when GDB stops.
 
1044
 
 
1045
   [linux]
 
1046
   * Multiple hardware watchpoints can be hit at the same time, causing GDB to
 
1047
     stop.  GDB only presents one hardware watchpoint hit at a time as the
 
1048
     reason for stopping, and all the other hits are presented later, one after
 
1049
     the other, each time the user requests the execution to be resumed.
 
1050
     Execution is not resumed for the threads still having pending hit event
 
1051
     stored in LWP_INFO->STATUS.  While the watchpoint is already removed from
 
1052
     the inferior on the first stop the thread hit event is kept being reported
 
1053
     from its cached value by linux_nat_stopped_data_address until the real
 
1054
     thread resume happens after the watchpoint gets presented and thus its
 
1055
     LWP_INFO->STATUS gets reset.
 
1056
 
 
1057
   Therefore the hardware watchpoint hit can get safely reset on the watchpoint
 
1058
   removal from inferior.  */
 
1059
 
907
1060
static void
908
1061
update_watchpoint (struct breakpoint *b, int reparse)
909
1062
{
910
1063
  int within_current_scope;
911
1064
  struct frame_id saved_frame_id;
912
1065
  struct bp_location *loc;
 
1066
  int frame_saved;
913
1067
  bpstat bs;
914
1068
 
915
 
  /* We don't free locations.  They are stored in bp_location_chain and
 
1069
  /* If this is a local watchpoint, we only want to check if the
 
1070
     watchpoint frame is in scope if the current thread is the thread
 
1071
     that was used to create the watchpoint.  */
 
1072
  if (!watchpoint_in_thread_scope (b))
 
1073
    return;
 
1074
 
 
1075
  /* We don't free locations.  They are stored in bp_location array and
916
1076
     update_global_locations will eventually delete them and remove
917
1077
     breakpoints if needed.  */
918
1078
  b->loc = NULL;
920
1080
  if (b->disposition == disp_del_at_next_stop)
921
1081
    return;
922
1082
 
923
 
  /* Save the current frame's ID so we can restore it after
924
 
     evaluating the watchpoint expression on its own frame.  */
925
 
  /* FIXME drow/2003-09-09: It would be nice if evaluate_expression
926
 
     took a frame parameter, so that we didn't have to change the
927
 
     selected frame.  */
928
 
  saved_frame_id = get_frame_id (get_selected_frame (NULL));
 
1083
  frame_saved = 0;
929
1084
 
930
1085
  /* Determine if the watchpoint is within scope.  */
931
1086
  if (b->exp_valid_block == NULL)
933
1088
  else
934
1089
    {
935
1090
      struct frame_info *fi;
 
1091
 
 
1092
      /* Save the current frame's ID so we can restore it after
 
1093
         evaluating the watchpoint expression on its own frame.  */
 
1094
      /* FIXME drow/2003-09-09: It would be nice if evaluate_expression
 
1095
         took a frame parameter, so that we didn't have to change the
 
1096
         selected frame.  */
 
1097
      frame_saved = 1;
 
1098
      saved_frame_id = get_frame_id (get_selected_frame (NULL));
 
1099
 
936
1100
      fi = frame_find_by_id (b->watchpoint_frame);
937
1101
      within_current_scope = (fi != NULL);
938
1102
      if (within_current_scope)
963
1127
     don't try to insert watchpoint.  We don't automatically delete
964
1128
     such watchpoint, though, since failure to parse expression
965
1129
     is different from out-of-scope watchpoint.  */
966
 
  if (within_current_scope && b->exp)
 
1130
  if ( !target_has_execution)
 
1131
    {
 
1132
      /* Without execution, memory can't change.  No use to try and
 
1133
         set watchpoint locations.  The watchpoint will be reset when
 
1134
         the target gains execution, through breakpoint_re_set.  */
 
1135
    }
 
1136
  else if (within_current_scope && b->exp)
967
1137
    {
968
1138
      struct value *val_chain, *v, *result, *next;
 
1139
      struct program_space *frame_pspace;
969
1140
 
970
1141
      fetch_watchpoint_value (b->exp, &v, &result, &val_chain);
971
1142
 
987
1158
          {
988
1159
            int i, mem_cnt, other_type_used;
989
1160
 
 
1161
            /* We need to determine how many resources are already used
 
1162
               for all other hardware watchpoints to see if we still have
 
1163
               enough resources to also fit this watchpoint in as well.
 
1164
               To avoid the hw_watchpoint_used_count call below from counting
 
1165
               this watchpoint, make sure that it is marked as a software
 
1166
               watchpoint.  */
 
1167
            b->type = bp_watchpoint;
990
1168
            i = hw_watchpoint_used_count (bp_hardware_watchpoint,
991
1169
                                          &other_type_used);
992
1170
            mem_cnt = can_use_hardware_watchpoint (val_chain);
1004
1182
              }
1005
1183
          }
1006
1184
 
 
1185
      frame_pspace = get_frame_program_space (get_selected_frame (NULL));
 
1186
 
1007
1187
      /* Look at each value on the value chain.  */
1008
1188
      for (v = val_chain; v; v = next)
1009
1189
        {
1041
1221
                    ;
1042
1222
                  *tmp = loc;
1043
1223
                  loc->gdbarch = get_type_arch (value_type (v));
 
1224
 
 
1225
                  loc->pspace = frame_pspace;
1044
1226
                  loc->address = addr;
1045
1227
                  loc->length = len;
1046
1228
                  loc->watchpoint_type = type;
1074
1256
    }
1075
1257
 
1076
1258
  /* Restore the selected frame.  */
1077
 
  select_frame (frame_find_by_id (saved_frame_id));
 
1259
  if (frame_saved)
 
1260
    select_frame (frame_find_by_id (saved_frame_id));
1078
1261
}
1079
1262
 
1080
1263
 
1092
1275
  if (!bpt->enabled || bpt->shlib_disabled || bpt->duplicate)
1093
1276
    return 0;
1094
1277
 
 
1278
  /* This is set for example, when we're attached to the parent of a
 
1279
     vfork, and have detached from the child.  The child is running
 
1280
     free, and we expect it to do an exec or exit, at which point the
 
1281
     OS makes the parent schedulable again (and the target reports
 
1282
     that the vfork is done).  Until the child is done with the shared
 
1283
     memory region, do not insert breakpoints in the parent, otherwise
 
1284
     the child could still trip on the parent's breakpoints.  Since
 
1285
     the parent is blocked anyway, it won't miss any breakpoint.  */
 
1286
  if (bpt->pspace->breakpoints_not_allowed)
 
1287
    return 0;
 
1288
 
1095
1289
  /* Tracepoints are inserted by the target at a time of its choosing,
1096
1290
     not by us.  */
1097
 
  if (bpt->owner->type == bp_tracepoint)
 
1291
  if (tracepoint_type (bpt->owner))
1098
1292
    return 0;
1099
1293
 
1100
1294
  return 1;
1120
1314
  /* Initialize the target-specific information.  */
1121
1315
  memset (&bpt->target_info, 0, sizeof (bpt->target_info));
1122
1316
  bpt->target_info.placed_address = bpt->address;
 
1317
  bpt->target_info.placed_address_space = bpt->pspace->aspace;
1123
1318
 
1124
1319
  if (bpt->loc_type == bp_loc_software_breakpoint
1125
1320
      || bpt->loc_type == bp_loc_hardware_breakpoint)
1238
1433
      if (val)
1239
1434
        {
1240
1435
          /* Can't set the breakpoint.  */
1241
 
          if (solib_name_from_address (bpt->address))
 
1436
          if (solib_name_from_address (bpt->pspace, bpt->address))
1242
1437
            {
1243
1438
              /* See also: disable_breakpoints_in_shlibs. */
1244
1439
              val = 0;
1316
1511
  return 0;
1317
1512
}
1318
1513
 
 
1514
/* This function is called when program space PSPACE is about to be
 
1515
   deleted.  It takes care of updating breakpoints to not reference
 
1516
   PSPACE anymore.  */
 
1517
 
 
1518
void
 
1519
breakpoint_program_space_exit (struct program_space *pspace)
 
1520
{
 
1521
  struct breakpoint *b, *b_temp;
 
1522
  struct bp_location *loc, **loc_temp;
 
1523
 
 
1524
  /* Remove any breakpoint that was set through this program space.  */
 
1525
  ALL_BREAKPOINTS_SAFE (b, b_temp)
 
1526
    {
 
1527
      if (b->pspace == pspace)
 
1528
        delete_breakpoint (b);
 
1529
    }
 
1530
 
 
1531
  /* Breakpoints set through other program spaces could have locations
 
1532
     bound to PSPACE as well.  Remove those.  */
 
1533
  ALL_BP_LOCATIONS (loc, loc_temp)
 
1534
    {
 
1535
      struct bp_location *tmp;
 
1536
 
 
1537
      if (loc->pspace == pspace)
 
1538
        {
 
1539
          if (loc->owner->loc == loc)
 
1540
            loc->owner->loc = loc->next;
 
1541
          else
 
1542
            for (tmp = loc->owner->loc; tmp->next != NULL; tmp = tmp->next)
 
1543
              if (tmp->next == loc)
 
1544
                {
 
1545
                  tmp->next = loc->next;
 
1546
                  break;
 
1547
                }
 
1548
        }
 
1549
    }
 
1550
 
 
1551
  /* Now update the global location list to permanently delete the
 
1552
     removed locations above.  */
 
1553
  update_global_location_list (0);
 
1554
}
 
1555
 
1319
1556
/* Make sure all breakpoints are inserted in inferior.
1320
1557
   Throws exception on any error.
1321
1558
   A breakpoint that is already inserted won't be inserted
1347
1584
insert_breakpoint_locations (void)
1348
1585
{
1349
1586
  struct breakpoint *bpt;
1350
 
  struct bp_location *b, *temp;
 
1587
  struct bp_location *b, **bp_tmp;
1351
1588
  int error = 0;
1352
1589
  int val = 0;
1353
1590
  int disabled_breaks = 0;
1359
1596
  /* Explicitly mark the warning -- this will only be printed if
1360
1597
     there was an error.  */
1361
1598
  fprintf_unfiltered (tmp_error_stream, "Warning:\n");
1362
 
        
1363
 
  ALL_BP_LOCATIONS_SAFE (b, temp)
 
1599
 
 
1600
  save_current_space_and_thread ();
 
1601
 
 
1602
  ALL_BP_LOCATIONS (b, bp_tmp)
1364
1603
    {
 
1604
      struct thread_info *tp;
 
1605
      CORE_ADDR last_addr;
 
1606
 
1365
1607
      if (!should_be_inserted (b) || b->inserted)
1366
1608
        continue;
1367
1609
 
1371
1613
          && !valid_thread_id (b->owner->thread))
1372
1614
        continue;
1373
1615
 
 
1616
      switch_to_program_space_and_thread (b->pspace);
 
1617
 
 
1618
      /* For targets that support global breakpoints, there's no need
 
1619
         to select an inferior to insert breakpoint to.  In fact, even
 
1620
         if we aren't attached to any process yet, we should still
 
1621
         insert breakpoints.  */
 
1622
      if (!gdbarch_has_global_breakpoints (target_gdbarch)
 
1623
          && ptid_equal (inferior_ptid, null_ptid))
 
1624
        continue;
 
1625
 
1374
1626
      val = insert_bp_location (b, tmp_error_stream,
1375
1627
                                    &disabled_breaks,
1376
1628
                                    &hw_breakpoint_error);
1395
1647
        continue;
1396
1648
      
1397
1649
      for (loc = bpt->loc; loc; loc = loc->next)
1398
 
        if (!loc->inserted)
 
1650
        if (!loc->inserted && should_be_inserted (loc))
1399
1651
          {
1400
1652
            some_failed = 1;
1401
1653
            break;
1434
1686
int
1435
1687
remove_breakpoints (void)
1436
1688
{
1437
 
  struct bp_location *b;
 
1689
  struct bp_location *b, **bp_tmp;
1438
1690
  int val = 0;
1439
1691
 
1440
 
  ALL_BP_LOCATIONS (b)
 
1692
  ALL_BP_LOCATIONS (b, bp_tmp)
1441
1693
  {
1442
1694
    if (b->inserted)
1443
1695
      val |= remove_breakpoint (b, mark_uninserted);
1445
1697
  return val;
1446
1698
}
1447
1699
 
 
1700
/* Remove breakpoints of process PID.  */
 
1701
 
 
1702
int
 
1703
remove_breakpoints_pid (int pid)
 
1704
{
 
1705
  struct bp_location *b, **b_tmp;
 
1706
  int val;
 
1707
  struct inferior *inf = find_inferior_pid (pid);
 
1708
 
 
1709
  ALL_BP_LOCATIONS (b, b_tmp)
 
1710
  {
 
1711
    if (b->pspace != inf->pspace)
 
1712
      continue;
 
1713
 
 
1714
    if (b->inserted)
 
1715
      {
 
1716
        val = remove_breakpoint (b, mark_uninserted);
 
1717
        if (val != 0)
 
1718
          return val;
 
1719
      }
 
1720
  }
 
1721
  return 0;
 
1722
}
 
1723
 
1448
1724
int
1449
1725
remove_hw_watchpoints (void)
1450
1726
{
1451
 
  struct bp_location *b;
 
1727
  struct bp_location *b, **bp_tmp;
1452
1728
  int val = 0;
1453
1729
 
1454
 
  ALL_BP_LOCATIONS (b)
 
1730
  ALL_BP_LOCATIONS (b, bp_tmp)
1455
1731
  {
1456
1732
    if (b->inserted && b->loc_type == bp_loc_hardware_watchpoint)
1457
1733
      val |= remove_breakpoint (b, mark_uninserted);
1462
1738
int
1463
1739
reattach_breakpoints (int pid)
1464
1740
{
1465
 
  struct bp_location *b;
 
1741
  struct cleanup *old_chain;
 
1742
  struct bp_location *b, **bp_tmp;
1466
1743
  int val;
1467
 
  struct cleanup *old_chain = save_inferior_ptid ();
1468
1744
  struct ui_file *tmp_error_stream = mem_fileopen ();
1469
1745
  int dummy1 = 0, dummy2 = 0;
 
1746
  struct inferior *inf;
 
1747
  struct thread_info *tp;
 
1748
 
 
1749
  tp = any_live_thread_of_process (pid);
 
1750
  if (tp == NULL)
 
1751
    return 1;
 
1752
 
 
1753
  inf = find_inferior_pid (pid);
 
1754
  old_chain = save_inferior_ptid ();
 
1755
 
 
1756
  inferior_ptid = tp->ptid;
1470
1757
 
1471
1758
  make_cleanup_ui_file_delete (tmp_error_stream);
1472
1759
 
1473
 
  inferior_ptid = pid_to_ptid (pid);
1474
 
  ALL_BP_LOCATIONS (b)
 
1760
  ALL_BP_LOCATIONS (b, bp_tmp)
1475
1761
  {
 
1762
    if (b->pspace != inf->pspace)
 
1763
      continue;
 
1764
 
1476
1765
    if (b->inserted)
1477
1766
      {
1478
1767
        b->inserted = 0;
1502
1791
 
1503
1792
  sal.pc = address;
1504
1793
  sal.section = find_pc_overlay (sal.pc);
 
1794
  sal.pspace = current_program_space;
1505
1795
 
1506
1796
  b = set_raw_breakpoint (gdbarch, sal, type);
1507
1797
  b->number = internal_breakpoint_number--;
1546
1836
static void
1547
1837
create_longjmp_master_breakpoint (char *func_name)
1548
1838
{
 
1839
  struct program_space *pspace;
1549
1840
  struct objfile *objfile;
1550
 
 
 
1841
  struct cleanup *old_chain;
 
1842
 
 
1843
  old_chain = save_current_program_space ();
 
1844
 
 
1845
  ALL_PSPACES (pspace)
1551
1846
  ALL_OBJFILES (objfile)
1552
1847
    {
1553
1848
      struct breakpoint *b;
1556
1851
      if (!gdbarch_get_longjmp_target_p (get_objfile_arch (objfile)))
1557
1852
        continue;
1558
1853
 
 
1854
      set_current_program_space (pspace);
 
1855
 
1559
1856
      m = lookup_minimal_symbol_text (func_name, objfile);
1560
1857
      if (m == NULL)
1561
1858
        continue;
1567
1864
      b->enable_state = bp_disabled;
1568
1865
    }
1569
1866
  update_global_location_list (1);
 
1867
 
 
1868
  do_cleanups (old_chain);
1570
1869
}
1571
1870
 
1572
1871
void
1574
1873
{
1575
1874
  struct breakpoint *b;
1576
1875
  struct breakpoint *temp;
1577
 
  struct bp_location *bploc;
 
1876
  struct bp_location *bploc, **bplocp_tmp;
1578
1877
 
1579
1878
  /* We're about to delete breakpoints from GDB's lists.  If the
1580
1879
     INSERTED flag is true, GDB will try to lift the breakpoints by
1584
1883
     breakpoints out as soon as it detects an exec.  We don't do that
1585
1884
     here instead, because there may be other attempts to delete
1586
1885
     breakpoints after detecting an exec and before reaching here.  */
1587
 
  ALL_BP_LOCATIONS (bploc)
1588
 
    gdb_assert (!bploc->inserted);
 
1886
  ALL_BP_LOCATIONS (bploc, bplocp_tmp)
 
1887
    if (bploc->pspace == current_program_space)
 
1888
      gdb_assert (!bploc->inserted);
1589
1889
 
1590
1890
  ALL_BREAKPOINTS_SAFE (b, temp)
1591
1891
  {
 
1892
    if (b->pspace != current_program_space)
 
1893
      continue;
 
1894
 
1592
1895
    /* Solib breakpoints must be explicitly reset after an exec(). */
1593
1896
    if (b->type == bp_shlib_event)
1594
1897
      {
1687
1990
int
1688
1991
detach_breakpoints (int pid)
1689
1992
{
1690
 
  struct bp_location *b;
 
1993
  struct bp_location *b, **bp_tmp;
1691
1994
  int val = 0;
1692
1995
  struct cleanup *old_chain = save_inferior_ptid ();
 
1996
  struct inferior *inf = current_inferior ();
1693
1997
 
1694
1998
  if (pid == PIDGET (inferior_ptid))
1695
1999
    error (_("Cannot detach breakpoints of inferior_ptid"));
1696
2000
 
1697
 
  /* Set inferior_ptid; remove_breakpoint uses this global.  */
 
2001
  /* Set inferior_ptid; remove_breakpoint_1 uses this global.  */
1698
2002
  inferior_ptid = pid_to_ptid (pid);
1699
 
  ALL_BP_LOCATIONS (b)
 
2003
  ALL_BP_LOCATIONS (b, bp_tmp)
1700
2004
  {
 
2005
    if (b->pspace != inf->pspace)
 
2006
      continue;
 
2007
 
1701
2008
    if (b->inserted)
1702
 
      val |= remove_breakpoint (b, mark_inserted);
 
2009
      val |= remove_breakpoint_1 (b, mark_inserted);
1703
2010
  }
1704
2011
  do_cleanups (old_chain);
1705
2012
  return val;
1706
2013
}
1707
2014
 
 
2015
/* Remove the breakpoint location B from the current address space.
 
2016
   Note that this is used to detach breakpoints from a child fork.
 
2017
   When we get here, the child isn't in the inferior list, and neither
 
2018
   do we have objects to represent its address space --- we should
 
2019
   *not* look at b->pspace->aspace here.  */
 
2020
 
1708
2021
static int
1709
 
remove_breakpoint (struct bp_location *b, insertion_state_t is)
 
2022
remove_breakpoint_1 (struct bp_location *b, insertion_state_t is)
1710
2023
{
1711
2024
  int val;
 
2025
  struct cleanup *old_chain;
1712
2026
 
1713
2027
  if (b->owner->enable_state == bp_permanent)
1714
2028
    /* Permanent breakpoints cannot be inserted or removed.  */
1786
2100
      /* In some cases, we might not be able to remove a breakpoint
1787
2101
         in a shared library that has already been removed, but we
1788
2102
         have not yet processed the shlib unload event.  */
1789
 
      if (val && solib_name_from_address (b->address))
 
2103
      if (val && solib_name_from_address (b->pspace, b->address))
1790
2104
        val = 0;
1791
2105
 
1792
2106
      if (val)
1822
2136
  return 0;
1823
2137
}
1824
2138
 
 
2139
static int
 
2140
remove_breakpoint (struct bp_location *b, insertion_state_t is)
 
2141
{
 
2142
  int ret;
 
2143
  struct cleanup *old_chain;
 
2144
 
 
2145
  if (b->owner->enable_state == bp_permanent)
 
2146
    /* Permanent breakpoints cannot be inserted or removed.  */
 
2147
    return 0;
 
2148
 
 
2149
  /* The type of none suggests that owner is actually deleted.
 
2150
     This should not ever happen.  */
 
2151
  gdb_assert (b->owner->type != bp_none);
 
2152
 
 
2153
  old_chain = save_current_space_and_thread ();
 
2154
 
 
2155
  switch_to_program_space_and_thread (b->pspace);
 
2156
 
 
2157
  ret = remove_breakpoint_1 (b, is);
 
2158
 
 
2159
  do_cleanups (old_chain);
 
2160
  return ret;
 
2161
}
 
2162
 
1825
2163
/* Clear the "inserted" flag in all breakpoints.  */
1826
2164
 
1827
2165
void
1828
2166
mark_breakpoints_out (void)
1829
2167
{
1830
 
  struct bp_location *bpt;
 
2168
  struct bp_location *bpt, **bptp_tmp;
1831
2169
 
1832
 
  ALL_BP_LOCATIONS (bpt)
1833
 
    bpt->inserted = 0;
 
2170
  ALL_BP_LOCATIONS (bpt, bptp_tmp)
 
2171
    if (bpt->pspace == current_program_space)
 
2172
      bpt->inserted = 0;
1834
2173
}
1835
2174
 
1836
2175
/* Clear the "inserted" flag in all breakpoints and delete any
1849
2188
breakpoint_init_inferior (enum inf_context context)
1850
2189
{
1851
2190
  struct breakpoint *b, *temp;
1852
 
  struct bp_location *bpt;
 
2191
  struct bp_location *bpt, **bptp_tmp;
1853
2192
  int ix;
 
2193
  struct program_space *pspace = current_program_space;
1854
2194
 
1855
2195
  /* If breakpoint locations are shared across processes, then there's
1856
2196
     nothing to do.  */
1857
2197
  if (gdbarch_has_global_breakpoints (target_gdbarch))
1858
2198
    return;
1859
2199
 
1860
 
  ALL_BP_LOCATIONS (bpt)
1861
 
    if (bpt->owner->enable_state != bp_permanent)
 
2200
  ALL_BP_LOCATIONS (bpt, bptp_tmp)
 
2201
  {
 
2202
    if (bpt->pspace == pspace
 
2203
        && bpt->owner->enable_state != bp_permanent)
1862
2204
      bpt->inserted = 0;
 
2205
  }
1863
2206
 
1864
2207
  ALL_BREAKPOINTS_SAFE (b, temp)
1865
2208
  {
 
2209
    if (b->loc && b->loc->pspace != pspace)
 
2210
      continue;
 
2211
 
1866
2212
    switch (b->type)
1867
2213
      {
1868
2214
      case bp_call_dummy:
1905
2251
  VEC_free (bp_location_p, moribund_locations);
1906
2252
}
1907
2253
 
 
2254
/* These functions concern about actual breakpoints inserted in the
 
2255
   target --- to e.g. check if we need to do decr_pc adjustment or if
 
2256
   we need to hop over the bkpt --- so we check for address space
 
2257
   match, not program space.  */
 
2258
 
1908
2259
/* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
1909
2260
   exists at PC.  It returns ordinary_breakpoint_here if it's an
1910
2261
   ordinary breakpoint, or permanent_breakpoint_here if it's a
1916
2267
     the target, to advance the PC past the breakpoint.  */
1917
2268
 
1918
2269
enum breakpoint_here
1919
 
breakpoint_here_p (CORE_ADDR pc)
 
2270
breakpoint_here_p (struct address_space *aspace, CORE_ADDR pc)
1920
2271
{
1921
 
  const struct bp_location *bpt;
 
2272
  struct bp_location *bpt, **bptp_tmp;
1922
2273
  int any_breakpoint_here = 0;
1923
2274
 
1924
 
  ALL_BP_LOCATIONS (bpt)
 
2275
  ALL_BP_LOCATIONS (bpt, bptp_tmp)
1925
2276
    {
1926
2277
      if (bpt->loc_type != bp_loc_software_breakpoint
1927
2278
          && bpt->loc_type != bp_loc_hardware_breakpoint)
1929
2280
 
1930
2281
      if ((breakpoint_enabled (bpt->owner)
1931
2282
           || bpt->owner->enable_state == bp_permanent)
1932
 
          && bpt->address == pc)        /* bp is enabled and matches pc */
 
2283
          && breakpoint_address_match (bpt->pspace->aspace, bpt->address,
 
2284
                                       aspace, pc))
1933
2285
        {
1934
2286
          if (overlay_debugging 
1935
2287
              && section_is_overlay (bpt->section) 
1948
2300
/* Return true if there's a moribund breakpoint at PC.  */
1949
2301
 
1950
2302
int
1951
 
moribund_breakpoint_here_p (CORE_ADDR pc)
 
2303
moribund_breakpoint_here_p (struct address_space *aspace, CORE_ADDR pc)
1952
2304
{
1953
2305
  struct bp_location *loc;
1954
2306
  int ix;
1955
2307
 
1956
2308
  for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix)
1957
 
    if (loc->address == pc)
 
2309
    if (breakpoint_address_match (loc->pspace->aspace, loc->address,
 
2310
                                  aspace,  pc))
1958
2311
      return 1;
1959
2312
 
1960
2313
  return 0;
1961
2314
}
1962
2315
 
1963
2316
/* Returns non-zero if there's a breakpoint inserted at PC, which is
1964
 
   inserted using regular breakpoint_chain/bp_location_chain mechanism.
 
2317
   inserted using regular breakpoint_chain / bp_location array mechanism.
1965
2318
   This does not check for single-step breakpoints, which are
1966
2319
   inserted and removed using direct target manipulation.  */
1967
2320
 
1968
2321
int
1969
 
regular_breakpoint_inserted_here_p (CORE_ADDR pc)
 
2322
regular_breakpoint_inserted_here_p (struct address_space *aspace, CORE_ADDR pc)
1970
2323
{
1971
 
  const struct bp_location *bpt;
 
2324
  struct bp_location *bpt, **bptp_tmp;
1972
2325
 
1973
 
  ALL_BP_LOCATIONS (bpt)
 
2326
  ALL_BP_LOCATIONS (bpt, bptp_tmp)
1974
2327
    {
1975
2328
      if (bpt->loc_type != bp_loc_software_breakpoint
1976
2329
          && bpt->loc_type != bp_loc_hardware_breakpoint)
1977
2330
        continue;
1978
2331
 
1979
2332
      if (bpt->inserted
1980
 
          && bpt->address == pc)        /* bp is inserted and matches pc */
 
2333
          && breakpoint_address_match (bpt->pspace->aspace, bpt->address,
 
2334
                                       aspace, pc))
1981
2335
        {
1982
2336
          if (overlay_debugging 
1983
2337
              && section_is_overlay (bpt->section) 
1994
2348
   or a single step breakpoint inserted at PC.  */
1995
2349
 
1996
2350
int
1997
 
breakpoint_inserted_here_p (CORE_ADDR pc)
 
2351
breakpoint_inserted_here_p (struct address_space *aspace, CORE_ADDR pc)
1998
2352
{
1999
 
  if (regular_breakpoint_inserted_here_p (pc))
 
2353
  if (regular_breakpoint_inserted_here_p (aspace, pc))
2000
2354
    return 1;
2001
2355
 
2002
 
  if (single_step_breakpoint_inserted_here_p (pc))
 
2356
  if (single_step_breakpoint_inserted_here_p (aspace, pc))
2003
2357
    return 1;
2004
2358
 
2005
2359
  return 0;
2009
2363
   inserted at PC.  */
2010
2364
 
2011
2365
int
2012
 
software_breakpoint_inserted_here_p (CORE_ADDR pc)
 
2366
software_breakpoint_inserted_here_p (struct address_space *aspace, CORE_ADDR pc)
2013
2367
{
2014
 
  const struct bp_location *bpt;
 
2368
  struct bp_location *bpt, **bptp_tmp;
2015
2369
  int any_breakpoint_here = 0;
2016
2370
 
2017
 
  ALL_BP_LOCATIONS (bpt)
 
2371
  ALL_BP_LOCATIONS (bpt, bptp_tmp)
2018
2372
    {
2019
2373
      if (bpt->loc_type != bp_loc_software_breakpoint)
2020
2374
        continue;
2021
2375
 
2022
2376
      if (bpt->inserted
2023
 
          && bpt->address == pc)        /* bp is enabled and matches pc */
 
2377
          && breakpoint_address_match (bpt->pspace->aspace, bpt->address,
 
2378
                                       aspace, pc))
2024
2379
        {
2025
2380
          if (overlay_debugging 
2026
2381
              && section_is_overlay (bpt->section) 
2032
2387
    }
2033
2388
 
2034
2389
  /* Also check for software single-step breakpoints.  */
2035
 
  if (single_step_breakpoint_inserted_here_p (pc))
 
2390
  if (single_step_breakpoint_inserted_here_p (aspace, pc))
2036
2391
    return 1;
2037
2392
 
2038
2393
  return 0;
2039
2394
}
2040
2395
 
 
2396
int
 
2397
hardware_watchpoint_inserted_in_range (struct address_space *aspace,
 
2398
                                       CORE_ADDR addr, ULONGEST len)
 
2399
{
 
2400
  struct breakpoint *bpt;
 
2401
 
 
2402
  ALL_BREAKPOINTS (bpt)
 
2403
    {
 
2404
      struct bp_location *loc;
 
2405
 
 
2406
      if (bpt->type != bp_hardware_watchpoint
 
2407
          && bpt->type != bp_access_watchpoint)
 
2408
        continue;
 
2409
 
 
2410
      if (!breakpoint_enabled (bpt))
 
2411
        continue;
 
2412
 
 
2413
      for (loc = bpt->loc; loc; loc = loc->next)
 
2414
        if (loc->pspace->aspace == aspace && loc->inserted)
 
2415
          {
 
2416
            CORE_ADDR l, h;
 
2417
 
 
2418
            /* Check for intersection.  */
 
2419
            l = max (loc->address, addr);
 
2420
            h = min (loc->address + loc->length, addr + len);
 
2421
            if (l < h)
 
2422
              return 1;
 
2423
          }
 
2424
    }
 
2425
  return 0;
 
2426
}
 
2427
 
2041
2428
/* breakpoint_thread_match (PC, PTID) returns true if the breakpoint at
2042
2429
   PC is valid for process/thread PTID.  */
2043
2430
 
2044
2431
int
2045
 
breakpoint_thread_match (CORE_ADDR pc, ptid_t ptid)
 
2432
breakpoint_thread_match (struct address_space *aspace, CORE_ADDR pc,
 
2433
                         ptid_t ptid)
2046
2434
{
2047
 
  const struct bp_location *bpt;
 
2435
  struct bp_location *bpt, **bptp_tmp;
2048
2436
  /* The thread and task IDs associated to PTID, computed lazily.  */
2049
2437
  int thread = -1;
2050
2438
  int task = 0;
2051
2439
  
2052
 
  ALL_BP_LOCATIONS (bpt)
 
2440
  ALL_BP_LOCATIONS (bpt, bptp_tmp)
2053
2441
    {
2054
2442
      if (bpt->loc_type != bp_loc_software_breakpoint
2055
2443
          && bpt->loc_type != bp_loc_hardware_breakpoint)
2059
2447
          && bpt->owner->enable_state != bp_permanent)
2060
2448
        continue;
2061
2449
 
2062
 
      if (bpt->address != pc)
 
2450
      if (!breakpoint_address_match (bpt->pspace->aspace, bpt->address,
 
2451
                                     aspace, pc))
2063
2452
        continue;
2064
2453
 
2065
2454
      if (bpt->owner->thread != -1)
2594
2983
    case bp_watchpoint_scope:
2595
2984
    case bp_call_dummy:
2596
2985
    case bp_tracepoint:
 
2986
    case bp_fast_tracepoint:
2597
2987
    case bp_jit_event:
2598
2988
    default:
2599
2989
      result = PRINT_UNKNOWN;
2798
3188
#define BP_TEMPFLAG 1
2799
3189
#define BP_HARDWAREFLAG 2
2800
3190
 
2801
 
/* Check watchpoint condition.  */
 
3191
/* Evaluate watchpoint condition expression and check if its value changed.
 
3192
 
 
3193
   P should be a pointer to struct bpstat, but is defined as a void *
 
3194
   in order for this function to be usable with catch_errors.  */
2802
3195
 
2803
3196
static int
2804
3197
watchpoint_check (void *p)
2810
3203
 
2811
3204
  b = bs->breakpoint_at->owner;
2812
3205
 
 
3206
  /* If this is a local watchpoint, we only want to check if the
 
3207
     watchpoint frame is in scope if the current thread is the thread
 
3208
     that was used to create the watchpoint.  */
 
3209
  if (!watchpoint_in_thread_scope (b))
 
3210
    return WP_VALUE_NOT_CHANGED;
 
3211
 
2813
3212
  if (b->exp_valid_block == NULL)
2814
3213
    within_current_scope = 1;
2815
3214
  else
2818
3217
      struct gdbarch *frame_arch = get_frame_arch (frame);
2819
3218
      CORE_ADDR frame_pc = get_frame_pc (frame);
2820
3219
 
 
3220
      /* in_function_epilogue_p() returns a non-zero value if we're still
 
3221
         in the function but the stack frame has already been invalidated.
 
3222
         Since we can't rely on the values of local variables after the
 
3223
         stack has been destroyed, we are treating the watchpoint in that
 
3224
         state as `not changed' without further checking.  Don't mark
 
3225
         watchpoints as changed if the current frame is in an epilogue -
 
3226
         even if they are in some other frame, our view of the stack
 
3227
         is likely to be wrong and frame_find_by_id could error out.  */
 
3228
      if (gdbarch_in_function_epilogue_p (frame_arch, frame_pc))
 
3229
        return WP_VALUE_NOT_CHANGED;
 
3230
 
2821
3231
      fr = frame_find_by_id (b->watchpoint_frame);
2822
3232
      within_current_scope = (fr != NULL);
2823
3233
 
2834
3244
            within_current_scope = 0;
2835
3245
        }
2836
3246
 
2837
 
      /* in_function_epilogue_p() returns a non-zero value if we're still
2838
 
         in the function but the stack frame has already been invalidated.
2839
 
         Since we can't rely on the values of local variables after the
2840
 
         stack has been destroyed, we are treating the watchpoint in that
2841
 
         state as `not changed' without further checking.  Don't mark
2842
 
         watchpoints as changed if the current frame is in an epilogue -
2843
 
         even if they are in some other frame, our view of the stack
2844
 
         is likely to be wrong.  */
2845
 
      if (gdbarch_in_function_epilogue_p (frame_arch, frame_pc))
2846
 
        return WP_VALUE_NOT_CHANGED;
2847
 
 
2848
3247
      if (within_current_scope)
2849
3248
        /* If we end up stopping, the current frame will get selected
2850
3249
           in normal_stop.  So this call to select_frame won't affect
2863
3262
      struct value *new_val;
2864
3263
 
2865
3264
      fetch_watchpoint_value (b->exp, &new_val, NULL, NULL);
 
3265
 
 
3266
      /* We use value_equal_contents instead of value_equal because the latter
 
3267
         coerces an array to a pointer, thus comparing just the address of the
 
3268
         array instead of its contents.  This is not what we want.  */
2866
3269
      if ((b->val != NULL) != (new_val != NULL)
2867
 
          || (b->val != NULL && !value_equal (b->val, new_val)))
 
3270
          || (b->val != NULL && !value_equal_contents (b->val, new_val)))
2868
3271
        {
2869
3272
          if (new_val != NULL)
2870
3273
            {
2919
3322
   breakpoint location BL.  This function does not check if we
2920
3323
   should stop, only if BL explains the stop.   */
2921
3324
static int
2922
 
bpstat_check_location (const struct bp_location *bl, CORE_ADDR bp_addr)
 
3325
bpstat_check_location (const struct bp_location *bl,
 
3326
                       struct address_space *aspace, CORE_ADDR bp_addr)
2923
3327
{
2924
3328
  struct breakpoint *b = bl->owner;
2925
3329
 
 
3330
  /* By definition, the inferior does not report stops at
 
3331
     tracepoints.  */
 
3332
  if (tracepoint_type (b))
 
3333
    return 0;
 
3334
 
2926
3335
  if (b->type != bp_watchpoint
2927
3336
      && b->type != bp_hardware_watchpoint
2928
3337
      && b->type != bp_read_watchpoint
2930
3339
      && b->type != bp_hardware_breakpoint
2931
3340
      && b->type != bp_catchpoint)      /* a non-watchpoint bp */
2932
3341
    {
2933
 
      if (bl->address != bp_addr)       /* address doesn't match */
 
3342
      if (!breakpoint_address_match (bl->pspace->aspace, bl->address,
 
3343
                                     aspace, bp_addr))
2934
3344
        return 0;
2935
3345
      if (overlay_debugging             /* unmapped overlay section */
2936
3346
          && section_is_overlay (bl->section) 
3154
3564
   commands, FIXME??? fields.  */
3155
3565
 
3156
3566
bpstat
3157
 
bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid)
 
3567
bpstat_stop_status (struct address_space *aspace,
 
3568
                    CORE_ADDR bp_addr, ptid_t ptid)
3158
3569
{
3159
3570
  struct breakpoint *b = NULL;
3160
 
  const struct bp_location *bl;
 
3571
  struct bp_location *bl, **blp_tmp;
3161
3572
  struct bp_location *loc;
3162
3573
  /* Root of the chain of bpstat's */
3163
3574
  struct bpstats root_bs[1];
3166
3577
  int ix;
3167
3578
  int need_remove_insert;
3168
3579
 
3169
 
  ALL_BP_LOCATIONS (bl)
3170
 
  {
3171
 
    b = bl->owner;
3172
 
    gdb_assert (b);
3173
 
    if (!breakpoint_enabled (b) && b->enable_state != bp_permanent)
3174
 
      continue;
3175
 
 
3176
 
    /* For hardware watchpoints, we look only at the first location.
3177
 
       The watchpoint_check function will work on entire expression,
3178
 
       not the individual locations.  For read watchopints, the
3179
 
       watchpoints_triggered function have checked all locations
3180
 
       alrea
3181
 
     */
3182
 
    if (b->type == bp_hardware_watchpoint && bl != b->loc)
3183
 
      continue;
3184
 
 
3185
 
    if (!bpstat_check_location (bl, bp_addr))
3186
 
      continue;
3187
 
 
3188
 
    /* Come here if it's a watchpoint, or if the break address matches */
3189
 
 
3190
 
    bs = bpstat_alloc (bl, bs); /* Alloc a bpstat to explain stop */
3191
 
 
3192
 
    /* Assume we stop.  Should we find watchpoint that is not actually
3193
 
       triggered, or if condition of breakpoint is false, we'll reset
3194
 
       'stop' to 0.  */
3195
 
    bs->stop = 1;
3196
 
    bs->print = 1;
3197
 
 
3198
 
    bpstat_check_watchpoint (bs);
3199
 
    if (!bs->stop)
3200
 
      continue;
3201
 
 
3202
 
    if (b->type == bp_thread_event || b->type == bp_overlay_event
3203
 
        || b->type == bp_longjmp_master)
3204
 
      /* We do not stop for these.  */
3205
 
      bs->stop = 0;
3206
 
    else
3207
 
      bpstat_check_breakpoint_conditions (bs, ptid);
3208
 
  
3209
 
    if (bs->stop)
3210
 
      {
3211
 
        ++(b->hit_count);
3212
 
 
3213
 
        /* We will stop here */
3214
 
        if (b->disposition == disp_disable)
3215
 
          {
3216
 
            if (b->enable_state != bp_permanent)
3217
 
              b->enable_state = bp_disabled;
3218
 
            update_global_location_list (0);
3219
 
          }
3220
 
        if (b->silent)
3221
 
          bs->print = 0;
3222
 
        bs->commands = b->commands;
3223
 
        if (bs->commands
3224
 
            && (strcmp ("silent", bs->commands->line) == 0
3225
 
                || (xdb_commands && strcmp ("Q", bs->commands->line) == 0)))
3226
 
          {
3227
 
            bs->commands = bs->commands->next;
3228
 
            bs->print = 0;
3229
 
          }
3230
 
        bs->commands = copy_command_lines (bs->commands);
3231
 
      }
3232
 
 
3233
 
    /* Print nothing for this entry if we dont stop or if we dont print.  */
3234
 
    if (bs->stop == 0 || bs->print == 0)
3235
 
      bs->print_it = print_it_noop;
3236
 
  }
 
3580
  /* ALL_BP_LOCATIONS iteration would break across
 
3581
     update_global_location_list possibly executed by
 
3582
     bpstat_check_breakpoint_conditions's inferior call.  */
 
3583
 
 
3584
  ALL_BREAKPOINTS (b)
 
3585
    {
 
3586
      if (!breakpoint_enabled (b) && b->enable_state != bp_permanent)
 
3587
        continue;
 
3588
 
 
3589
      for (bl = b->loc; bl != NULL; bl = bl->next)
 
3590
        {
 
3591
          /* For hardware watchpoints, we look only at the first location.
 
3592
             The watchpoint_check function will work on entire expression,
 
3593
             not the individual locations.  For read watchopints, the
 
3594
             watchpoints_triggered function have checked all locations
 
3595
             already.  */
 
3596
          if (b->type == bp_hardware_watchpoint && bl != b->loc)
 
3597
            break;
 
3598
 
 
3599
          if (bl->shlib_disabled)
 
3600
            continue;
 
3601
 
 
3602
          if (!bpstat_check_location (bl, aspace, bp_addr))
 
3603
            continue;
 
3604
 
 
3605
          /* Come here if it's a watchpoint, or if the break address matches */
 
3606
 
 
3607
          bs = bpstat_alloc (bl, bs);   /* Alloc a bpstat to explain stop */
 
3608
 
 
3609
          /* Assume we stop.  Should we find watchpoint that is not actually
 
3610
             triggered, or if condition of breakpoint is false, we'll reset
 
3611
             'stop' to 0.  */
 
3612
          bs->stop = 1;
 
3613
          bs->print = 1;
 
3614
 
 
3615
          bpstat_check_watchpoint (bs);
 
3616
          if (!bs->stop)
 
3617
            continue;
 
3618
 
 
3619
          if (b->type == bp_thread_event || b->type == bp_overlay_event
 
3620
              || b->type == bp_longjmp_master)
 
3621
            /* We do not stop for these.  */
 
3622
            bs->stop = 0;
 
3623
          else
 
3624
            bpstat_check_breakpoint_conditions (bs, ptid);
 
3625
        
 
3626
          if (bs->stop)
 
3627
            {
 
3628
              ++(b->hit_count);
 
3629
 
 
3630
              /* We will stop here */
 
3631
              if (b->disposition == disp_disable)
 
3632
                {
 
3633
                  if (b->enable_state != bp_permanent)
 
3634
                    b->enable_state = bp_disabled;
 
3635
                  update_global_location_list (0);
 
3636
                }
 
3637
              if (b->silent)
 
3638
                bs->print = 0;
 
3639
              bs->commands = b->commands;
 
3640
              if (bs->commands
 
3641
                  && (strcmp ("silent", bs->commands->line) == 0
 
3642
                      || (xdb_commands && strcmp ("Q",
 
3643
                                                  bs->commands->line) == 0)))
 
3644
                {
 
3645
                  bs->commands = bs->commands->next;
 
3646
                  bs->print = 0;
 
3647
                }
 
3648
              bs->commands = copy_command_lines (bs->commands);
 
3649
            }
 
3650
 
 
3651
          /* Print nothing for this entry if we dont stop or dont print.  */
 
3652
          if (bs->stop == 0 || bs->print == 0)
 
3653
            bs->print_it = print_it_noop;
 
3654
        }
 
3655
    }
3237
3656
 
3238
3657
  for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix)
3239
3658
    {
3240
 
      if (loc->address == bp_addr)
 
3659
      if (breakpoint_address_match (loc->pspace->aspace, loc->address,
 
3660
                                    aspace, bp_addr))
3241
3661
        {
3242
3662
          bs = bpstat_alloc (loc, bs);
3243
3663
          /* For hits of moribund locations, we should just proceed.  */
3248
3668
    }
3249
3669
 
3250
3670
  bs->next = NULL;              /* Terminate the chain */
3251
 
  bs = root_bs->next;           /* Re-grab the head of the chain */
3252
3671
 
3253
3672
  /* If we aren't stopping, the value of some hardware watchpoint may
3254
3673
     not have changed, but the intermediate memory locations we are
3263
3682
    for (bs = root_bs->next; bs != NULL; bs = bs->next)
3264
3683
      if (!bs->stop
3265
3684
          && bs->breakpoint_at->owner
3266
 
          && (bs->breakpoint_at->owner->type == bp_hardware_watchpoint
3267
 
              || bs->breakpoint_at->owner->type == bp_read_watchpoint
3268
 
              || bs->breakpoint_at->owner->type == bp_access_watchpoint))
 
3685
          && is_hardware_watchpoint (bs->breakpoint_at->owner))
3269
3686
        {
3270
 
          /* remove/insert can invalidate bs->breakpoint_at, if this
3271
 
             location is no longer used by the watchpoint.  Prevent
3272
 
             further code from trying to use it.  */
 
3687
          update_watchpoint (bs->breakpoint_at->owner, 0 /* don't reparse. */);
 
3688
          /* Updating watchpoints invalidates bs->breakpoint_at.
 
3689
             Prevent further code from trying to use it.  */
3273
3690
          bs->breakpoint_at = NULL;
3274
3691
          need_remove_insert = 1;
3275
3692
        }
3276
3693
 
3277
3694
  if (need_remove_insert)
3278
 
    {
3279
 
      remove_breakpoints ();
3280
 
      insert_breakpoints ();
3281
 
    }
 
3695
    update_global_location_list (1);
3282
3696
 
3283
3697
  return root_bs->next;
3284
3698
}
3506
3920
          retval.call_dummy = 1;
3507
3921
          break;
3508
3922
        case bp_tracepoint:
 
3923
        case bp_fast_tracepoint:
3509
3924
          /* Tracepoint hits should not be reported back to GDB, and
3510
3925
             if one got through somehow, it should have been filtered
3511
3926
             out already.  */
3512
3927
          internal_error (__FILE__, __LINE__,
3513
 
                          _("bpstat_what: bp_tracepoint encountered"));
 
3928
                          _("bpstat_what: tracepoint encountered"));
3514
3929
          break;
3515
3930
        }
3516
3931
      current_action = table[(int) bs_class][(int) current_action];
3533
3948
  return 0;
3534
3949
}
3535
3950
 
 
3951
int
 
3952
bpstat_causes_stop (bpstat bs)
 
3953
{
 
3954
  for (; bs != NULL; bs = bs->next)
 
3955
    if (bs->stop)
 
3956
      return 1;
 
3957
 
 
3958
  return 0;
 
3959
}
 
3960
 
3536
3961
 
3537
3962
 
 
3963
/* Print the LOC location out of the list of B->LOC locations.  */
 
3964
 
3538
3965
static void print_breakpoint_location (struct breakpoint *b,
3539
3966
                                       struct bp_location *loc,
3540
3967
                                       char *wrap_indent,
3541
3968
                                       struct ui_stream *stb)
3542
3969
{
3543
 
  if (b->source_file)
 
3970
  struct cleanup *old_chain = save_current_program_space ();
 
3971
 
 
3972
  if (loc != NULL && loc->shlib_disabled)
 
3973
    loc = NULL;
 
3974
 
 
3975
  if (loc != NULL)
 
3976
    set_current_program_space (loc->pspace);
 
3977
 
 
3978
  if (b->source_file && loc)
3544
3979
    {
3545
3980
      struct symbol *sym 
3546
3981
        = find_pc_sect_function (loc->address, loc->section);
3566
4001
      
3567
4002
      ui_out_field_int (uiout, "line", b->line_number);
3568
4003
    }
3569
 
  else if (!b->loc)
3570
 
    {
3571
 
      ui_out_field_string (uiout, "pending", b->addr_string);
3572
 
    }
3573
 
  else
3574
 
    {
3575
 
      print_address_symbolic (loc->address, stb->stream, demangle, "");
 
4004
  else if (loc)
 
4005
    {
 
4006
      print_address_symbolic (loc->gdbarch, loc->address, stb->stream,
 
4007
                              demangle, "");
3576
4008
      ui_out_field_stream (uiout, "at", stb);
3577
4009
    }
 
4010
  else
 
4011
    ui_out_field_string (uiout, "pending", b->addr_string);
 
4012
 
 
4013
  do_cleanups (old_chain);
3578
4014
}
3579
4015
 
3580
4016
/* Print B to gdb_stdout. */
3583
4019
                               struct bp_location *loc,
3584
4020
                               int loc_number,
3585
4021
                               struct bp_location **last_loc,
3586
 
                               int print_address_bits)
 
4022
                               int print_address_bits,
 
4023
                               int allflag)
3587
4024
{
3588
4025
  struct command_line *l;
3589
4026
  struct symbol *sym;
3614
4051
    {bp_longjmp_master, "longjmp master"},
3615
4052
    {bp_catchpoint, "catchpoint"},
3616
4053
    {bp_tracepoint, "tracepoint"},
 
4054
    {bp_fast_tracepoint, "fast tracepoint"},
3617
4055
    {bp_jit_event, "jit events"},
3618
4056
  };
3619
4057
  
3743
4181
      case bp_overlay_event:
3744
4182
      case bp_longjmp_master:
3745
4183
      case bp_tracepoint:
 
4184
      case bp_fast_tracepoint:
3746
4185
      case bp_jit_event:
3747
4186
        if (opts.addressprint)
3748
4187
          {
3763
4202
        break;
3764
4203
      }
3765
4204
 
 
4205
 
 
4206
  /* For backward compatibility, don't display inferiors unless there
 
4207
     are several.  */
 
4208
  if (loc != NULL
 
4209
      && !header_of_multiple
 
4210
      && (allflag
 
4211
          || (!gdbarch_has_global_breakpoints (target_gdbarch)
 
4212
              && (number_of_program_spaces () > 1
 
4213
                  || number_of_inferiors () > 1)
 
4214
              && loc->owner->type != bp_catchpoint)))
 
4215
    {
 
4216
      struct inferior *inf;
 
4217
      int first = 1;
 
4218
 
 
4219
      for (inf = inferior_list; inf != NULL; inf = inf->next)
 
4220
        {
 
4221
          if (inf->pspace == loc->pspace)
 
4222
            {
 
4223
              if (first)
 
4224
                {
 
4225
                  first = 0;
 
4226
                  ui_out_text (uiout, " inf ");
 
4227
                }
 
4228
              else
 
4229
                ui_out_text (uiout, ", ");
 
4230
              ui_out_text (uiout, plongest (inf->num));
 
4231
            }
 
4232
        }
 
4233
    }
 
4234
 
3766
4235
  if (!part_of_multiple)
3767
4236
    {
3768
4237
      if (b->thread != -1)
3798
4267
         because the condition is an internal implementation detail
3799
4268
         that we do not want to expose to the user.  */
3800
4269
      annotate_field (7);
3801
 
      if (b->type == bp_tracepoint)
 
4270
      if (tracepoint_type (b))
3802
4271
        ui_out_text (uiout, "\ttrace only if ");
3803
4272
      else
3804
4273
        ui_out_text (uiout, "\tstop only if ");
3896
4365
 
3897
4366
static void
3898
4367
print_one_breakpoint (struct breakpoint *b,
3899
 
                      struct bp_location **last_loc, int print_address_bits)
 
4368
                      struct bp_location **last_loc, int print_address_bits,
 
4369
                      int allflag)
3900
4370
{
3901
 
  print_one_breakpoint_location (b, NULL, 0, last_loc, print_address_bits);
 
4371
  print_one_breakpoint_location (b, NULL, 0, last_loc,
 
4372
                                 print_address_bits, allflag);
3902
4373
 
3903
4374
  /* If this breakpoint has custom print function,
3904
4375
     it's already printed.  Otherwise, print individual
3922
4393
          int n = 1;
3923
4394
          for (loc = b->loc; loc; loc = loc->next, ++n)
3924
4395
            print_one_breakpoint_location (b, loc, n, last_loc,
3925
 
                                           print_address_bits);
 
4396
                                           print_address_bits, allflag);
3926
4397
        }
3927
4398
    }
3928
4399
}
3935
4406
 
3936
4407
  for (loc = b->loc; loc; loc = loc->next)
3937
4408
    {
3938
 
      int addr_bit = gdbarch_addr_bit (b->gdbarch);
 
4409
      int addr_bit = gdbarch_addr_bit (loc->gdbarch);
3939
4410
      if (addr_bit > print_address_bits)
3940
4411
        print_address_bits = addr_bit;
3941
4412
    }
3959
4430
      if (args->bnum == b->number)
3960
4431
        {
3961
4432
          int print_address_bits = breakpoint_address_bits (b);
3962
 
          print_one_breakpoint (b, &dummy_loc, print_address_bits);
 
4433
          print_one_breakpoint (b, &dummy_loc, print_address_bits, 0);
3963
4434
          return GDB_RC_OK;
3964
4435
        }
3965
4436
    }
3989
4460
  return (b->type == bp_breakpoint
3990
4461
          || b->type == bp_catchpoint
3991
4462
          || b->type == bp_hardware_breakpoint
3992
 
          || b->type == bp_tracepoint
 
4463
          || tracepoint_type (b)
3993
4464
          || b->type == bp_watchpoint
3994
4465
          || b->type == bp_read_watchpoint
3995
4466
          || b->type == bp_access_watchpoint
4075
4546
        /* We only print out user settable breakpoints unless the
4076
4547
           allflag is set. */
4077
4548
        if (allflag || user_settable_breakpoint (b))
4078
 
          print_one_breakpoint (b, &last_loc, print_address_bits);
 
4549
          print_one_breakpoint (b, &last_loc, print_address_bits, allflag);
4079
4550
      }
4080
4551
  
4081
4552
  do_cleanups (bkpttbl_chain);
4123
4594
 
4124
4595
static int
4125
4596
breakpoint_has_pc (struct breakpoint *b,
 
4597
                   struct program_space *pspace,
4126
4598
                   CORE_ADDR pc, struct obj_section *section)
4127
4599
{
4128
4600
  struct bp_location *bl = b->loc;
4129
4601
  for (; bl; bl = bl->next)
4130
4602
    {
4131
 
      if (bl->address == pc
 
4603
      if (bl->pspace == pspace
 
4604
          && bl->address == pc
4132
4605
          && (!overlay_debugging || bl->section == section))
4133
4606
        return 1;         
4134
4607
    }
4135
4608
  return 0;
4136
4609
}
4137
4610
 
4138
 
/* Print a message describing any breakpoints set at PC.  */
 
4611
/* Print a message describing any breakpoints set at PC.  This
 
4612
   concerns with logical breakpoints, so we match program spaces, not
 
4613
   address spaces.  */
4139
4614
 
4140
4615
static void
4141
 
describe_other_breakpoints (struct gdbarch *gdbarch, CORE_ADDR pc,
 
4616
describe_other_breakpoints (struct gdbarch *gdbarch,
 
4617
                            struct program_space *pspace, CORE_ADDR pc,
4142
4618
                            struct obj_section *section, int thread)
4143
4619
{
4144
4620
  int others = 0;
4145
4621
  struct breakpoint *b;
4146
4622
 
4147
4623
  ALL_BREAKPOINTS (b)
4148
 
    others += breakpoint_has_pc (b, pc, section);
 
4624
    others += breakpoint_has_pc (b, pspace, pc, section);
4149
4625
  if (others > 0)
4150
4626
    {
4151
4627
      if (others == 1)
4153
4629
      else /* if (others == ???) */
4154
4630
        printf_filtered (_("Note: breakpoints "));
4155
4631
      ALL_BREAKPOINTS (b)
4156
 
        if (breakpoint_has_pc (b, pc, section))
 
4632
        if (breakpoint_has_pc (b, pspace, pc, section))
4157
4633
          {
4158
4634
            others--;
4159
4635
            printf_filtered ("%d", b->number);
4182
4658
   for the `break' command with no arguments.  */
4183
4659
 
4184
4660
void
4185
 
set_default_breakpoint (int valid, CORE_ADDR addr, struct symtab *symtab,
 
4661
set_default_breakpoint (int valid, struct program_space *pspace,
 
4662
                        CORE_ADDR addr, struct symtab *symtab,
4186
4663
                        int line)
4187
4664
{
4188
4665
  default_breakpoint_valid = valid;
 
4666
  default_breakpoint_pspace = pspace;
4189
4667
  default_breakpoint_address = addr;
4190
4668
  default_breakpoint_symtab = symtab;
4191
4669
  default_breakpoint_line = line;
4197
4675
   (or use it for any other purpose either).
4198
4676
 
4199
4677
   More specifically, each of the following breakpoint types will always
4200
 
   have a zero valued address and we don't want check_duplicates() to mark
4201
 
   breakpoints of any of these types to be a duplicate of an actual
4202
 
   breakpoint at address zero:
 
4678
   have a zero valued address and we don't want to mark breakpoints of any of
 
4679
   these types to be a duplicate of an actual breakpoint at address zero:
4203
4680
 
4204
4681
      bp_watchpoint
4205
 
      bp_hardware_watchpoint
4206
 
      bp_read_watchpoint
4207
 
      bp_access_watchpoint
4208
 
      bp_catchpoint */
 
4682
      bp_catchpoint
 
4683
 
 
4684
*/
4209
4685
 
4210
4686
static int
4211
4687
breakpoint_address_is_meaningful (struct breakpoint *bpt)
4212
4688
{
4213
4689
  enum bptype type = bpt->type;
4214
4690
 
4215
 
  return (type != bp_watchpoint
4216
 
          && type != bp_hardware_watchpoint
4217
 
          && type != bp_read_watchpoint
4218
 
          && type != bp_access_watchpoint
4219
 
          && type != bp_catchpoint);
4220
 
}
4221
 
 
4222
 
/* Rescan breakpoints at the same address and section as BPT,
4223
 
   marking the first one as "first" and any others as "duplicates".
4224
 
   This is so that the bpt instruction is only inserted once.
4225
 
   If we have a permanent breakpoint at the same place as BPT, make
4226
 
   that one the official one, and the rest as duplicates.  */
4227
 
 
4228
 
static void
4229
 
check_duplicates_for (CORE_ADDR address, struct obj_section *section)
4230
 
{
4231
 
  struct bp_location *b;
4232
 
  int count = 0;
4233
 
  struct bp_location *perm_bp = 0;
4234
 
 
4235
 
  ALL_BP_LOCATIONS (b)
4236
 
    if (b->owner->enable_state != bp_disabled
4237
 
        && b->owner->enable_state != bp_call_disabled
4238
 
        && b->owner->enable_state != bp_startup_disabled
4239
 
        && b->enabled
4240
 
        && !b->shlib_disabled
4241
 
        && b->address == address        /* address / overlay match */
4242
 
        && (!overlay_debugging || b->section == section)
4243
 
        && breakpoint_address_is_meaningful (b->owner))
4244
 
    {
4245
 
      /* Have we found a permanent breakpoint?  */
4246
 
      if (b->owner->enable_state == bp_permanent)
4247
 
        {
4248
 
          perm_bp = b;
4249
 
          break;
4250
 
        }
4251
 
        
4252
 
      count++;
4253
 
      b->duplicate = count > 1;
4254
 
    }
4255
 
 
4256
 
  /* If we found a permanent breakpoint at this address, go over the
4257
 
     list again and declare all the other breakpoints there (except
4258
 
     other permanent breakpoints) to be the duplicates.  */
4259
 
  if (perm_bp)
4260
 
    {
4261
 
      perm_bp->duplicate = 0;
4262
 
 
4263
 
      /* Permanent breakpoint should always be inserted.  */
4264
 
      if (! perm_bp->inserted)
4265
 
        internal_error (__FILE__, __LINE__,
4266
 
                        _("allegedly permanent breakpoint is not "
4267
 
                        "actually inserted"));
4268
 
 
4269
 
      ALL_BP_LOCATIONS (b)
4270
 
        if (b != perm_bp)
4271
 
          {
4272
 
            if (b->owner->enable_state != bp_permanent
4273
 
                && b->owner->enable_state != bp_disabled
4274
 
                && b->owner->enable_state != bp_call_disabled
4275
 
                && b->owner->enable_state != bp_startup_disabled
4276
 
                && b->enabled && !b->shlib_disabled             
4277
 
                && b->address == address        /* address / overlay match */
4278
 
                && (!overlay_debugging || b->section == section)
4279
 
                && breakpoint_address_is_meaningful (b->owner))
4280
 
              {
4281
 
                if (b->inserted)
4282
 
                  internal_error (__FILE__, __LINE__,
4283
 
                                  _("another breakpoint was inserted on top of "
4284
 
                                  "a permanent breakpoint"));
4285
 
 
4286
 
                b->duplicate = 1;
4287
 
              }
4288
 
          }
4289
 
    }
4290
 
}
4291
 
 
4292
 
static void
4293
 
check_duplicates (struct breakpoint *bpt)
4294
 
{
4295
 
  struct bp_location *bl = bpt->loc;
4296
 
 
4297
 
  if (! breakpoint_address_is_meaningful (bpt))
4298
 
    return;
4299
 
 
4300
 
  for (; bl; bl = bl->next)
4301
 
    check_duplicates_for (bl->address, bl->section);    
 
4691
  return (type != bp_watchpoint && type != bp_catchpoint);
 
4692
}
 
4693
 
 
4694
/* Assuming LOC1 and LOC2's owners are hardware watchpoints, returns
 
4695
   true if LOC1 and LOC2 represent the same watchpoint location.  */
 
4696
 
 
4697
static int
 
4698
watchpoint_locations_match (struct bp_location *loc1, struct bp_location *loc2)
 
4699
{
 
4700
  return (loc1->owner->type == loc2->owner->type
 
4701
          && loc1->pspace->aspace == loc2->pspace->aspace
 
4702
          && loc1->address == loc2->address
 
4703
          && loc1->length == loc2->length);
 
4704
}
 
4705
 
 
4706
/* Returns true if {ASPACE1,ADDR1} and {ASPACE2,ADDR2} represent the
 
4707
   same breakpoint location.  In most targets, this can only be true
 
4708
   if ASPACE1 matches ASPACE2.  On targets that have global
 
4709
   breakpoints, the address space doesn't really matter.  */
 
4710
 
 
4711
static int
 
4712
breakpoint_address_match (struct address_space *aspace1, CORE_ADDR addr1,
 
4713
                          struct address_space *aspace2, CORE_ADDR addr2)
 
4714
{
 
4715
  return ((gdbarch_has_global_breakpoints (target_gdbarch)
 
4716
           || aspace1 == aspace2)
 
4717
          && addr1 == addr2);
 
4718
}
 
4719
 
 
4720
/* Assuming LOC1 and LOC2's types' have meaningful target addresses
 
4721
   (breakpoint_address_is_meaningful), returns true if LOC1 and LOC2
 
4722
   represent the same location.  */
 
4723
 
 
4724
static int
 
4725
breakpoint_locations_match (struct bp_location *loc1, struct bp_location *loc2)
 
4726
{
 
4727
  int hw_point1 = is_hardware_watchpoint (loc1->owner);
 
4728
  int hw_point2 = is_hardware_watchpoint (loc2->owner);
 
4729
 
 
4730
  if (hw_point1 != hw_point2)
 
4731
    return 0;
 
4732
  else if (hw_point1)
 
4733
    return watchpoint_locations_match (loc1, loc2);
 
4734
  else
 
4735
    return breakpoint_address_match (loc1->pspace->aspace, loc1->address,
 
4736
                                     loc2->pspace->aspace, loc2->address);
4302
4737
}
4303
4738
 
4304
4739
static void
4377
4812
  switch (bpt->type)
4378
4813
    {
4379
4814
    case bp_breakpoint:
4380
 
    case bp_tracepoint:
4381
4815
    case bp_until:
4382
4816
    case bp_finish:
4383
4817
    case bp_longjmp:
4402
4836
      break;
4403
4837
    case bp_watchpoint:
4404
4838
    case bp_catchpoint:
 
4839
    case bp_tracepoint:
 
4840
    case bp_fast_tracepoint:
4405
4841
      loc->loc_type = bp_loc_other;
4406
4842
      break;
4407
4843
    default:
4474
4910
{
4475
4911
  if (loc->owner->type == bp_breakpoint
4476
4912
      || loc->owner->type == bp_hardware_breakpoint
4477
 
      || loc->owner->type == bp_tracepoint)
 
4913
      || tracepoint_type (loc->owner))
4478
4914
    {
4479
4915
      find_pc_partial_function (loc->address, &(loc->function_name), 
4480
4916
                                NULL, NULL);
4522
4958
  if (!loc_gdbarch)
4523
4959
    loc_gdbarch = b->gdbarch;
4524
4960
 
 
4961
  if (bptype != bp_catchpoint)
 
4962
    gdb_assert (sal.pspace != NULL);
 
4963
 
4525
4964
  /* Adjust the breakpoint's address prior to allocating a location.
4526
4965
     Once we call allocate_bp_location(), that mostly uninitialized
4527
4966
     location will be placed on the location chain.  Adjustment of the
4534
4973
  b->loc->gdbarch = loc_gdbarch;
4535
4974
  b->loc->requested_address = sal.pc;
4536
4975
  b->loc->address = adjusted_address;
 
4976
  b->loc->pspace = sal.pspace;
 
4977
 
 
4978
  /* Store the program space that was used to set the breakpoint, for
 
4979
     breakpoint resetting.  */
 
4980
  b->pspace = sal.pspace;
4537
4981
 
4538
4982
  if (sal.symtab == NULL)
4539
4983
    b->source_file = NULL;
4581
5025
     longjmp "master" breakpoints.  Here, we simply create momentary
4582
5026
     clones of those and enable them for the requested thread.  */
4583
5027
  ALL_BREAKPOINTS_SAFE (b, temp)
4584
 
    if (b->type == bp_longjmp_master)
 
5028
    if (b->pspace == current_program_space
 
5029
        && b->type == bp_longjmp_master)
4585
5030
      {
4586
5031
        struct breakpoint *clone = clone_momentary_breakpoint (b);
4587
5032
        clone->type = bp_longjmp;
4654
5099
  struct breakpoint *b, *temp;
4655
5100
 
4656
5101
  ALL_BREAKPOINTS_SAFE (b, temp)
4657
 
    if (b->type == bp_thread_event)
 
5102
    if (b->type == bp_thread_event
 
5103
        && b->loc->pspace == current_program_space)
4658
5104
      delete_breakpoint (b);
4659
5105
}
4660
5106
 
4690
5136
  struct breakpoint *b, *temp;
4691
5137
 
4692
5138
  ALL_BREAKPOINTS_SAFE (b, temp)
4693
 
    if (b->type == bp_shlib_event)
 
5139
    if (b->type == bp_shlib_event
 
5140
        && b->loc->pspace == current_program_space)
4694
5141
      delete_breakpoint (b);
4695
5142
}
4696
5143
 
4710
5157
void
4711
5158
disable_breakpoints_in_shlibs (void)
4712
5159
{
4713
 
  struct bp_location *loc;
 
5160
  struct bp_location *loc, **locp_tmp;
4714
5161
 
4715
 
  ALL_BP_LOCATIONS (loc)
 
5162
  ALL_BP_LOCATIONS (loc, locp_tmp)
4716
5163
  {
4717
5164
    struct breakpoint *b = loc->owner;
4718
5165
    /* We apply the check to all breakpoints, including disabled
4722
5169
       to insert those breakpoints and fail.  */
4723
5170
    if (((b->type == bp_breakpoint)
4724
5171
         || (b->type == bp_hardware_breakpoint)
4725
 
         || (b->type == bp_tracepoint))
 
5172
         || (tracepoint_type (b)))
 
5173
        && loc->pspace == current_program_space
4726
5174
        && !loc->shlib_disabled
4727
5175
#ifdef PC_SOLIB
4728
5176
        && PC_SOLIB (loc->address)
4729
5177
#else
4730
 
        && solib_name_from_address (loc->address)
 
5178
        && solib_name_from_address (loc->pspace, loc->address)
4731
5179
#endif
4732
5180
        )
4733
5181
      {
4742
5190
static void
4743
5191
disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
4744
5192
{
4745
 
  struct bp_location *loc;
 
5193
  struct bp_location *loc, **locp_tmp;
4746
5194
  int disabled_shlib_breaks = 0;
4747
5195
 
4748
5196
  /* SunOS a.out shared libraries are always mapped, so do not
4753
5201
      && bfd_get_flavour (exec_bfd) == bfd_target_aout_flavour)
4754
5202
    return;
4755
5203
 
4756
 
  ALL_BP_LOCATIONS (loc)
 
5204
  ALL_BP_LOCATIONS (loc, locp_tmp)
4757
5205
  {
4758
5206
    struct breakpoint *b = loc->owner;
4759
5207
    if ((loc->loc_type == bp_loc_hardware_breakpoint
4760
5208
         || loc->loc_type == bp_loc_software_breakpoint)
 
5209
        && solib->pspace == loc->pspace
4761
5210
        && !loc->shlib_disabled
4762
5211
        && (b->type == bp_breakpoint || b->type == bp_hardware_breakpoint)
4763
5212
        && solib_contains_address_p (solib, loc->address))
5218
5667
  struct breakpoint *b;
5219
5668
 
5220
5669
  init_sal (&sal);
 
5670
  sal.pspace = current_program_space;
5221
5671
 
5222
5672
  b = set_raw_breakpoint (gdbarch, sal, bp_catchpoint);
5223
5673
  set_breakpoint_count (breakpoint_count + 1);
5432
5882
 
5433
5883
  ALL_BREAKPOINTS (b)
5434
5884
    {
 
5885
      if (b->pspace != current_program_space)
 
5886
        continue;
 
5887
 
5435
5888
      if ((b->type == bp_breakpoint
5436
5889
           || b->type == bp_hardware_breakpoint)
5437
5890
          && breakpoint_enabled (b))
5444
5897
  if (found)
5445
5898
    update_global_location_list (0);
5446
5899
 
5447
 
  executing_startup = 1;
 
5900
  current_program_space->executing_startup = 1;
5448
5901
}
5449
5902
 
5450
5903
void
5453
5906
  struct breakpoint *b;
5454
5907
  int found = 0;
5455
5908
 
5456
 
  executing_startup = 0;
 
5909
  current_program_space->executing_startup = 0;
5457
5910
 
5458
5911
  ALL_BREAKPOINTS (b)
5459
5912
    {
 
5913
      if (b->pspace != current_program_space)
 
5914
        continue;
 
5915
 
5460
5916
      if ((b->type == bp_breakpoint
5461
5917
           || b->type == bp_hardware_breakpoint)
5462
5918
          && b->enable_state == bp_startup_disabled)
5521
5977
  copy->loc->requested_address = orig->loc->requested_address;
5522
5978
  copy->loc->address = orig->loc->address;
5523
5979
  copy->loc->section = orig->loc->section;
 
5980
  copy->loc->pspace = orig->loc->pspace;
5524
5981
 
5525
5982
  if (orig->source_file == NULL)
5526
5983
    copy->source_file = NULL;
5530
5987
  copy->line_number = orig->line_number;
5531
5988
  copy->frame_id = orig->frame_id;
5532
5989
  copy->thread = orig->thread;
 
5990
  copy->pspace = orig->pspace;
5533
5991
 
5534
5992
  copy->enable_state = bp_enabled;
5535
5993
  copy->disposition = disp_donttouch;
5643
6101
        printf_filtered (_(" %d"), b->number);
5644
6102
        say_where = 1;
5645
6103
        break;
 
6104
      case bp_fast_tracepoint:
 
6105
        if (ui_out_is_mi_like_p (uiout))
 
6106
          {
 
6107
            say_where = 0;
 
6108
            break;
 
6109
          }
 
6110
        printf_filtered (_("Fast tracepoint"));
 
6111
        printf_filtered (_(" %d"), b->number);
 
6112
        say_where = 1;
 
6113
        break;
5646
6114
 
5647
6115
      case bp_until:
5648
6116
      case bp_finish:
5712
6180
  loc->requested_address = sal->pc;
5713
6181
  loc->address = adjust_breakpoint_address (loc->gdbarch,
5714
6182
                                            loc->requested_address, b->type);
 
6183
  loc->pspace = sal->pspace;
 
6184
  gdb_assert (loc->pspace != NULL);
5715
6185
  loc->section = sal->section;
5716
6186
 
5717
6187
  set_breakpoint_location_function (loc);
5746
6216
  /* Enable the automatic memory restoration from breakpoints while
5747
6217
     we read the memory.  Otherwise we could say about our temporary
5748
6218
     breakpoints they are permanent.  */
5749
 
  cleanup = make_show_memory_breakpoints_cleanup (0);
 
6219
  cleanup = save_current_space_and_thread ();
 
6220
 
 
6221
  switch_to_program_space_and_thread (loc->pspace);
 
6222
  make_show_memory_breakpoints_cleanup (0);
5750
6223
 
5751
6224
  if (target_read_memory (loc->address, target_mem, len) == 0
5752
6225
      && memcmp (target_mem, brk, len) == 0)
5786
6259
        error (_("Hardware breakpoints used exceeds limit."));
5787
6260
    }
5788
6261
 
 
6262
  gdb_assert (sals.nelts > 0);
 
6263
 
5789
6264
  for (i = 0; i < sals.nelts; ++i)
5790
6265
    {
5791
6266
      struct symtab_and_line sal = sals.sals[i];
5798
6273
            loc_gdbarch = gdbarch;
5799
6274
 
5800
6275
          describe_other_breakpoints (loc_gdbarch,
5801
 
                                      sal.pc, sal.section, thread);
 
6276
                                      sal.pspace, sal.pc, sal.section, thread);
5802
6277
        }
5803
6278
 
5804
6279
      if (i == 0)
5814
6289
          b->enable_state = enabled ? bp_enabled : bp_disabled;
5815
6290
          b->disposition = disposition;
5816
6291
 
5817
 
          if (enabled && executing_startup
 
6292
          b->pspace = sals.sals[0].pspace;
 
6293
 
 
6294
          if (enabled && b->pspace->executing_startup
5818
6295
              && (b->type == bp_breakpoint
5819
6296
                  || b->type == bp_hardware_breakpoint))
5820
6297
            b->enable_state = bp_startup_disabled;
5864
6341
  --(sal->nelts);
5865
6342
}
5866
6343
 
5867
 
/* If appropriate, obtains all sals that correspond
5868
 
   to the same file and line as SAL.  This is done
5869
 
   only if SAL does not have explicit PC and has
5870
 
   line and file information.  If we got just a single
5871
 
   expanded sal, return the original.
5872
 
 
5873
 
   Otherwise, if SAL.explicit_line is not set, filter out 
5874
 
   all sals for which the name of enclosing function 
5875
 
   is different from SAL. This makes sure that if we have
5876
 
   breakpoint originally set in template instantiation, say
5877
 
   foo<int>(), we won't expand SAL to locations at the same
5878
 
   line in all existing instantiations of 'foo'.
5879
 
 
5880
 
*/
 
6344
/* If appropriate, obtains all sals that correspond to the same file
 
6345
   and line as SAL, in all program spaces.  Users debugging with IDEs,
 
6346
   will want to set a breakpoint at foo.c:line, and not really care
 
6347
   about program spaces.  This is done only if SAL does not have
 
6348
   explicit PC and has line and file information.  If we got just a
 
6349
   single expanded sal, return the original.
 
6350
 
 
6351
   Otherwise, if SAL.explicit_line is not set, filter out all sals for
 
6352
   which the name of enclosing function is different from SAL.  This
 
6353
   makes sure that if we have breakpoint originally set in template
 
6354
   instantiation, say foo<int>(), we won't expand SAL to locations at
 
6355
   the same line in all existing instantiations of 'foo'.  */
 
6356
 
5881
6357
static struct symtabs_and_lines
5882
6358
expand_line_sal_maybe (struct symtab_and_line sal)
5883
6359
{
5886
6362
  char *original_function = NULL;
5887
6363
  int found;
5888
6364
  int i;
 
6365
  struct cleanup *old_chain;
5889
6366
 
5890
6367
  /* If we have explicit pc, don't expand.
5891
6368
     If we have no line number, we can't expand.  */
5898
6375
    }
5899
6376
 
5900
6377
  sal.pc = 0;
 
6378
 
 
6379
  old_chain = save_current_space_and_thread ();
 
6380
 
 
6381
  switch_to_program_space_and_thread (sal.pspace);
 
6382
 
5901
6383
  find_pc_partial_function (original_pc, &original_function, NULL, NULL);
5902
 
  
 
6384
 
 
6385
  /* Note that expand_line_sal visits *all* program spaces.  */
5903
6386
  expanded = expand_line_sal (sal);
 
6387
 
5904
6388
  if (expanded.nelts == 1)
5905
6389
    {
5906
 
      /* We had one sal, we got one sal.  Without futher
5907
 
         processing, just return the original sal.  */
 
6390
      /* We had one sal, we got one sal.  Return that sal, adjusting it
 
6391
         past the function prologue if necessary.  */
5908
6392
      xfree (expanded.sals);
5909
6393
      expanded.nelts = 1;
5910
6394
      expanded.sals = xmalloc (sizeof (struct symtab_and_line));
5911
6395
      sal.pc = original_pc;
5912
6396
      expanded.sals[0] = sal;
 
6397
      skip_prologue_sal (&expanded.sals[0]);
 
6398
      do_cleanups (old_chain);
5913
6399
      return expanded;      
5914
6400
    }
5915
6401
 
5920
6406
        {
5921
6407
          CORE_ADDR pc = expanded.sals[i].pc;
5922
6408
          char *this_function;
 
6409
 
 
6410
          /* We need to switch threads as well since we're about to
 
6411
             read memory.  */
 
6412
          switch_to_program_space_and_thread (expanded.sals[i].pspace);
 
6413
 
5923
6414
          if (find_pc_partial_function (pc, &this_function, 
5924
6415
                                        &func_addr, &func_end))
5925
6416
            {
5963
6454
        }
5964
6455
    }
5965
6456
 
5966
 
  
 
6457
  do_cleanups (old_chain);
 
6458
 
5967
6459
  if (expanded.nelts <= 1)
5968
6460
    {
5969
6461
      /* This is un ugly workaround. If we get zero
6055
6547
          sal.pc = default_breakpoint_address;
6056
6548
          sal.line = default_breakpoint_line;
6057
6549
          sal.symtab = default_breakpoint_symtab;
 
6550
          sal.pspace = default_breakpoint_pspace;
6058
6551
          sal.section = find_pc_overlay (sal.pc);
6059
6552
 
6060
6553
          /* "break" without arguments is equivalent to "break *PC" where PC is
6120
6613
    resolve_sal_pc (&sals->sals[i]);
6121
6614
}
6122
6615
 
 
6616
/* Fast tracepoints may have restrictions on valid locations.  For
 
6617
   instance, a fast tracepoint using a jump instead of a trap will
 
6618
   likely have to overwrite more bytes than a trap would, and so can
 
6619
   only be placed where the instruction is longer than the jump, or a
 
6620
   multi-instruction sequence does not have a jump into the middle of
 
6621
   it, etc.  */
 
6622
 
 
6623
static void
 
6624
check_fast_tracepoint_sals (struct gdbarch *gdbarch,
 
6625
                            struct symtabs_and_lines *sals)
 
6626
{
 
6627
  int i, rslt;
 
6628
  struct symtab_and_line *sal;
 
6629
  char *msg;
 
6630
  struct cleanup *old_chain;
 
6631
 
 
6632
  for (i = 0; i < sals->nelts; i++)
 
6633
    {
 
6634
      sal = &sals->sals[i];
 
6635
 
 
6636
      rslt = gdbarch_fast_tracepoint_valid_at (gdbarch, sal->pc,
 
6637
                                               NULL, &msg);
 
6638
      old_chain = make_cleanup (xfree, msg);
 
6639
 
 
6640
      if (!rslt)
 
6641
        error (_("May not have a fast tracepoint at 0x%s%s"),
 
6642
               paddress (gdbarch, sal->pc), (msg ? msg : ""));
 
6643
 
 
6644
      do_cleanups (old_chain);
 
6645
    }
 
6646
}
 
6647
 
6123
6648
static void
6124
6649
do_captured_parse_breakpoint (struct ui_out *ui, void *data)
6125
6650
{
6190
6715
          if (tok == tmptok)
6191
6716
            error (_("Junk after task keyword."));
6192
6717
          if (!valid_task_id (*task))
6193
 
            error (_("Unknown task %d\n"), *task);
 
6718
            error (_("Unknown task %d."), *task);
6194
6719
        }
6195
6720
      else
6196
6721
        error (_("Junk at end of arguments."));
6197
6722
    }
6198
6723
}
6199
6724
 
6200
 
/* Set a breakpoint.  This function is shared between
6201
 
   CLI and MI functions for setting a breakpoint.
6202
 
   This function has two major modes of operations,
6203
 
   selected by the PARSE_CONDITION_AND_THREAD parameter.
6204
 
   If non-zero, the function will parse arg, extracting
6205
 
   breakpoint location, address and thread. Otherwise,
6206
 
   ARG is just the location of breakpoint, with condition
6207
 
   and thread specified by the COND_STRING and THREAD
6208
 
   parameters.  */
 
6725
/* Set a breakpoint.  This function is shared between CLI and MI
 
6726
   functions for setting a breakpoint.  This function has two major
 
6727
   modes of operations, selected by the PARSE_CONDITION_AND_THREAD
 
6728
   parameter.  If non-zero, the function will parse arg, extracting
 
6729
   breakpoint location, address and thread. Otherwise, ARG is just the
 
6730
   location of breakpoint, with condition and thread specified by the
 
6731
   COND_STRING and THREAD parameters.  Returns true if any breakpoint
 
6732
   was created; false otherwise.  */
6209
6733
 
6210
 
static void
 
6734
static int
6211
6735
break_command_really (struct gdbarch *gdbarch,
6212
6736
                      char *arg, char *cond_string, int thread,
6213
6737
                      int parse_condition_and_thread,
6268
6792
             selects no, then simply return the error code.  */
6269
6793
          if (pending_break_support == AUTO_BOOLEAN_AUTO
6270
6794
              && !nquery ("Make breakpoint pending on future shared library load? "))
6271
 
            return;
 
6795
            return 0;
6272
6796
 
6273
6797
          /* At this point, either the user was queried about setting
6274
6798
             a pending breakpoint and selected yes, or pending
6286
6810
        }
6287
6811
    default:
6288
6812
      if (!sals.nelts)
6289
 
        return;
 
6813
        return 0;
6290
6814
    }
6291
6815
 
6292
6816
  /* Create a chain of things that always need to be cleaned up. */
6321
6845
    breakpoint_sals_to_pc (&sals, addr_start);
6322
6846
 
6323
6847
  type_wanted = (traceflag
6324
 
                 ? bp_tracepoint
 
6848
                 ? (hardwareflag ? bp_fast_tracepoint : bp_tracepoint)
6325
6849
                 : (hardwareflag ? bp_hardware_breakpoint : bp_breakpoint));
6326
6850
 
 
6851
  /* Fast tracepoints may have additional restrictions on location.  */
 
6852
  if (type_wanted == bp_fast_tracepoint)
 
6853
    check_fast_tracepoint_sals (gdbarch, &sals);
 
6854
 
6327
6855
  /* Verify that condition can be parsed, before setting any
6328
6856
     breakpoints.  Allocate a separate condition expression for each
6329
6857
     breakpoint. */
6373
6901
      b->condition_not_parsed = 1;
6374
6902
      b->ops = ops;
6375
6903
      b->enable_state = enabled ? bp_enabled : bp_disabled;
 
6904
      b->pspace = current_program_space;
6376
6905
 
6377
 
      if (enabled && executing_startup
 
6906
      if (enabled && b->pspace->executing_startup
6378
6907
          && (b->type == bp_breakpoint
6379
6908
              || b->type == bp_hardware_breakpoint))
6380
6909
        b->enable_state = bp_startup_disabled;
6393
6922
 
6394
6923
  /* error call may happen here - have BKPT_CHAIN already discarded.  */
6395
6924
  update_global_location_list (1);
 
6925
 
 
6926
  return 1;
6396
6927
}
6397
6928
 
6398
6929
/* Set a breakpoint. 
6447
6978
static void
6448
6979
skip_prologue_sal (struct symtab_and_line *sal)
6449
6980
{
6450
 
  struct symbol *sym = find_pc_function (sal->pc);
 
6981
  struct symbol *sym;
6451
6982
  struct symtab_and_line start_sal;
6452
 
 
6453
 
  if (sym == NULL)
6454
 
    return;
6455
 
 
6456
 
  start_sal = find_function_start_sal (sym, 1);
6457
 
  if (sal->pc < start_sal.pc)
 
6983
  struct cleanup *old_chain;
 
6984
 
 
6985
  old_chain = save_current_space_and_thread ();
 
6986
 
 
6987
  sym = find_pc_function (sal->pc);
 
6988
  if (sym != NULL)
6458
6989
    {
6459
 
      start_sal.explicit_line = sal->explicit_line;
6460
 
      start_sal.explicit_pc = sal->explicit_pc;
6461
 
      *sal = start_sal;
 
6990
      start_sal = find_function_start_sal (sym, 1);
 
6991
      if (sal->pc < start_sal.pc)
 
6992
        {
 
6993
          start_sal.explicit_line = sal->explicit_line;
 
6994
          start_sal.explicit_pc = sal->explicit_pc;
 
6995
          *sal = start_sal;
 
6996
        }
6462
6997
    }
 
6998
 
 
6999
  do_cleanups (old_chain);
6463
7000
}
6464
7001
 
6465
7002
/* Helper function for break_command_1 and disassemble_command.  */
6510
7047
                 source).  */
6511
7048
 
6512
7049
              struct minimal_symbol *msym;
 
7050
              struct cleanup *old_chain = save_current_space_and_thread ();
 
7051
 
 
7052
              switch_to_program_space_and_thread (sal->pspace);
6513
7053
 
6514
7054
              msym = lookup_minimal_symbol_by_pc (sal->pc);
6515
7055
              if (msym)
6516
7056
                sal->section = SYMBOL_OBJ_SECTION (msym);
 
7057
 
 
7058
              do_cleanups (old_chain);
6517
7059
            }
6518
7060
        }
6519
7061
    }
6624
7166
{
6625
7167
  struct gdbarch *gdbarch = get_current_arch ();
6626
7168
  struct breakpoint *b, *scope_breakpoint = NULL;
6627
 
  struct symtab_and_line sal;
6628
7169
  struct expression *exp;
6629
7170
  struct block *exp_valid_block;
6630
7171
  struct value *val, *mark;
6635
7176
  int toklen;
6636
7177
  char *cond_start = NULL;
6637
7178
  char *cond_end = NULL;
6638
 
  struct expression *cond = NULL;
6639
7179
  int i, other_type_used, target_resources_ok = 0;
6640
7180
  enum bptype bp_type;
6641
7181
  int mem_cnt = 0;
6642
7182
  int thread = -1;
6643
7183
 
6644
 
  init_sal (&sal);              /* initialize to zeroes */
6645
 
 
6646
7184
  /* Make sure that we actually have parameters to parse.  */
6647
7185
  if (arg != NULL && arg[0] != '\0')
6648
7186
    {
6732
7270
  toklen = end_tok - tok;
6733
7271
  if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
6734
7272
    {
 
7273
      struct expression *cond;
 
7274
 
6735
7275
      tok = cond_start = end_tok + 1;
6736
7276
      cond = parse_exp_1 (&tok, 0, 0);
 
7277
      xfree (cond);
6737
7278
      cond_end = tok;
6738
7279
    }
6739
7280
  if (*tok)
6803
7344
    }
6804
7345
 
6805
7346
  /* Now set up the breakpoint.  */
6806
 
  b = set_raw_breakpoint (gdbarch, sal, bp_type);
 
7347
  b = set_raw_breakpoint_without_location (NULL, bp_type);
6807
7348
  set_breakpoint_count (breakpoint_count + 1);
6808
7349
  b->number = breakpoint_count;
6809
7350
  b->thread = thread;
6813
7354
  b->exp_string = savestring (exp_start, exp_end - exp_start);
6814
7355
  b->val = val;
6815
7356
  b->val_valid = 1;
6816
 
  b->loc->cond = cond;
6817
7357
  if (cond_start)
6818
7358
    b->cond_string = savestring (cond_start, cond_end - cond_start);
6819
7359
  else
6820
7360
    b->cond_string = 0;
6821
7361
 
6822
7362
  if (frame)
6823
 
    b->watchpoint_frame = get_frame_id (frame);
 
7363
    {
 
7364
      b->watchpoint_frame = get_frame_id (frame);
 
7365
      b->watchpoint_thread = inferior_ptid;
 
7366
    }
6824
7367
  else
6825
 
    b->watchpoint_frame = null_frame_id;
 
7368
    {
 
7369
      b->watchpoint_frame = null_frame_id;
 
7370
      b->watchpoint_thread = null_ptid;
 
7371
    }
6826
7372
 
6827
7373
  if (scope_breakpoint != NULL)
6828
7374
    {
6833
7379
    }
6834
7380
 
6835
7381
  value_free_to_mark (mark);
 
7382
 
 
7383
  /* Finally update the new watchpoint.  This creates the locations
 
7384
     that should be inserted.  */
 
7385
  update_watchpoint (b, 1);
 
7386
 
6836
7387
  mention (b);
6837
7388
  update_global_location_list (1);
6838
7389
}
7098
7649
  return cond_string;
7099
7650
}
7100
7651
 
7101
 
/* This function attempts to parse an optional filename from the arg
7102
 
   string.  If one is not found, it returns NULL.
7103
 
 
7104
 
   Else, it returns a pointer to the parsed filename.  (This function
7105
 
   makes no attempt to verify that a file of that name exists, or is
7106
 
   accessible.)  And, it updates arg to point to the first character
7107
 
   following the parsed filename in the arg string.
7108
 
 
7109
 
   Note that clients needing to preserve the returned filename for
7110
 
   future access should copy it to their own buffers. */
7111
 
static char *
7112
 
ep_parse_optional_filename (char **arg)
7113
 
{
7114
 
  static char filename[1024];
7115
 
  char *arg_p = *arg;
7116
 
  int i;
7117
 
  char c;
7118
 
 
7119
 
  if ((*arg_p == '\0') || isspace (*arg_p))
7120
 
    return NULL;
7121
 
 
7122
 
  for (i = 0;; i++)
7123
 
    {
7124
 
      c = *arg_p;
7125
 
      if (isspace (c))
7126
 
        c = '\0';
7127
 
      filename[i] = c;
7128
 
      if (c == '\0')
7129
 
        break;
7130
 
      arg_p++;
7131
 
    }
7132
 
  *arg = arg_p;
7133
 
 
7134
 
  return filename;
7135
 
}
7136
 
 
7137
7652
/* Commands to deal with catching events, such as signals, exceptions,
7138
7653
   process start/exit, etc.  */
7139
7654
 
7387
7902
      if (!loc_gdbarch)
7388
7903
        loc_gdbarch = gdbarch;
7389
7904
 
7390
 
      describe_other_breakpoints (loc_gdbarch, sal.pc, sal.section, -1);
 
7905
      describe_other_breakpoints (loc_gdbarch,
 
7906
                                  sal.pspace, sal.pc, sal.section, -1);
7391
7907
      /* FIXME: brobecker/2006-12-28: Actually, re-implement a special
7392
7908
         version for exception catchpoints, because two catchpoints
7393
7909
         used for different exception names will use the same address.
7479
7995
      /* Check if the user provided a syscall name or a number.  */
7480
7996
      syscall_number = (int) strtol (cur_name, &endptr, 0);
7481
7997
      if (*endptr == '\0')
7482
 
        {
7483
 
          get_syscall_by_number (syscall_number, &s);
7484
 
 
7485
 
          if (s.name == NULL)
7486
 
            /* We can issue just a warning, but still create the catchpoint.
7487
 
               This is because, even not knowing the syscall name that
7488
 
               this number represents, we can still try to catch the syscall
7489
 
               number.  */
7490
 
            warning (_("The number '%d' does not represent a known syscall."),
7491
 
                     syscall_number);
7492
 
        }
 
7998
        get_syscall_by_number (syscall_number, &s);
7493
7999
      else
7494
8000
        {
7495
8001
          /* We have a name.  Let's check if it's valid and convert it
7611
8117
      sal.line = default_breakpoint_line;
7612
8118
      sal.symtab = default_breakpoint_symtab;
7613
8119
      sal.pc = default_breakpoint_address;
 
8120
      sal.pspace = default_breakpoint_pspace;
7614
8121
      if (sal.symtab == 0)
7615
8122
        error (_("No source file specified."));
7616
8123
 
7674
8181
              struct bp_location *loc = b->loc;
7675
8182
              for (; loc; loc = loc->next)
7676
8183
                {
7677
 
                  int pc_match = sal.pc 
 
8184
                  int pc_match = sal.pc
 
8185
                    && (loc->pspace == sal.pspace)
7678
8186
                    && (loc->address == sal.pc)
7679
8187
                    && (!section_is_overlay (loc->section)
7680
8188
                        || loc->section == sal.section);
7681
8189
                  int line_match = ((default_match || (0 == sal.pc))
7682
8190
                                    && b->source_file != NULL
7683
8191
                                    && sal.symtab != NULL
 
8192
                                    && sal.pspace == loc->pspace
7684
8193
                                    && strcmp (b->source_file, sal.symtab->filename) == 0
7685
8194
                                    && b->line_number == sal.line);
7686
8195
                  if (pc_match || line_match)
7748
8257
  }
7749
8258
}
7750
8259
 
7751
 
/* A cleanup function which destroys a vector.  */
 
8260
/* A comparison function for bp_location AP and BP being interfaced to qsort.
 
8261
   Sort elements primarily by their ADDRESS (no matter what does
 
8262
   breakpoint_address_is_meaningful say for its OWNER), secondarily by ordering
 
8263
   first bp_permanent OWNERed elements and terciarily just ensuring the array
 
8264
   is sorted stable way despite qsort being an instable algorithm.  */
 
8265
 
 
8266
static int
 
8267
bp_location_compare (const void *ap, const void *bp)
 
8268
{
 
8269
  struct bp_location *a = *(void **) ap;
 
8270
  struct bp_location *b = *(void **) bp;
 
8271
  int a_perm = a->owner->enable_state == bp_permanent;
 
8272
  int b_perm = b->owner->enable_state == bp_permanent;
 
8273
 
 
8274
  if (a->address != b->address)
 
8275
    return (a->address > b->address) - (a->address < b->address);
 
8276
 
 
8277
  /* Sort permanent breakpoints first.  */
 
8278
  if (a_perm != b_perm)
 
8279
    return (a_perm < b_perm) - (a_perm > b_perm);
 
8280
 
 
8281
  /* Make the user-visible order stable across GDB runs.  Locations of the same
 
8282
     breakpoint can be sorted in arbitrary order.  */
 
8283
 
 
8284
  if (a->owner->number != b->owner->number)
 
8285
    return (a->owner->number > b->owner->number)
 
8286
           - (a->owner->number < b->owner->number);
 
8287
 
 
8288
  return (a > b) - (a < b);
 
8289
}
 
8290
 
 
8291
/* Set bp_location_placed_address_before_address_max and
 
8292
   bp_location_shadow_len_after_address_max according to the current content of
 
8293
   the bp_location array.  */
7752
8294
 
7753
8295
static void
7754
 
do_vec_free (void *p)
 
8296
bp_location_target_extensions_update (void)
7755
8297
{
7756
 
  VEC(bp_location_p) **vec = p;
7757
 
  if (*vec)
7758
 
    VEC_free (bp_location_p, *vec);
 
8298
  struct bp_location *bl, **blp_tmp;
 
8299
 
 
8300
  bp_location_placed_address_before_address_max = 0;
 
8301
  bp_location_shadow_len_after_address_max = 0;
 
8302
 
 
8303
  ALL_BP_LOCATIONS (bl, blp_tmp)
 
8304
    {
 
8305
      CORE_ADDR start, end, addr;
 
8306
 
 
8307
      if (!bp_location_has_shadow (bl))
 
8308
        continue;
 
8309
 
 
8310
      start = bl->target_info.placed_address;
 
8311
      end = start + bl->target_info.shadow_len;
 
8312
 
 
8313
      gdb_assert (bl->address >= start);
 
8314
      addr = bl->address - start;
 
8315
      if (addr > bp_location_placed_address_before_address_max)
 
8316
        bp_location_placed_address_before_address_max = addr;
 
8317
 
 
8318
      /* Zero SHADOW_LEN would not pass bp_location_has_shadow.  */
 
8319
 
 
8320
      gdb_assert (bl->address < end);
 
8321
      addr = end - bl->address;
 
8322
      if (addr > bp_location_shadow_len_after_address_max)
 
8323
        bp_location_shadow_len_after_address_max = addr;
 
8324
    }
7759
8325
}
7760
8326
 
7761
8327
/* If SHOULD_INSERT is false, do not insert any breakpoint locations
7777
8343
update_global_location_list (int should_insert)
7778
8344
{
7779
8345
  struct breakpoint *b;
7780
 
  struct bp_location **next = &bp_location_chain;
7781
 
  struct bp_location *loc;
7782
 
  struct bp_location *loc2;
7783
 
  VEC(bp_location_p) *old_locations = NULL;
7784
 
  int ret;
7785
 
  int ix;
 
8346
  struct bp_location **locp, *loc;
7786
8347
  struct cleanup *cleanups;
7787
8348
 
7788
 
  cleanups = make_cleanup (do_vec_free, &old_locations);
7789
 
  /* Store old locations for future reference.  */
7790
 
  for (loc = bp_location_chain; loc; loc = loc->global_next)
7791
 
    VEC_safe_push (bp_location_p, old_locations, loc);
7792
 
 
7793
 
  bp_location_chain = NULL;
7794
 
  ALL_BREAKPOINTS (b)
7795
 
    {
7796
 
      for (loc = b->loc; loc; loc = loc->next)
7797
 
        {
7798
 
          *next = loc;
7799
 
          next = &(loc->global_next);
7800
 
          *next = NULL;
7801
 
        }
7802
 
    }
 
8349
  /* Used in the duplicates detection below.  When iterating over all
 
8350
     bp_locations, points to the first bp_location of a given address.
 
8351
     Breakpoints and watchpoints of different types are never
 
8352
     duplicates of each other.  Keep one pointer for each type of
 
8353
     breakpoint/watchpoint, so we only need to loop over all locations
 
8354
     once.  */
 
8355
  struct bp_location *bp_loc_first;  /* breakpoint */
 
8356
  struct bp_location *wp_loc_first;  /* hardware watchpoint */
 
8357
  struct bp_location *awp_loc_first; /* access watchpoint */
 
8358
  struct bp_location *rwp_loc_first; /* read watchpoint */
 
8359
 
 
8360
  /* Saved former bp_location array which we compare against the newly built
 
8361
     bp_location from the current state of ALL_BREAKPOINTS.  */
 
8362
  struct bp_location **old_location, **old_locp;
 
8363
  unsigned old_location_count;
 
8364
 
 
8365
  old_location = bp_location;
 
8366
  old_location_count = bp_location_count;
 
8367
  bp_location = NULL;
 
8368
  bp_location_count = 0;
 
8369
  cleanups = make_cleanup (xfree, old_location);
 
8370
 
 
8371
  ALL_BREAKPOINTS (b)
 
8372
    for (loc = b->loc; loc; loc = loc->next)
 
8373
      bp_location_count++;
 
8374
 
 
8375
  bp_location = xmalloc (sizeof (*bp_location) * bp_location_count);
 
8376
  locp = bp_location;
 
8377
  ALL_BREAKPOINTS (b)
 
8378
    for (loc = b->loc; loc; loc = loc->next)
 
8379
      *locp++ = loc;
 
8380
  qsort (bp_location, bp_location_count, sizeof (*bp_location),
 
8381
         bp_location_compare);
 
8382
 
 
8383
  bp_location_target_extensions_update ();
7803
8384
 
7804
8385
  /* Identify bp_location instances that are no longer present in the new
7805
8386
     list, and therefore should be freed.  Note that it's not necessary that
7806
8387
     those locations should be removed from inferior -- if there's another
7807
8388
     location at the same address (previously marked as duplicate),
7808
 
     we don't need to remove/insert the location.  */
7809
 
  for (ix = 0; VEC_iterate(bp_location_p, old_locations, ix, loc); ++ix)
 
8389
     we don't need to remove/insert the location.
 
8390
     
 
8391
     LOCP is kept in sync with OLD_LOCP, each pointing to the current and
 
8392
     former bp_location array state respectively.  */
 
8393
 
 
8394
  locp = bp_location;
 
8395
  for (old_locp = old_location; old_locp < old_location + old_location_count;
 
8396
       old_locp++)
7810
8397
    {
7811
 
      /* Tells if 'loc' is found amoung the new locations.  If not, we
 
8398
      struct bp_location *old_loc = *old_locp;
 
8399
      struct bp_location **loc2p;
 
8400
 
 
8401
      /* Tells if 'old_loc' is found amoung the new locations.  If not, we
7812
8402
         have to free it.  */
7813
8403
      int found_object = 0;
7814
8404
      /* Tells if the location should remain inserted in the target.  */
7815
8405
      int keep_in_target = 0;
7816
8406
      int removed = 0;
7817
 
      for (loc2 = bp_location_chain; loc2; loc2 = loc2->global_next)
7818
 
        if (loc2 == loc)
7819
 
          {
7820
 
            found_object = 1;
7821
 
            break;
7822
 
          }
 
8407
 
 
8408
      /* Skip LOCP entries which will definitely never be needed.  Stop either
 
8409
         at or being the one matching OLD_LOC.  */
 
8410
      while (locp < bp_location + bp_location_count
 
8411
             && (*locp)->address < old_loc->address)
 
8412
        locp++;
 
8413
 
 
8414
      for (loc2p = locp;
 
8415
           (loc2p < bp_location + bp_location_count
 
8416
            && (*loc2p)->address == old_loc->address);
 
8417
           loc2p++)
 
8418
        {
 
8419
          if (*loc2p == old_loc)
 
8420
            {
 
8421
              found_object = 1;
 
8422
              break;
 
8423
            }
 
8424
        }
7823
8425
 
7824
8426
      /* If this location is no longer present, and inserted, look if there's
7825
8427
         maybe a new location at the same address.  If so, mark that one 
7827
8429
         don't have a time window where a breakpoint at certain location is not
7828
8430
         inserted.  */
7829
8431
 
7830
 
      if (loc->inserted)
 
8432
      if (old_loc->inserted)
7831
8433
        {
7832
8434
          /* If the location is inserted now, we might have to remove it.  */
7833
8435
 
7834
 
          if (found_object && should_be_inserted (loc))
 
8436
          if (found_object && should_be_inserted (old_loc))
7835
8437
            {
7836
8438
              /* The location is still present in the location list, and still
7837
8439
                 should be inserted.  Don't do anything.  */
7842
8444
              /* The location is either no longer present, or got disabled.
7843
8445
                 See if there's another location at the same address, in which 
7844
8446
                 case we don't need to remove this one from the target.  */
7845
 
              if (breakpoint_address_is_meaningful (loc->owner))
7846
 
                for (loc2 = bp_location_chain; loc2; loc2 = loc2->global_next)
7847
 
                  {
7848
 
                    /* For the sake of should_insert_location.  The
7849
 
                       call to check_duplicates will fix up this later.  */
7850
 
                    loc2->duplicate = 0;
7851
 
                    if (should_be_inserted (loc2)
7852
 
                        && loc2 != loc && loc2->address == loc->address)
7853
 
                      {           
7854
 
                        loc2->inserted = 1;
7855
 
                        loc2->target_info = loc->target_info;
7856
 
                        keep_in_target = 1;
7857
 
                        break;
7858
 
                      }
7859
 
                  }
 
8447
 
 
8448
              if (breakpoint_address_is_meaningful (old_loc->owner))
 
8449
                {
 
8450
                  for (loc2p = locp;
 
8451
                       (loc2p < bp_location + bp_location_count
 
8452
                        && (*loc2p)->address == old_loc->address);
 
8453
                       loc2p++)
 
8454
                    {
 
8455
                      struct bp_location *loc2 = *loc2p;
 
8456
 
 
8457
                      if (breakpoint_locations_match (loc2, old_loc))
 
8458
                        {
 
8459
                          /* For the sake of should_be_inserted.
 
8460
                             Duplicates check below will fix up this later.  */
 
8461
                          loc2->duplicate = 0;
 
8462
                          if (loc2 != old_loc && should_be_inserted (loc2))
 
8463
                            {
 
8464
                              loc2->inserted = 1;
 
8465
                              loc2->target_info = old_loc->target_info;
 
8466
                              keep_in_target = 1;
 
8467
                              break;
 
8468
                            }
 
8469
                        }
 
8470
                    }
 
8471
                }
7860
8472
            }
7861
8473
 
7862
8474
          if (!keep_in_target)
7863
8475
            {
7864
 
              if (remove_breakpoint (loc, mark_uninserted))
 
8476
              if (remove_breakpoint (old_loc, mark_uninserted))
7865
8477
                {
7866
8478
                  /* This is just about all we can do.  We could keep this
7867
8479
                     location on the global list, and try to remove it next
7868
8480
                     time, but there's no particular reason why we will
7869
8481
                     succeed next time.  
7870
8482
                     
7871
 
                     Note that at this point, loc->owner is still valid,
 
8483
                     Note that at this point, old_loc->owner is still valid,
7872
8484
                     as delete_breakpoint frees the breakpoint only
7873
8485
                     after calling us.  */
7874
8486
                  printf_filtered (_("warning: Error removing breakpoint %d\n"), 
7875
 
                                   loc->owner->number);
 
8487
                                   old_loc->owner->number);
7876
8488
                }
7877
8489
              removed = 1;
7878
8490
            }
7880
8492
 
7881
8493
      if (!found_object)
7882
8494
        {
7883
 
          if (removed && non_stop)
 
8495
          if (removed && non_stop
 
8496
              && breakpoint_address_is_meaningful (old_loc->owner)
 
8497
              && !is_hardware_watchpoint (old_loc->owner))
7884
8498
            {
7885
 
              /* This location was removed from the targets.  In non-stop mode,
7886
 
                 a race condition is possible where we've removed a breakpoint,
7887
 
                 but stop events for that breakpoint are already queued and will
7888
 
                 arrive later.  To suppress spurious SIGTRAPs reported to user,
7889
 
                 we keep this breakpoint location for a bit, and will retire it
7890
 
                 after we see 3 * thread_count events.
7891
 
                 The theory here is that reporting of events should,
7892
 
                 "on the average", be fair, so after that many event we'll see
7893
 
                 events from all threads that have anything of interest, and no
7894
 
                 longer need to keep this breakpoint.  This is just a
7895
 
                 heuristic, but if it's wrong, we'll report unexpected SIGTRAP,
7896
 
                 which is usability issue, but not a correctness problem.  */
7897
 
              loc->events_till_retirement = 3 * (thread_count () + 1);
7898
 
              loc->owner = NULL;
7899
 
 
7900
 
              VEC_safe_push (bp_location_p, moribund_locations, loc);
 
8499
              /* This location was removed from the target.  In
 
8500
                 non-stop mode, a race condition is possible where
 
8501
                 we've removed a breakpoint, but stop events for that
 
8502
                 breakpoint are already queued and will arrive later.
 
8503
                 We apply an heuristic to be able to distinguish such
 
8504
                 SIGTRAPs from other random SIGTRAPs: we keep this
 
8505
                 breakpoint location for a bit, and will retire it
 
8506
                 after we see some number of events.  The theory here
 
8507
                 is that reporting of events should, "on the average",
 
8508
                 be fair, so after a while we'll see events from all
 
8509
                 threads that have anything of interest, and no longer
 
8510
                 need to keep this breakpoint location around.  We
 
8511
                 don't hold locations forever so to reduce chances of
 
8512
                 mistaking a non-breakpoint SIGTRAP for a breakpoint
 
8513
                 SIGTRAP.
 
8514
 
 
8515
                 The heuristic failing can be disastrous on
 
8516
                 decr_pc_after_break targets.
 
8517
 
 
8518
                 On decr_pc_after_break targets, like e.g., x86-linux,
 
8519
                 if we fail to recognize a late breakpoint SIGTRAP,
 
8520
                 because events_till_retirement has reached 0 too
 
8521
                 soon, we'll fail to do the PC adjustment, and report
 
8522
                 a random SIGTRAP to the user.  When the user resumes
 
8523
                 the inferior, it will most likely immediately crash
 
8524
                 with SIGILL/SIGBUS/SEGSEGV, or worse, get silently
 
8525
                 corrupted, because of being resumed e.g., in the
 
8526
                 middle of a multi-byte instruction, or skipped a
 
8527
                 one-byte instruction.  This was actually seen happen
 
8528
                 on native x86-linux, and should be less rare on
 
8529
                 targets that do not support new thread events, like
 
8530
                 remote, due to the heuristic depending on
 
8531
                 thread_count.
 
8532
 
 
8533
                 Mistaking a random SIGTRAP for a breakpoint trap
 
8534
                 causes similar symptoms (PC adjustment applied when
 
8535
                 it shouldn't), but then again, playing with SIGTRAPs
 
8536
                 behind the debugger's back is asking for trouble.
 
8537
 
 
8538
                 Since hardware watchpoint traps are always
 
8539
                 distinguishable from other traps, so we don't need to
 
8540
                 apply keep hardware watchpoint moribund locations
 
8541
                 around.  We simply always ignore hardware watchpoint
 
8542
                 traps we can no longer explain.  */
 
8543
 
 
8544
              old_loc->events_till_retirement = 3 * (thread_count () + 1);
 
8545
              old_loc->owner = NULL;
 
8546
 
 
8547
              VEC_safe_push (bp_location_p, moribund_locations, old_loc);
7901
8548
            }
7902
8549
          else
7903
 
            free_bp_location (loc);
 
8550
            free_bp_location (old_loc);
7904
8551
        }
7905
8552
    }
7906
8553
 
7907
 
  ALL_BREAKPOINTS (b)
 
8554
  /* Rescan breakpoints at the same address and section, marking the
 
8555
     first one as "first" and any others as "duplicates".  This is so
 
8556
     that the bpt instruction is only inserted once.  If we have a
 
8557
     permanent breakpoint at the same place as BPT, make that one the
 
8558
     official one, and the rest as duplicates.  Permanent breakpoints
 
8559
     are sorted first for the same address.
 
8560
 
 
8561
     Do the same for hardware watchpoints, but also considering the
 
8562
     watchpoint's type (regular/access/read) and length.  */
 
8563
 
 
8564
  bp_loc_first = NULL;
 
8565
  wp_loc_first = NULL;
 
8566
  awp_loc_first = NULL;
 
8567
  rwp_loc_first = NULL;
 
8568
  ALL_BP_LOCATIONS (loc, locp)
7908
8569
    {
7909
 
      check_duplicates (b);
 
8570
      struct breakpoint *b = loc->owner;
 
8571
      struct bp_location **loc_first_p;
 
8572
 
 
8573
      if (b->enable_state == bp_disabled
 
8574
          || b->enable_state == bp_call_disabled
 
8575
          || b->enable_state == bp_startup_disabled
 
8576
          || !loc->enabled
 
8577
          || loc->shlib_disabled
 
8578
          || !breakpoint_address_is_meaningful (b)
 
8579
          || tracepoint_type (b))
 
8580
        continue;
 
8581
 
 
8582
      /* Permanent breakpoint should always be inserted.  */
 
8583
      if (b->enable_state == bp_permanent && ! loc->inserted)
 
8584
        internal_error (__FILE__, __LINE__,
 
8585
                        _("allegedly permanent breakpoint is not "
 
8586
                        "actually inserted"));
 
8587
 
 
8588
      if (b->type == bp_hardware_watchpoint)
 
8589
        loc_first_p = &wp_loc_first;
 
8590
      else if (b->type == bp_read_watchpoint)
 
8591
        loc_first_p = &rwp_loc_first;
 
8592
      else if (b->type == bp_access_watchpoint)
 
8593
        loc_first_p = &awp_loc_first;
 
8594
      else
 
8595
        loc_first_p = &bp_loc_first;
 
8596
 
 
8597
      if (*loc_first_p == NULL
 
8598
          || (overlay_debugging && loc->section != (*loc_first_p)->section)
 
8599
          || !breakpoint_locations_match (loc, *loc_first_p))
 
8600
        {
 
8601
          *loc_first_p = loc;
 
8602
          loc->duplicate = 0;
 
8603
          continue;
 
8604
        }
 
8605
 
 
8606
      loc->duplicate = 1;
 
8607
 
 
8608
      if ((*loc_first_p)->owner->enable_state == bp_permanent && loc->inserted
 
8609
          && b->enable_state != bp_permanent)
 
8610
        internal_error (__FILE__, __LINE__,
 
8611
                        _("another breakpoint was inserted on top of "
 
8612
                        "a permanent breakpoint"));
7910
8613
    }
7911
8614
 
7912
8615
  if (breakpoints_always_inserted_mode () && should_insert
7990
8693
  if (bpt->type == bp_none)
7991
8694
    return;
7992
8695
 
 
8696
  /* At least avoid this stale reference until the reference counting of
 
8697
     breakpoints gets resolved.  */
 
8698
  if (bpt->related_breakpoint != NULL)
 
8699
    {
 
8700
      gdb_assert (bpt->related_breakpoint->related_breakpoint == bpt);
 
8701
      bpt->related_breakpoint->disposition = disp_del_at_next_stop;
 
8702
      bpt->related_breakpoint->related_breakpoint = NULL;
 
8703
      bpt->related_breakpoint = NULL;
 
8704
    }
 
8705
 
7993
8706
  observer_notify_breakpoint_deleted (bpt->number);
7994
8707
 
7995
8708
  if (breakpoint_chain == bpt)
8235
8948
            if (have_ambiguous_names)
8236
8949
              {
8237
8950
                for (; l; l = l->next)
8238
 
                  if (e->address == l->address)
 
8951
                  if (breakpoint_address_match (e->pspace->aspace, e->address,
 
8952
                                                l->pspace->aspace, l->address))
8239
8953
                    {
8240
8954
                      l->enabled = 0;
8241
8955
                      break;
8272
8986
  int i;
8273
8987
  int not_found = 0;
8274
8988
  int *not_found_ptr = &not_found;
8275
 
  struct symtabs_and_lines sals = {};
8276
 
  struct symtabs_and_lines expanded;
 
8989
  struct symtabs_and_lines sals = {0};
 
8990
  struct symtabs_and_lines expanded = {0};
8277
8991
  char *s;
8278
8992
  enum enable_state save_enable;
8279
8993
  struct gdb_exception e;
8280
 
  struct cleanup *cleanups;
 
8994
  struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
8281
8995
 
8282
8996
  switch (b->type)
8283
8997
    {
8288
9002
    case bp_breakpoint:
8289
9003
    case bp_hardware_breakpoint:
8290
9004
    case bp_tracepoint:
 
9005
    case bp_fast_tracepoint:
8291
9006
      /* Do not attempt to re-set breakpoints disabled during startup.  */
8292
9007
      if (b->enable_state == bp_startup_disabled)
8293
9008
        return 0;
8302
9017
      set_language (b->language);
8303
9018
      input_radix = b->input_radix;
8304
9019
      s = b->addr_string;
 
9020
 
 
9021
      save_current_space_and_thread ();
 
9022
      switch_to_program_space_and_thread (b->pspace);
 
9023
 
8305
9024
      TRY_CATCH (e, RETURN_MASK_ERROR)
8306
9025
        {
8307
9026
          sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL,
8335
9054
            }
8336
9055
        }
8337
9056
 
8338
 
      if (not_found)
8339
 
        break;
8340
 
      
8341
 
      gdb_assert (sals.nelts == 1);
8342
 
      resolve_sal_pc (&sals.sals[0]);
8343
 
      if (b->condition_not_parsed && s && s[0])
 
9057
      if (!not_found)
8344
9058
        {
8345
 
          char *cond_string = 0;
8346
 
          int thread = -1;
8347
 
          int task = 0;
8348
 
 
8349
 
          find_condition_and_thread (s, sals.sals[0].pc, 
8350
 
                                     &cond_string, &thread, &task);
8351
 
          if (cond_string)
8352
 
            b->cond_string = cond_string;
8353
 
          b->thread = thread;
8354
 
          b->task = task;
8355
 
          b->condition_not_parsed = 0;
 
9059
          gdb_assert (sals.nelts == 1);
 
9060
 
 
9061
          resolve_sal_pc (&sals.sals[0]);
 
9062
          if (b->condition_not_parsed && s && s[0])
 
9063
            {
 
9064
              char *cond_string = 0;
 
9065
              int thread = -1;
 
9066
              int task = 0;
 
9067
 
 
9068
              find_condition_and_thread (s, sals.sals[0].pc,
 
9069
                                         &cond_string, &thread, &task);
 
9070
              if (cond_string)
 
9071
                b->cond_string = cond_string;
 
9072
              b->thread = thread;
 
9073
              b->task = task;
 
9074
              b->condition_not_parsed = 0;
 
9075
            }
 
9076
 
 
9077
          expanded = expand_line_sal_maybe (sals.sals[0]);
8356
9078
        }
8357
 
      expanded = expand_line_sal_maybe (sals.sals[0]);
8358
 
      cleanups = make_cleanup (xfree, sals.sals);
 
9079
 
 
9080
      make_cleanup (xfree, sals.sals);
8359
9081
      update_breakpoint_locations (b, expanded);
8360
 
      do_cleanups (cleanups);
8361
9082
      break;
8362
9083
 
8363
9084
    case bp_watchpoint:
8430
9151
      break;
8431
9152
    }
8432
9153
 
 
9154
  do_cleanups (cleanups);
8433
9155
  return 0;
8434
9156
}
8435
9157
 
8440
9162
  struct breakpoint *b, *temp;
8441
9163
  enum language save_language;
8442
9164
  int save_input_radix;
 
9165
  struct cleanup *old_chain;
8443
9166
 
8444
9167
  save_language = current_language->la_language;
8445
9168
  save_input_radix = input_radix;
 
9169
  old_chain = save_current_program_space ();
 
9170
 
8446
9171
  ALL_BREAKPOINTS_SAFE (b, temp)
8447
9172
  {
8448
9173
    /* Format possible error msg */
8457
9182
 
8458
9183
  jit_breakpoint_re_set ();
8459
9184
 
 
9185
  do_cleanups (old_chain);
 
9186
 
8460
9187
  create_overlay_event_breakpoint ("_ovly_debug_event");
8461
9188
  create_longjmp_master_breakpoint ("longjmp");
8462
9189
  create_longjmp_master_breakpoint ("_longjmp");
8475
9202
    {
8476
9203
      if (in_thread_list (inferior_ptid))
8477
9204
        b->thread = pid_to_thread_id (inferior_ptid);
 
9205
 
 
9206
      /* We're being called after following a fork.  The new fork is
 
9207
         selected as current, and unless this was a vfork will have a
 
9208
         different program space from the original thread.  Reset that
 
9209
         as well.  */
 
9210
      b->loc->pspace = current_program_space;
8478
9211
    }
8479
9212
}
8480
9213
 
8669
9402
        continue;
8670
9403
      case bp_breakpoint:
8671
9404
      case bp_tracepoint:
 
9405
      case bp_fast_tracepoint:
8672
9406
      case bp_catchpoint:
8673
9407
      case bp_hardware_breakpoint:
8674
9408
      case bp_watchpoint:
8762
9496
        continue;
8763
9497
      case bp_breakpoint:
8764
9498
      case bp_tracepoint:
 
9499
      case bp_fast_tracepoint:
8765
9500
      case bp_catchpoint:
8766
9501
      case bp_hardware_breakpoint:
8767
9502
      case bp_watchpoint:
8817
9552
{
8818
9553
}
8819
9554
 
 
9555
/* Invalidate last known value of any hardware watchpoint if
 
9556
   the memory which that value represents has been written to by
 
9557
   GDB itself.  */
 
9558
 
 
9559
static void
 
9560
invalidate_bp_value_on_memory_change (CORE_ADDR addr, int len,
 
9561
                                      const bfd_byte *data)
 
9562
{
 
9563
  struct breakpoint *bp;
 
9564
 
 
9565
  ALL_BREAKPOINTS (bp)
 
9566
    if (bp->enable_state == bp_enabled
 
9567
        && bp->type == bp_hardware_watchpoint
 
9568
        && bp->val_valid && bp->val)
 
9569
      {
 
9570
        struct bp_location *loc;
 
9571
 
 
9572
        for (loc = bp->loc; loc != NULL; loc = loc->next)
 
9573
          if (loc->loc_type == bp_loc_hardware_watchpoint
 
9574
              && loc->address + loc->length > addr
 
9575
              && addr + len > loc->address)
 
9576
            {
 
9577
              value_free (bp->val);
 
9578
              bp->val = NULL;
 
9579
              bp->val_valid = 0;
 
9580
            }
 
9581
      }
 
9582
}
 
9583
 
8820
9584
/* Use default_breakpoint_'s, or nothing if they aren't valid.  */
8821
9585
 
8822
9586
struct symtabs_and_lines
8845
9609
   someday.  */
8846
9610
 
8847
9611
void *
8848
 
deprecated_insert_raw_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc)
 
9612
deprecated_insert_raw_breakpoint (struct gdbarch *gdbarch,
 
9613
                                  struct address_space *aspace, CORE_ADDR pc)
8849
9614
{
8850
9615
  struct bp_target_info *bp_tgt;
8851
9616
 
8852
 
  bp_tgt = xmalloc (sizeof (struct bp_target_info));
8853
 
  memset (bp_tgt, 0, sizeof (struct bp_target_info));
 
9617
  bp_tgt = XZALLOC (struct bp_target_info);
8854
9618
 
 
9619
  bp_tgt->placed_address_space = aspace;
8855
9620
  bp_tgt->placed_address = pc;
 
9621
 
8856
9622
  if (target_insert_breakpoint (gdbarch, bp_tgt) != 0)
8857
9623
    {
8858
9624
      /* Could not insert the breakpoint.  */
8885
9651
/* Create and insert a breakpoint for software single step.  */
8886
9652
 
8887
9653
void
8888
 
insert_single_step_breakpoint (struct gdbarch *gdbarch, CORE_ADDR next_pc)
 
9654
insert_single_step_breakpoint (struct gdbarch *gdbarch,
 
9655
                               struct address_space *aspace, CORE_ADDR next_pc)
8889
9656
{
8890
9657
  void **bpt_p;
8891
9658
 
8908
9675
     corresponding changes elsewhere where single step breakpoints are
8909
9676
     handled, however.  So, for now, we use this.  */
8910
9677
 
8911
 
  *bpt_p = deprecated_insert_raw_breakpoint (gdbarch, next_pc);
 
9678
  *bpt_p = deprecated_insert_raw_breakpoint (gdbarch, aspace, next_pc);
8912
9679
  if (*bpt_p == NULL)
8913
9680
    error (_("Could not insert single-step breakpoint at %s"),
8914
9681
             paddress (gdbarch, next_pc));
8940
9707
/* Check whether a software single-step breakpoint is inserted at PC.  */
8941
9708
 
8942
9709
static int
8943
 
single_step_breakpoint_inserted_here_p (CORE_ADDR pc)
 
9710
single_step_breakpoint_inserted_here_p (struct address_space *aspace, CORE_ADDR pc)
8944
9711
{
8945
9712
  int i;
8946
9713
 
8947
9714
  for (i = 0; i < 2; i++)
8948
9715
    {
8949
9716
      struct bp_target_info *bp_tgt = single_step_breakpoints[i];
8950
 
      if (bp_tgt && bp_tgt->placed_address == pc)
 
9717
      if (bp_tgt
 
9718
          && breakpoint_address_match (bp_tgt->placed_address_space,
 
9719
                                       bp_tgt->placed_address,
 
9720
                                       aspace, pc))
8951
9721
        return 1;
8952
9722
    }
8953
9723
 
9021
9791
void
9022
9792
trace_command (char *arg, int from_tty)
9023
9793
{
9024
 
  break_command_really (get_current_arch (),
9025
 
                        arg,
9026
 
                        NULL, 0, 1 /* parse arg */,
9027
 
                        0 /* tempflag */, 0 /* hardwareflag */,
9028
 
                        1 /* traceflag */,
9029
 
                        0 /* Ignore count */,
9030
 
                        pending_break_support, 
9031
 
                        NULL,
9032
 
                        from_tty,
9033
 
                        1 /* enabled */);
 
9794
  if (break_command_really (get_current_arch (),
 
9795
                            arg,
 
9796
                            NULL, 0, 1 /* parse arg */,
 
9797
                            0 /* tempflag */, 0 /* hardwareflag */,
 
9798
                            1 /* traceflag */,
 
9799
                            0 /* Ignore count */,
 
9800
                            pending_break_support,
 
9801
                            NULL,
 
9802
                            from_tty,
 
9803
                            1 /* enabled */))
 
9804
    set_tracepoint_count (breakpoint_count);
 
9805
}
 
9806
 
 
9807
void
 
9808
ftrace_command (char *arg, int from_tty)
 
9809
{
 
9810
  if (break_command_really (get_current_arch (),
 
9811
                            arg,
 
9812
                            NULL, 0, 1 /* parse arg */,
 
9813
                            0 /* tempflag */, 1 /* hardwareflag */,
 
9814
                            1 /* traceflag */,
 
9815
                            0 /* Ignore count */,
 
9816
                            pending_break_support,
 
9817
                            NULL,
 
9818
                            from_tty,
 
9819
                            1 /* enabled */))
 
9820
    set_tracepoint_count (breakpoint_count);
 
9821
}
 
9822
 
 
9823
/* Given information about a tracepoint as recorded on a target (which
 
9824
   can be either a live system or a trace file), attempt to create an
 
9825
   equivalent GDB tracepoint.  This is not a reliable process, since
 
9826
   the target does not necessarily have all the information used when
 
9827
   the tracepoint was originally defined.  */
 
9828
  
 
9829
struct breakpoint *
 
9830
create_tracepoint_from_upload (struct uploaded_tp *utp)
 
9831
{
 
9832
  char buf[100];
 
9833
  struct breakpoint *tp;
 
9834
 
 
9835
  /* In the absence of a source location, fall back to raw address.  */
 
9836
  sprintf (buf, "*%s", paddress (get_current_arch(), utp->addr));
 
9837
 
 
9838
  if (!break_command_really (get_current_arch (),
 
9839
                             buf,
 
9840
                             NULL, 0, 1 /* parse arg */,
 
9841
                             0 /* tempflag */,
 
9842
                             (utp->type == bp_fast_tracepoint) /* hardwareflag */,
 
9843
                             1 /* traceflag */,
 
9844
                             0 /* Ignore count */,
 
9845
                             pending_break_support,
 
9846
                             NULL,
 
9847
                             0 /* from_tty */,
 
9848
                             utp->enabled /* enabled */))
 
9849
    return NULL;
 
9850
 
9034
9851
  set_tracepoint_count (breakpoint_count);
9035
 
}
9036
 
 
 
9852
  
 
9853
  tp = get_tracepoint (tracepoint_count);
 
9854
  gdb_assert (tp != NULL);
 
9855
 
 
9856
  if (utp->pass > 0)
 
9857
    {
 
9858
      sprintf (buf, "%d %d", utp->pass, tp->number);
 
9859
 
 
9860
      trace_pass_command (buf, 0);
 
9861
    }
 
9862
 
 
9863
  if (utp->cond)
 
9864
    {
 
9865
      printf_filtered ("Want to restore a condition\n");
 
9866
    }
 
9867
 
 
9868
  if (utp->numactions > 0)
 
9869
    {
 
9870
      printf_filtered ("Want to restore action list\n");
 
9871
    }
 
9872
 
 
9873
  if (utp->num_step_actions > 0)
 
9874
    {
 
9875
      printf_filtered ("Want to restore action list\n");
 
9876
    }
 
9877
 
 
9878
  return tp;
 
9879
  }
 
9880
  
9037
9881
/* Print information on tracepoint number TPNUM_EXP, or all if
9038
9882
   omitted.  */
9039
9883
 
9111
9955
        {
9112
9956
          ALL_BREAKPOINTS_SAFE (b, temp)
9113
9957
          {
9114
 
            if (b->type == bp_tracepoint
 
9958
            if (tracepoint_type (b)
9115
9959
                && b->number >= 0)
9116
9960
              delete_breakpoint (b);
9117
9961
          }
9184
10028
  return NULL;
9185
10029
}
9186
10030
 
 
10031
/* Find the tracepoint with the given target-side number (which may be
 
10032
   different from the tracepoint number after disconnecting and
 
10033
   reconnecting).  */
 
10034
 
 
10035
struct breakpoint *
 
10036
get_tracepoint_by_number_on_target (int num)
 
10037
{
 
10038
  struct breakpoint *t;
 
10039
 
 
10040
  ALL_TRACEPOINTS (t)
 
10041
    if (t->number_on_target == num)
 
10042
      return t;
 
10043
 
 
10044
  return NULL;
 
10045
}
 
10046
 
9187
10047
/* Utility: parse a tracepoint number and look it up in the list.
9188
10048
   If MULTI_P is true, there might be a range of tracepoints in ARG.
9189
10049
   if OPTIONAL_P is true, then if the argument is missing, the most
9379
10239
  set_cmd_completer (command, completer);
9380
10240
}
9381
10241
 
 
10242
static void
 
10243
clear_syscall_counts (int pid)
 
10244
{
 
10245
  struct inferior *inf = find_inferior_pid (pid);
 
10246
 
 
10247
  inf->total_syscalls_count = 0;
 
10248
  inf->any_syscall_count = 0;
 
10249
  VEC_free (int, inf->syscalls_counts);
 
10250
}
 
10251
 
9382
10252
void
9383
10253
_initialize_breakpoint (void)
9384
10254
{
9387
10257
  struct cmd_list_element *c;
9388
10258
 
9389
10259
  observer_attach_solib_unloaded (disable_breakpoints_in_unloaded_shlib);
 
10260
  observer_attach_inferior_exit (clear_syscall_counts);
 
10261
  observer_attach_memory_changed (invalidate_bp_value_on_memory_change);
9390
10262
 
9391
10263
  breakpoint_chain = 0;
9392
10264
  /* Don't bother to call set_breakpoint_count.  $bpnum isn't useful
9597
10469
Convenience variable \"$bpnum\" contains the number of the last\n\
9598
10470
breakpoint set."));
9599
10471
 
 
10472
  add_info_alias ("b", "breakpoints", 1);
 
10473
 
9600
10474
  if (xdb_commands)
9601
10475
    add_com ("lb", class_breakpoint, breakpoints_info, _("\
9602
10476
Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
9752
10626
  add_com_alias ("tra", "trace", class_alias, 1);
9753
10627
  add_com_alias ("trac", "trace", class_alias, 1);
9754
10628
 
 
10629
  c = add_com ("ftrace", class_breakpoint, ftrace_command, _("\
 
10630
Set a fast tracepoint at specified line or function.\n\
 
10631
\n"
 
10632
BREAK_ARGS_HELP ("ftrace") "\n\
 
10633
Do \"help tracepoints\" for info on other tracepoint commands."));
 
10634
  set_cmd_completer (c, location_completer);
 
10635
 
9755
10636
  add_info ("tracepoints", tracepoints_info, _("\
9756
10637
Status of tracepoints, or tracepoint number NUMBER.\n\
9757
10638
Convenience variable \"$tpnum\" contains the number of the\n\