GDB (xrefs)
/tmp/gdb-8.1/gdb/record-full.c
Go to the documentation of this file.
1 /* Process record and replay target for GDB, the GNU debugger.
2 
3  Copyright (C) 2013-2018 Free Software Foundation, Inc.
4 
5  This file is part of GDB.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #include "defs.h"
21 #include "gdbcmd.h"
22 #include "regcache.h"
23 #include "gdbthread.h"
24 #include "event-top.h"
25 #include "completer.h"
26 #include "arch-utils.h"
27 #include "gdbcore.h"
28 #include "exec.h"
29 #include "record.h"
30 #include "record-full.h"
31 #include "elf-bfd.h"
32 #include "gcore.h"
33 #include "event-loop.h"
34 #include "inf-loop.h"
35 #include "gdb_bfd.h"
36 #include "observer.h"
37 #include "infrun.h"
38 #include "common/gdb_unlinker.h"
39 #include "common/byte-vector.h"
40 
41 #include <signal.h>
42 
43 /* This module implements "target record-full", also known as "process
44  record and replay". This target sits on top of a "normal" target
45  (a target that "has execution"), and provides a record and replay
46  functionality, including reverse debugging.
47 
48  Target record has two modes: recording, and replaying.
49 
50  In record mode, we intercept the to_resume and to_wait methods.
51  Whenever gdb resumes the target, we run the target in single step
52  mode, and we build up an execution log in which, for each executed
53  instruction, we record all changes in memory and register state.
54  This is invisible to the user, to whom it just looks like an
55  ordinary debugging session (except for performance degredation).
56 
57  In replay mode, instead of actually letting the inferior run as a
58  process, we simulate its execution by playing back the recorded
59  execution log. For each instruction in the log, we simulate the
60  instruction's side effects by duplicating the changes that it would
61  have made on memory and registers. */
62 
63 #define DEFAULT_RECORD_FULL_INSN_MAX_NUM 200000
64 
65 #define RECORD_FULL_IS_REPLAY \
66  (record_full_list->next || execution_direction == EXEC_REVERSE)
67 
68 #define RECORD_FULL_FILE_MAGIC netorder32(0x20091016)
69 
70 /* These are the core structs of the process record functionality.
71 
72  A record_full_entry is a record of the value change of a register
73  ("record_full_reg") or a part of memory ("record_full_mem"). And each
74  instruction must have a struct record_full_entry ("record_full_end")
75  that indicates that this is the last struct record_full_entry of this
76  instruction.
77 
78  Each struct record_full_entry is linked to "record_full_list" by "prev"
79  and "next" pointers. */
80 
82 {
84  int len;
85  /* Set this flag if target memory for this entry
86  can no longer be accessed. */
88  union
89  {
91  gdb_byte buf[sizeof (gdb_byte *)];
92  } u;
93 };
94 
96 {
97  unsigned short num;
98  unsigned short len;
99  union
100  {
102  gdb_byte buf[2 * sizeof (gdb_byte *)];
103  } u;
104 };
105 
107 {
108  enum gdb_signal sigval;
110 };
111 
113 {
117 };
118 
119 /* This is the data structure that makes up the execution log.
120 
121  The execution log consists of a single linked list of entries
122  of type "struct record_full_entry". It is doubly linked so that it
123  can be traversed in either direction.
124 
125  The start of the list is anchored by a struct called
126  "record_full_first". The pointer "record_full_list" either points
127  to the last entry that was added to the list (in record mode), or to
128  the next entry in the list that will be executed (in replay mode).
129 
130  Each list element (struct record_full_entry), in addition to next
131  and prev pointers, consists of a union of three entry types: mem,
132  reg, and end. A field called "type" determines which entry type is
133  represented by a given list element.
134 
135  Each instruction that is added to the execution log is represented
136  by a variable number of list elements ('entries'). The instruction
137  will have one "reg" entry for each register that is changed by
138  executing the instruction (including the PC in every case). It
139  will also have one "mem" entry for each memory change. Finally,
140  each instruction will have an "end" entry that separates it from
141  the changes associated with the next instruction. */
142 
144 {
148  union
149  {
150  /* reg */
152  /* mem */
154  /* end */
156  } u;
157 };
158 
159 /* If true, query if PREC cannot record memory
160  change of next instruction. */
162 
164 {
166  struct target_section *p;
167  bfd_byte *buf;
168 };
169 
170 /* Record buf with core target. */
175 
176 /* The following variables are used for managing the linked list that
177  represents the execution log.
178 
179  record_full_first is the anchor that holds down the beginning of
180  the list.
181 
182  record_full_list serves two functions:
183  1) In record mode, it anchors the end of the list.
184  2) In replay mode, it traverses the list and points to
185  the next instruction that must be emulated.
186 
187  record_full_arch_list_head and record_full_arch_list_tail are used
188  to manage a separate list, which is used to build up the change
189  elements of the currently executing instruction during record mode.
190  When this instruction has been completely annotated in the "arch
191  list", it will be appended to the main execution log. */
192 
197 
198 /* 1 ask user. 0 auto delete the last struct record_full_entry. */
200 /* Maximum allowed number of insns in execution log. */
201 static unsigned int record_full_insn_max_num
203 /* Actual count of insns presently in execution log. */
204 static unsigned int record_full_insn_num = 0;
205 /* Count of insns logged so far (may be larger
206  than count of insns presently in execution log). */
208 
209 /* The target_ops of process record. */
212 
213 /* See record-full.h. */
214 
215 int
217 {
218  struct target_ops *t;
219 
220  t = find_record_target ();
221  return (t == &record_full_ops
222  || t == &record_full_core_ops);
223 }
224 
225 
226 /* Command lists for "set/show record full". */
229 
230 /* Command list for "record full". */
232 
233 static void record_full_goto_insn (struct record_full_entry *entry,
234  enum exec_direction_kind dir);
235 static void record_full_save (struct target_ops *self,
236  const char *recfilename);
237 
238 /* Alloc and free functions for record_full_reg, record_full_mem, and
239  record_full_end entries. */
240 
241 /* Alloc a record_full_reg record entry. */
242 
243 static inline struct record_full_entry *
245 {
246  struct record_full_entry *rec;
247  struct gdbarch *gdbarch = regcache->arch ();
248 
249  rec = XCNEW (struct record_full_entry);
250  rec->type = record_full_reg;
251  rec->u.reg.num = regnum;
252  rec->u.reg.len = register_size (gdbarch, regnum);
253  if (rec->u.reg.len > sizeof (rec->u.reg.u.buf))
254  rec->u.reg.u.ptr = (gdb_byte *) xmalloc (rec->u.reg.len);
255 
256  return rec;
257 }
258 
259 /* Free a record_full_reg record entry. */
260 
261 static inline void
263 {
264  gdb_assert (rec->type == record_full_reg);
265  if (rec->u.reg.len > sizeof (rec->u.reg.u.buf))
266  xfree (rec->u.reg.u.ptr);
267  xfree (rec);
268 }
269 
270 /* Alloc a record_full_mem record entry. */
271 
272 static inline struct record_full_entry *
274 {
275  struct record_full_entry *rec;
276 
277  rec = XCNEW (struct record_full_entry);
278  rec->type = record_full_mem;
279  rec->u.mem.addr = addr;
280  rec->u.mem.len = len;
281  if (rec->u.mem.len > sizeof (rec->u.mem.u.buf))
282  rec->u.mem.u.ptr = (gdb_byte *) xmalloc (len);
283 
284  return rec;
285 }
286 
287 /* Free a record_full_mem record entry. */
288 
289 static inline void
291 {
292  gdb_assert (rec->type == record_full_mem);
293  if (rec->u.mem.len > sizeof (rec->u.mem.u.buf))
294  xfree (rec->u.mem.u.ptr);
295  xfree (rec);
296 }
297 
298 /* Alloc a record_full_end record entry. */
299 
300 static inline struct record_full_entry *
302 {
303  struct record_full_entry *rec;
304 
305  rec = XCNEW (struct record_full_entry);
306  rec->type = record_full_end;
307 
308  return rec;
309 }
310 
311 /* Free a record_full_end record entry. */
312 
313 static inline void
315 {
316  xfree (rec);
317 }
318 
319 /* Free one record entry, any type.
320  Return entry->type, in case caller wants to know. */
321 
322 static inline enum record_full_type
324 {
325  enum record_full_type type = rec->type;
326 
327  switch (type) {
328  case record_full_reg:
330  break;
331  case record_full_mem:
333  break;
334  case record_full_end:
336  break;
337  }
338  return type;
339 }
340 
341 /* Free all record entries in list pointed to by REC. */
342 
343 static void
345 {
346  if (!rec)
347  return;
348 
349  while (rec->next)
350  rec = rec->next;
351 
352  while (rec->prev)
353  {
354  rec = rec->prev;
356  }
357 
358  if (rec == &record_full_first)
359  {
361  record_full_first.next = NULL;
362  }
363  else
365 }
366 
367 /* Free all record entries forward of the given list position. */
368 
369 static void
371 {
372  struct record_full_entry *tmp = rec->next;
373 
374  rec->next = NULL;
375  while (tmp)
376  {
377  rec = tmp->next;
379  {
382  }
383  tmp = rec;
384  }
385 }
386 
387 /* Delete the first instruction from the beginning of the log, to make
388  room for adding a new instruction at the end of the log.
389 
390  Note -- this function does not modify record_full_insn_num. */
391 
392 static void
394 {
395  struct record_full_entry *tmp;
396 
397  if (!record_full_first.next)
398  return;
399 
400  /* Loop until a record_full_end. */
401  while (1)
402  {
403  /* Cut record_full_first.next out of the linked list. */
404  tmp = record_full_first.next;
405  record_full_first.next = tmp->next;
406  tmp->next->prev = &record_full_first;
407 
408  /* tmp is now isolated, and can be deleted. */
410  break; /* End loop at first record_full_end. */
411 
412  if (!record_full_first.next)
413  {
415  break; /* End loop when list is empty. */
416  }
417  }
418 }
419 
420 /* Add a struct record_full_entry to record_full_arch_list. */
421 
422 static void
424 {
425  if (record_debug > 1)
427  "Process record: record_full_arch_list_add %s.\n",
428  host_address_to_string (rec));
429 
431  {
435  }
436  else
437  {
440  }
441 }
442 
443 /* Return the value storage location of a record entry. */
444 static inline gdb_byte *
446 {
447  switch (rec->type) {
448  case record_full_mem:
449  if (rec->u.mem.len > sizeof (rec->u.mem.u.buf))
450  return rec->u.mem.u.ptr;
451  else
452  return rec->u.mem.u.buf;
453  case record_full_reg:
454  if (rec->u.reg.len > sizeof (rec->u.reg.u.buf))
455  return rec->u.reg.u.ptr;
456  else
457  return rec->u.reg.u.buf;
458  case record_full_end:
459  default:
460  gdb_assert_not_reached ("unexpected record_full_entry type");
461  return NULL;
462  }
463 }
464 
465 /* Record the value of a register NUM to record_full_arch_list. */
466 
467 int
469 {
470  struct record_full_entry *rec;
471 
472  if (record_debug > 1)
474  "Process record: add register num = %d to "
475  "record list.\n",
476  regnum);
477 
479 
481 
483 
484  return 0;
485 }
486 
487 /* Record the value of a region of memory whose address is ADDR and
488  length is LEN to record_full_arch_list. */
489 
490 int
492 {
493  struct record_full_entry *rec;
494 
495  if (record_debug > 1)
497  "Process record: add mem addr = %s len = %d to "
498  "record list.\n",
499  paddress (target_gdbarch (), addr), len);
500 
501  if (!addr) /* FIXME: Why? Some arch must permit it... */
502  return 0;
503 
504  rec = record_full_mem_alloc (addr, len);
505 
506  if (record_read_memory (target_gdbarch (), addr,
507  record_full_get_loc (rec), len))
508  {
510  return -1;
511  }
512 
514 
515  return 0;
516 }
517 
518 /* Add a record_full_end type struct record_full_entry to
519  record_full_arch_list. */
520 
521 int
523 {
524  struct record_full_entry *rec;
525 
526  if (record_debug > 1)
528  "Process record: add end to arch list.\n");
529 
530  rec = record_full_end_alloc ();
531  rec->u.end.sigval = GDB_SIGNAL_0;
533 
535 
536  return 0;
537 }
538 
539 static void
541 {
543  {
544  /* Ask user what to do. */
546  {
547  if (!yquery (_("Do you want to auto delete previous execution "
548  "log entries when record/replay buffer becomes "
549  "full (record full stop-at-limit)?")))
550  error (_("Process record: stopped by user."));
552  }
553  }
554 }
555 
556 static void
558 {
560 }
561 
562 /* Before inferior step (when GDB record the running message, inferior
563  only can step), GDB will call this function to record the values to
564  record_full_list. This function will call gdbarch_process_record to
565  record the running message of inferior and set them to
566  record_full_arch_list, and add it to record_full_list. */
567 
568 static void
569 record_full_message (struct regcache *regcache, enum gdb_signal signal)
570 {
571  int ret;
572  struct gdbarch *gdbarch = regcache->arch ();
573  struct cleanup *old_cleanups
575 
578 
579  /* Check record_full_insn_num. */
581 
582  /* If gdb sends a signal value to target_resume,
583  save it in the 'end' field of the previous instruction.
584 
585  Maybe process record should record what really happened,
586  rather than what gdb pretends has happened.
587 
588  So if Linux delivered the signal to the child process during
589  the record mode, we will record it and deliver it again in
590  the replay mode.
591 
592  If user says "ignore this signal" during the record mode, then
593  it will be ignored again during the replay mode (no matter if
594  the user says something different, like "deliver this signal"
595  during the replay mode).
596 
597  User should understand that nothing he does during the replay
598  mode will change the behavior of the child. If he tries,
599  then that is a user error.
600 
601  But we should still deliver the signal to gdb during the replay,
602  if we delivered it during the recording. Therefore we should
603  record the signal during record_full_wait, not
604  record_full_resume. */
605  if (record_full_list != &record_full_first) /* FIXME better way to check */
606  {
608  record_full_list->u.end.sigval = signal;
609  }
610 
611  if (signal == GDB_SIGNAL_0
614  regcache,
616  else
618  regcache,
619  signal);
620 
621  if (ret > 0)
622  error (_("Process record: inferior program stopped."));
623  if (ret < 0)
624  error (_("Process record: failed to record execution log."));
625 
626  discard_cleanups (old_cleanups);
627 
631 
634  else
636 }
637 
638 static bool
640  enum gdb_signal signal)
641 {
642  TRY
643  {
644  record_full_message (regcache, signal);
645  }
646  CATCH (ex, RETURN_MASK_ALL)
647  {
649  return false;
650  }
651  END_CATCH
652 
653  return true;
654 }
655 
656 /* Set to 1 if record_full_store_registers and record_full_xfer_partial
657  doesn't need record. */
658 
660 
663 {
665 }
666 
667 /* Flag set to TRUE for target_stopped_by_watchpoint. */
670 
671 /* Execute one instruction from the record log. Each instruction in
672  the log will be represented by an arbitrary sequence of register
673  entries and memory entries, followed by an 'end' entry. */
674 
675 static inline void
677  struct gdbarch *gdbarch,
678  struct record_full_entry *entry)
679 {
680  switch (entry->type)
681  {
682  case record_full_reg: /* reg */
683  {
684  gdb::byte_vector reg (entry->u.reg.len);
685 
686  if (record_debug > 1)
688  "Process record: record_full_reg %s to "
689  "inferior num = %d.\n",
690  host_address_to_string (entry),
691  entry->u.reg.num);
692 
693  regcache_cooked_read (regcache, entry->u.reg.num, reg.data ());
695  record_full_get_loc (entry));
696  memcpy (record_full_get_loc (entry), reg.data (), entry->u.reg.len);
697  }
698  break;
699 
700  case record_full_mem: /* mem */
701  {
702  /* Nothing to do if the entry is flagged not_accessible. */
703  if (!entry->u.mem.mem_entry_not_accessible)
704  {
705  gdb_byte *mem = (gdb_byte *) xmalloc (entry->u.mem.len);
706  struct cleanup *cleanup = make_cleanup (xfree, mem);
707 
708  if (record_debug > 1)
710  "Process record: record_full_mem %s to "
711  "inferior addr = %s len = %d.\n",
712  host_address_to_string (entry),
713  paddress (gdbarch, entry->u.mem.addr),
714  entry->u.mem.len);
715 
717  entry->u.mem.addr, mem, entry->u.mem.len))
718  entry->u.mem.mem_entry_not_accessible = 1;
719  else
720  {
721  if (target_write_memory (entry->u.mem.addr,
722  record_full_get_loc (entry),
723  entry->u.mem.len))
724  {
725  entry->u.mem.mem_entry_not_accessible = 1;
726  if (record_debug)
727  warning (_("Process record: error writing memory at "
728  "addr = %s len = %d."),
729  paddress (gdbarch, entry->u.mem.addr),
730  entry->u.mem.len);
731  }
732  else
733  {
734  memcpy (record_full_get_loc (entry), mem,
735  entry->u.mem.len);
736 
737  /* We've changed memory --- check if a hardware
738  watchpoint should trap. Note that this
739  presently assumes the target beneath supports
740  continuable watchpoints. On non-continuable
741  watchpoints target, we'll want to check this
742  _before_ actually doing the memory change, and
743  not doing the change at all if the watchpoint
744  traps. */
746  (regcache->aspace (),
747  entry->u.mem.addr, entry->u.mem.len))
749  }
750  }
751 
753  }
754  }
755  break;
756  }
757 }
758 
759 static void record_full_restore (void);
760 
761 /* Asynchronous signal handle registered as event loop source for when
762  we have pending events ready to be passed to the core. */
763 
765 
766 static void
768 {
770 }
771 
772 /* Open the process record target. */
773 
774 static void
775 record_full_core_open_1 (const char *name, int from_tty)
776 {
778  int regnum = gdbarch_num_regs (regcache->arch ());
779  int i;
780 
781  /* Get record_full_core_regbuf. */
784  for (i = 0; i < regnum; i ++)
787 
788  /* Get record_full_core_start and record_full_core_end. */
791  {
794  error (_("\"%s\": Can't find sections: %s"),
795  bfd_get_filename (core_bfd), bfd_errmsg (bfd_get_error ()));
796  }
797 
800 }
801 
802 /* "to_open" target method for 'live' processes. */
803 
804 static void
805 record_full_open_1 (const char *name, int from_tty)
806 {
807  if (record_debug)
808  fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open_1\n");
809 
810  /* check exec */
812  error (_("Process record: the program is not being run."));
813  if (non_stop)
814  error (_("Process record target can't debug inferior in non-stop mode "
815  "(non-stop)."));
816 
818  error (_("Process record: the current architecture doesn't support "
819  "record function."));
820 
822 }
823 
824 static void record_full_init_record_breakpoints (void);
825 
826 /* "to_open" target method. Open the process record target. */
827 
828 static void
829 record_full_open (const char *name, int from_tty)
830 {
831  if (record_debug)
832  fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n");
833 
834  record_preopen ();
835 
836  /* Reset */
840  record_full_list->next = NULL;
841 
842  if (core_bfd)
843  record_full_core_open_1 (name, from_tty);
844  else
845  record_full_open_1 (name, from_tty);
846 
847  /* Register extra event sources in the event loop. */
850  NULL);
851 
853 
854  observer_notify_record_changed (current_inferior (), 1, "full", NULL);
855 }
856 
857 /* "to_close" target method. Close the process record target. */
858 
859 static void
861 {
862  struct record_full_core_buf_entry *entry;
863 
864  if (record_debug)
865  fprintf_unfiltered (gdb_stdlog, "Process record: record_full_close\n");
866 
868 
869  /* Release record_full_core_regbuf. */
871  {
874  }
875 
876  /* Release record_full_core_buf_list. */
878  {
879  for (entry = record_full_core_buf_list->prev; entry;
880  entry = entry->prev)
881  {
884  }
886  }
887 
890 }
891 
892 /* "to_async" target method. */
893 
894 static void
896 {
897  if (enable)
899  else
901 
902  ops->beneath->to_async (ops->beneath, enable);
903 }
904 
905 static int record_full_resume_step = 0;
906 
907 /* True if we've been resumed, and so each record_full_wait call should
908  advance execution. If this is false, record_full_wait will return a
909  TARGET_WAITKIND_IGNORE. */
910 static int record_full_resumed = 0;
911 
912 /* The execution direction of the last resume we got. This is
913  necessary for async mode. Vis (order is not strictly accurate):
914 
915  1. user has the global execution direction set to forward
916  2. user does a reverse-step command
917  3. record_full_resume is called with global execution direction
918  temporarily switched to reverse
919  4. GDB's execution direction is reverted back to forward
920  5. target record notifies event loop there's an event to handle
921  6. infrun asks the target which direction was it going, and switches
922  the global execution direction accordingly (to reverse)
923  7. infrun polls an event out of the record target, and handles it
924  8. GDB goes back to the event loop, and goto #4.
925 */
927 
928 /* "to_resume" target method. Resume the process record target. */
929 
930 static void
931 record_full_resume (struct target_ops *ops, ptid_t ptid, int step,
932  enum gdb_signal signal)
933 {
937 
939  {
940  struct gdbarch *gdbarch = target_thread_architecture (ptid);
941 
943 
944  if (!step)
945  {
946  /* This is not hard single step. */
948  {
949  /* This is a normal continue. */
950  step = 1;
951  }
952  else
953  {
954  /* This arch supports soft single step. */
956  {
957  /* This is a soft single step. */
959  }
960  else
962  }
963  }
964 
965  /* Make sure the target beneath reports all signals. */
966  target_pass_signals (0, NULL);
967 
968  ops->beneath->to_resume (ops->beneath, ptid, step, signal);
969  }
970 
971  /* We are about to start executing the inferior (or simulate it),
972  let's register it with the event loop. */
973  if (target_can_async_p ())
974  target_async (1);
975 }
976 
977 /* "to_commit_resume" method for process record target. */
978 
979 static void
981 {
983  ops->beneath->to_commit_resume (ops->beneath);
984 }
985 
986 static int record_full_get_sig = 0;
987 
988 /* SIGINT signal handler, registered by "to_wait" method. */
989 
990 static void
992 {
993  if (record_debug)
994  fprintf_unfiltered (gdb_stdlog, "Process record: get a signal\n");
995 
996  /* It will break the running inferior in replay mode. */
998 
999  /* It will let record_full_wait set inferior status to get the signal
1000  SIGINT. */
1001  record_full_get_sig = 1;
1002 }
1003 
1004 static void
1006 {
1008  {
1009  if (record_full_list->next)
1011  }
1012  else
1014 }
1015 
1016 /* "to_wait" target method for process record target.
1017 
1018  In record mode, the target is always run in singlestep mode
1019  (even when gdb says to continue). The to_wait method intercepts
1020  the stop events and determines which ones are to be passed on to
1021  gdb. Most stop events are just singlestep events that gdb is not
1022  to know about, so the to_wait method just records them and keeps
1023  singlestepping.
1024 
1025  In replay mode, this function emulates the recorded execution log,
1026  one instruction at a time (forward or backward), and determines
1027  where to stop. */
1028 
1029 static ptid_t
1031  ptid_t ptid, struct target_waitstatus *status,
1032  int options)
1033 {
1034  scoped_restore restore_operation_disable
1036 
1037  if (record_debug)
1039  "Process record: record_full_wait "
1040  "record_full_resume_step = %d, "
1041  "record_full_resumed = %d, direction=%s\n",
1044  ? "forward" : "reverse");
1045 
1046  if (!record_full_resumed)
1047  {
1048  gdb_assert ((options & TARGET_WNOHANG) != 0);
1049 
1050  /* No interesting event. */
1052  return minus_one_ptid;
1053  }
1054 
1055  record_full_get_sig = 0;
1056  signal (SIGINT, record_full_sig_handler);
1057 
1059 
1061  {
1063  {
1064  /* This is a single step. */
1065  return ops->beneath->to_wait (ops->beneath, ptid, status, options);
1066  }
1067  else
1068  {
1069  /* This is not a single step. */
1070  ptid_t ret;
1071  CORE_ADDR tmp_pc;
1073 
1074  while (1)
1075  {
1076  struct thread_info *tp;
1077 
1078  ret = ops->beneath->to_wait (ops->beneath, ptid, status, options);
1079  if (status->kind == TARGET_WAITKIND_IGNORE)
1080  {
1081  if (record_debug)
1083  "Process record: record_full_wait "
1084  "target beneath not done yet\n");
1085  return ret;
1086  }
1087 
1090 
1092  return ret;
1093 
1094  /* Is this a SIGTRAP? */
1095  if (status->kind == TARGET_WAITKIND_STOPPED
1096  && status->value.sig == GDB_SIGNAL_TRAP)
1097  {
1098  struct regcache *regcache;
1099  enum target_stop_reason *stop_reason_p
1101 
1102  /* Yes -- this is likely our single-step finishing,
1103  but check if there's any reason the core would be
1104  interested in the event. */
1105 
1106  registers_changed ();
1108  tmp_pc = regcache_read_pc (regcache);
1109  const struct address_space *aspace = regcache->aspace ();
1110 
1112  {
1113  /* Always interested in watchpoints. */
1114  }
1115  else if (record_check_stopped_by_breakpoint (aspace, tmp_pc,
1116  stop_reason_p))
1117  {
1118  /* There is a breakpoint here. Let the core
1119  handle it. */
1120  }
1121  else
1122  {
1123  /* This is a single-step trap. Record the
1124  insn and issue another step.
1125  FIXME: this part can be a random SIGTRAP too.
1126  But GDB cannot handle it. */
1127  int step = 1;
1128 
1130  GDB_SIGNAL_0))
1131  {
1133  status->value.sig = GDB_SIGNAL_0;
1134  break;
1135  }
1136 
1138  {
1139  /* Try to insert the software single step breakpoint.
1140  If insert success, set step to 0. */
1142  reinit_frame_cache ();
1143 
1145 
1147  }
1148 
1149  if (record_debug)
1151  "Process record: record_full_wait "
1152  "issuing one more step in the "
1153  "target beneath\n");
1154  ops->beneath->to_resume (ops->beneath, ptid, step,
1155  GDB_SIGNAL_0);
1156  ops->beneath->to_commit_resume (ops->beneath);
1157  continue;
1158  }
1159  }
1160 
1161  /* The inferior is broken by a breakpoint or a signal. */
1162  break;
1163  }
1164 
1165  return ret;
1166  }
1167  }
1168  else
1169  {
1170  struct regcache *regcache = get_current_regcache ();
1171  struct gdbarch *gdbarch = regcache->arch ();
1172  const struct address_space *aspace = regcache->aspace ();
1173  int continue_flag = 1;
1174  int first_record_full_end = 1;
1175  struct cleanup *old_cleanups
1177  CORE_ADDR tmp_pc;
1178 
1181 
1182  /* Check breakpoint when forward execute. */
1184  {
1185  tmp_pc = regcache_read_pc (regcache);
1186  if (record_check_stopped_by_breakpoint (aspace, tmp_pc,
1188  {
1189  if (record_debug)
1191  "Process record: break at %s.\n",
1192  paddress (gdbarch, tmp_pc));
1193  goto replay_out;
1194  }
1195  }
1196 
1197  /* If GDB is in terminal_inferior mode, it will not get the signal.
1198  And in GDB replay mode, GDB doesn't need to be in terminal_inferior
1199  mode, because inferior will not executed.
1200  Then set it to terminal_ours to make GDB get the signal. */
1202 
1203  /* In EXEC_FORWARD mode, record_full_list points to the tail of prev
1204  instruction. */
1207 
1208  /* Loop over the record_full_list, looking for the next place to
1209  stop. */
1210  do
1211  {
1212  /* Check for beginning and end of log. */
1215  {
1216  /* Hit beginning of record log in reverse. */
1218  break;
1219  }
1221  {
1222  /* Hit end of record log going forward. */
1224  break;
1225  }
1226 
1228 
1230  {
1231  if (record_debug > 1)
1233  "Process record: record_full_end %s to "
1234  "inferior.\n",
1236 
1237  if (first_record_full_end && execution_direction == EXEC_REVERSE)
1238  {
1239  /* When reverse excute, the first record_full_end is the
1240  part of current instruction. */
1241  first_record_full_end = 0;
1242  }
1243  else
1244  {
1245  /* In EXEC_REVERSE mode, this is the record_full_end of prev
1246  instruction.
1247  In EXEC_FORWARD mode, this is the record_full_end of
1248  current instruction. */
1249  /* step */
1251  {
1252  if (record_debug > 1)
1254  "Process record: step.\n");
1255  continue_flag = 0;
1256  }
1257 
1258  /* check breakpoint */
1259  tmp_pc = regcache_read_pc (regcache);
1260  if (record_check_stopped_by_breakpoint (aspace, tmp_pc,
1262  {
1263  if (record_debug)
1265  "Process record: break "
1266  "at %s.\n",
1267  paddress (gdbarch, tmp_pc));
1268 
1269  continue_flag = 0;
1270  }
1271 
1273  {
1274  if (record_debug)
1276  "Process record: hit hw "
1277  "watchpoint.\n");
1278  continue_flag = 0;
1279  }
1280  /* Check target signal */
1281  if (record_full_list->u.end.sigval != GDB_SIGNAL_0)
1282  /* FIXME: better way to check */
1283  continue_flag = 0;
1284  }
1285  }
1286 
1287  if (continue_flag)
1288  {
1290  {
1291  if (record_full_list->prev)
1293  }
1294  else
1295  {
1296  if (record_full_list->next)
1298  }
1299  }
1300  }
1301  while (continue_flag);
1302 
1303 replay_out:
1304  if (record_full_get_sig)
1305  status->value.sig = GDB_SIGNAL_INT;
1306  else if (record_full_list->u.end.sigval != GDB_SIGNAL_0)
1307  /* FIXME: better way to check */
1308  status->value.sig = record_full_list->u.end.sigval;
1309  else
1310  status->value.sig = GDB_SIGNAL_TRAP;
1311 
1312  discard_cleanups (old_cleanups);
1313  }
1314 
1315  signal (SIGINT, handle_sigint);
1316 
1317  return inferior_ptid;
1318 }
1319 
1320 static ptid_t
1322  ptid_t ptid, struct target_waitstatus *status,
1323  int options)
1324 {
1325  ptid_t return_ptid;
1326 
1327  return_ptid = record_full_wait_1 (ops, ptid, status, options);
1328  if (status->kind != TARGET_WAITKIND_IGNORE)
1329  {
1330  /* We're reporting a stop. Make sure any spurious
1331  target_wait(WNOHANG) doesn't advance the target until the
1332  core wants us resumed again. */
1333  record_full_resumed = 0;
1334  }
1335  return return_ptid;
1336 }
1337 
1338 static int
1340 {
1343  else
1344  return ops->beneath->to_stopped_by_watchpoint (ops->beneath);
1345 }
1346 
1347 static int
1349 {
1351  return 0;
1352  else
1353  return ops->beneath->to_stopped_data_address (ops->beneath, addr_p);
1354 }
1355 
1356 /* The to_stopped_by_sw_breakpoint method of target record-full. */
1357 
1358 static int
1360 {
1362 }
1363 
1364 /* The to_supports_stopped_by_sw_breakpoint method of target
1365  record-full. */
1366 
1367 static int
1369 {
1370  return 1;
1371 }
1372 
1373 /* The to_stopped_by_hw_breakpoint method of target record-full. */
1374 
1375 static int
1377 {
1379 }
1380 
1381 /* The to_supports_stopped_by_sw_breakpoint method of target
1382  record-full. */
1383 
1384 static int
1386 {
1387  return 1;
1388 }
1389 
1390 /* Record registers change (by user or by GDB) to list as an instruction. */
1391 
1392 static void
1394 {
1395  /* Check record_full_insn_num. */
1397 
1400 
1401  if (regnum < 0)
1402  {
1403  int i;
1404 
1405  for (i = 0; i < gdbarch_num_regs (regcache->arch ()); i++)
1406  {
1408  {
1410  error (_("Process record: failed to record execution log."));
1411  }
1412  }
1413  }
1414  else
1415  {
1417  {
1419  error (_("Process record: failed to record execution log."));
1420  }
1421  }
1423  {
1425  error (_("Process record: failed to record execution log."));
1426  }
1430 
1433  else
1435 }
1436 
1437 /* "to_store_registers" method for process record target. */
1438 
1439 static void
1441  struct regcache *regcache,
1442  int regno)
1443 {
1445  {
1447  {
1448  int n;
1449 
1450  /* Let user choose if he wants to write register or not. */
1451  if (regno < 0)
1452  n =
1453  query (_("Because GDB is in replay mode, changing the "
1454  "value of a register will make the execution "
1455  "log unusable from this point onward. "
1456  "Change all registers?"));
1457  else
1458  n =
1459  query (_("Because GDB is in replay mode, changing the value "
1460  "of a register will make the execution log unusable "
1461  "from this point onward. Change register %s?"),
1463  regno));
1464 
1465  if (!n)
1466  {
1467  /* Invalidate the value of regcache that was set in function
1468  "regcache_raw_write". */
1469  if (regno < 0)
1470  {
1471  int i;
1472 
1473  for (i = 0;
1474  i < gdbarch_num_regs (regcache->arch ());
1475  i++)
1477  }
1478  else
1479  regcache_invalidate (regcache, regno);
1480 
1481  error (_("Process record canceled the operation."));
1482  }
1483 
1484  /* Destroy the record from here forward. */
1486  }
1487 
1489  }
1490  ops->beneath->to_store_registers (ops->beneath, regcache, regno);
1491 }
1492 
1493 /* "to_xfer_partial" method. Behavior is conditional on
1494  RECORD_FULL_IS_REPLAY.
1495  In replay mode, we cannot write memory unles we are willing to
1496  invalidate the record/replay log from this point forward. */
1497 
1498 static enum target_xfer_status
1500  const char *annex, gdb_byte *readbuf,
1501  const gdb_byte *writebuf, ULONGEST offset,
1502  ULONGEST len, ULONGEST *xfered_len)
1503 {
1505  && (object == TARGET_OBJECT_MEMORY
1506  || object == TARGET_OBJECT_RAW_MEMORY) && writebuf)
1507  {
1509  {
1510  /* Let user choose if he wants to write memory or not. */
1511  if (!query (_("Because GDB is in replay mode, writing to memory "
1512  "will make the execution log unusable from this "
1513  "point onward. Write memory at address %s?"),
1515  error (_("Process record canceled the operation."));
1516 
1517  /* Destroy the record from here forward. */
1519  }
1520 
1521  /* Check record_full_insn_num */
1523 
1524  /* Record registers change to list as an instruction. */
1528  {
1530  if (record_debug)
1532  "Process record: failed to record "
1533  "execution log.");
1534  return TARGET_XFER_E_IO;
1535  }
1537  {
1539  if (record_debug)
1541  "Process record: failed to record "
1542  "execution log.");
1543  return TARGET_XFER_E_IO;
1544  }
1548 
1551  else
1553  }
1554 
1555  return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
1556  readbuf, writebuf, offset,
1557  len, xfered_len);
1558 }
1559 
1560 /* This structure represents a breakpoint inserted while the record
1561  target is active. We use this to know when to install/remove
1562  breakpoints in/from the target beneath. For example, a breakpoint
1563  may be inserted while recording, but removed when not replaying nor
1564  recording. In that case, the breakpoint had not been inserted on
1565  the target beneath, so we should not try to remove it there. */
1566 
1568 {
1569  /* The address and address space the breakpoint was set at. */
1572 
1573  /* True when the breakpoint has been also installed in the target
1574  beneath. This will be false for breakpoints set during replay or
1575  when recording. */
1577 };
1578 
1581 
1582 /* The list of breakpoints inserted while the record target is
1583  active. */
1584 VEC(record_full_breakpoint_p) *record_full_breakpoints = NULL;
1585 
1586 static void
1587 record_full_sync_record_breakpoints (struct bp_location *loc, void *data)
1588 {
1589  if (loc->loc_type != bp_loc_software_breakpoint)
1590  return;
1591 
1592  if (loc->inserted)
1593  {
1595 
1596  bp->addr = loc->target_info.placed_address;
1597  bp->address_space = loc->target_info.placed_address_space;
1598 
1599  bp->in_target_beneath = 1;
1600 
1601  VEC_safe_push (record_full_breakpoint_p, record_full_breakpoints, bp);
1602  }
1603 }
1604 
1605 /* Sync existing breakpoints to record_full_breakpoints. */
1606 
1607 static void
1609 {
1610  VEC_free (record_full_breakpoint_p, record_full_breakpoints);
1611 
1612  iterate_over_bp_locations (record_full_sync_record_breakpoints);
1613 }
1614 
1615 /* Behavior is conditional on RECORD_FULL_IS_REPLAY. We will not actually
1616  insert or remove breakpoints in the real target when replaying, nor
1617  when recording. */
1618 
1619 static int
1621  struct gdbarch *gdbarch,
1622  struct bp_target_info *bp_tgt)
1623 {
1624  struct record_full_breakpoint *bp;
1625  int in_target_beneath = 0;
1626  int ix;
1627 
1628  if (!RECORD_FULL_IS_REPLAY)
1629  {
1630  /* When recording, we currently always single-step, so we don't
1631  really need to install regular breakpoints in the inferior.
1632  However, we do have to insert software single-step
1633  breakpoints, in case the target can't hardware step. To keep
1634  things simple, we always insert. */
1635  int ret;
1636 
1637  scoped_restore restore_operation_disable
1639  ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt);
1640 
1641  if (ret != 0)
1642  return ret;
1643 
1644  in_target_beneath = 1;
1645  }
1646 
1647  /* Use the existing entries if found in order to avoid duplication
1648  in record_full_breakpoints. */
1649 
1650  for (ix = 0;
1652  record_full_breakpoints, ix, bp);
1653  ++ix)
1654  {
1655  if (bp->addr == bp_tgt->placed_address
1656  && bp->address_space == bp_tgt->placed_address_space)
1657  {
1658  gdb_assert (bp->in_target_beneath == in_target_beneath);
1659  return 0;
1660  }
1661  }
1662 
1663  bp = XNEW (struct record_full_breakpoint);
1664  bp->addr = bp_tgt->placed_address;
1665  bp->address_space = bp_tgt->placed_address_space;
1666  bp->in_target_beneath = in_target_beneath;
1667  VEC_safe_push (record_full_breakpoint_p, record_full_breakpoints, bp);
1668  return 0;
1669 }
1670 
1671 /* "to_remove_breakpoint" method for process record target. */
1672 
1673 static int
1675  struct gdbarch *gdbarch,
1676  struct bp_target_info *bp_tgt,
1677  enum remove_bp_reason reason)
1678 {
1679  struct record_full_breakpoint *bp;
1680  int ix;
1681 
1682  for (ix = 0;
1684  record_full_breakpoints, ix, bp);
1685  ++ix)
1686  {
1687  if (bp->addr == bp_tgt->placed_address
1688  && bp->address_space == bp_tgt->placed_address_space)
1689  {
1690  if (bp->in_target_beneath)
1691  {
1692  int ret;
1693 
1694  scoped_restore restore_operation_disable
1696  ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch,
1697  bp_tgt, reason);
1698  if (ret != 0)
1699  return ret;
1700  }
1701 
1702  if (reason == REMOVE_BREAKPOINT)
1703  {
1705  record_full_breakpoints, ix);
1706  }
1707  return 0;
1708  }
1709  }
1710 
1711  gdb_assert_not_reached ("removing unknown breakpoint");
1712 }
1713 
1714 /* "to_can_execute_reverse" method for process record target. */
1715 
1716 static int
1718 {
1719  return 1;
1720 }
1721 
1722 /* "to_get_bookmark" method for process record and prec over core. */
1723 
1724 static gdb_byte *
1725 record_full_get_bookmark (struct target_ops *self, const char *args,
1726  int from_tty)
1727 {
1728  char *ret = NULL;
1729 
1730  /* Return stringified form of instruction count. */
1732  ret = xstrdup (pulongest (record_full_list->u.end.insn_num));
1733 
1734  if (record_debug)
1735  {
1736  if (ret)
1738  "record_full_get_bookmark returns %s\n", ret);
1739  else
1741  "record_full_get_bookmark returns NULL\n");
1742  }
1743  return (gdb_byte *) ret;
1744 }
1745 
1746 /* "to_goto_bookmark" method for process record and prec over core. */
1747 
1748 static void
1750  const gdb_byte *raw_bookmark, int from_tty)
1751 {
1752  const char *bookmark = (const char *) raw_bookmark;
1753  struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
1754 
1755  if (record_debug)
1757  "record_full_goto_bookmark receives %s\n", bookmark);
1758 
1759  if (bookmark[0] == '\'' || bookmark[0] == '\"')
1760  {
1761  char *copy;
1762 
1763  if (bookmark[strlen (bookmark) - 1] != bookmark[0])
1764  error (_("Unbalanced quotes: %s"), bookmark);
1765 
1766 
1767  copy = savestring (bookmark + 1, strlen (bookmark) - 2);
1768  make_cleanup (xfree, copy);
1769  bookmark = copy;
1770  }
1771 
1773 
1774  do_cleanups (cleanup);
1775 }
1776 
1777 static enum exec_direction_kind
1779 {
1781 }
1782 
1783 /* The to_record_method method of target record-full. */
1784 
1785 enum record_method
1787 {
1788  return RECORD_METHOD_FULL;
1789 }
1790 
1791 static void
1793 {
1794  struct record_full_entry *p;
1795 
1797  printf_filtered (_("Replay mode:\n"));
1798  else
1799  printf_filtered (_("Record mode:\n"));
1800 
1801  /* Find entry for first actual instruction in the log. */
1802  for (p = record_full_first.next;
1803  p != NULL && p->type != record_full_end;
1804  p = p->next)
1805  ;
1806 
1807  /* Do we have a log at all? */
1808  if (p != NULL && p->type == record_full_end)
1809  {
1810  /* Display instruction number for first instruction in the log. */
1811  printf_filtered (_("Lowest recorded instruction number is %s.\n"),
1812  pulongest (p->u.end.insn_num));
1813 
1814  /* If in replay mode, display where we are in the log. */
1816  printf_filtered (_("Current instruction number is %s.\n"),
1818 
1819  /* Display instruction number for last instruction in the log. */
1820  printf_filtered (_("Highest recorded instruction number is %s.\n"),
1822 
1823  /* Display log count. */
1824  printf_filtered (_("Log contains %u instructions.\n"),
1826  }
1827  else
1828  printf_filtered (_("No instructions have been logged.\n"));
1829 
1830  /* Display max log size. */
1831  printf_filtered (_("Max logged instructions is %u.\n"),
1833 }
1834 
1835 /* The "to_record_delete" target method. */
1836 
1837 static void
1839 {
1841 }
1842 
1843 /* The "to_record_is_replaying" target method. */
1844 
1845 static int
1847 {
1848  return RECORD_FULL_IS_REPLAY;
1849 }
1850 
1851 /* The "to_record_will_replay" target method. */
1852 
1853 static int
1854 record_full_will_replay (struct target_ops *self, ptid_t ptid, int dir)
1855 {
1856  /* We can currently only record when executing forwards. Should we be able
1857  to record when executing backwards on targets that support reverse
1858  execution, this needs to be changed. */
1859 
1860  return RECORD_FULL_IS_REPLAY || dir == EXEC_REVERSE;
1861 }
1862 
1863 /* Go to a specific entry. */
1864 
1865 static void
1867 {
1868  if (p == NULL)
1869  error (_("Target insn not found."));
1870  else if (p == record_full_list)
1871  error (_("Already at target insn."));
1872  else if (p->u.end.insn_num > record_full_list->u.end.insn_num)
1873  {
1874  printf_filtered (_("Go forward to insn number %s\n"),
1875  pulongest (p->u.end.insn_num));
1877  }
1878  else
1879  {
1880  printf_filtered (_("Go backward to insn number %s\n"),
1881  pulongest (p->u.end.insn_num));
1883  }
1884 
1885  registers_changed ();
1886  reinit_frame_cache ();
1889 }
1890 
1891 /* The "to_goto_record_begin" target method. */
1892 
1893 static void
1895 {
1896  struct record_full_entry *p = NULL;
1897 
1898  for (p = &record_full_first; p != NULL; p = p->next)
1899  if (p->type == record_full_end)
1900  break;
1901 
1903 }
1904 
1905 /* The "to_goto_record_end" target method. */
1906 
1907 static void
1909 {
1910  struct record_full_entry *p = NULL;
1911 
1912  for (p = record_full_list; p->next != NULL; p = p->next)
1913  ;
1914  for (; p!= NULL; p = p->prev)
1915  if (p->type == record_full_end)
1916  break;
1917 
1919 }
1920 
1921 /* The "to_goto_record" target method. */
1922 
1923 static void
1924 record_full_goto (struct target_ops *self, ULONGEST target_insn)
1925 {
1926  struct record_full_entry *p = NULL;
1927 
1928  for (p = &record_full_first; p != NULL; p = p->next)
1929  if (p->type == record_full_end && p->u.end.insn_num == target_insn)
1930  break;
1931 
1933 }
1934 
1935 /* The "to_record_stop_replaying" target method. */
1936 
1937 static void
1939 {
1940  record_full_goto_end (self);
1941 }
1942 
1943 static void
1945 {
1946  record_full_ops.to_shortname = "record-full";
1947  record_full_ops.to_longname = "Process record and replay target";
1949  "Log program while executing and replay execution from log.";
1976  /* Add bookmark target methods. */
1991 }
1992 
1993 /* "to_resume" method for prec over corefile. */
1994 
1995 static void
1996 record_full_core_resume (struct target_ops *ops, ptid_t ptid, int step,
1997  enum gdb_signal signal)
1998 {
1999  record_full_resume_step = step;
2000  record_full_resumed = 1;
2002 
2003  /* We are about to start executing the inferior (or simulate it),
2004  let's register it with the event loop. */
2005  if (target_can_async_p ())
2006  target_async (1);
2007 }
2008 
2009 /* "to_kill" method for prec over corefile. */
2010 
2011 static void
2013 {
2014  if (record_debug)
2015  fprintf_unfiltered (gdb_stdlog, "Process record: record_full_core_kill\n");
2016 
2018 }
2019 
2020 /* "to_fetch_registers" method for prec over corefile. */
2021 
2022 static void
2024  struct regcache *regcache,
2025  int regno)
2026 {
2027  if (regno < 0)
2028  {
2029  int num = gdbarch_num_regs (regcache->arch ());
2030  int i;
2031 
2032  for (i = 0; i < num; i ++)
2035  }
2036  else
2037  regcache_raw_supply (regcache, regno,
2039 }
2040 
2041 /* "to_prepare_to_store" method for prec over corefile. */
2042 
2043 static void
2045  struct regcache *regcache)
2046 {
2047 }
2048 
2049 /* "to_store_registers" method for prec over corefile. */
2050 
2051 static void
2053  struct regcache *regcache,
2054  int regno)
2055 {
2059  else
2060  error (_("You can't do that without a process to debug."));
2061 }
2062 
2063 /* "to_xfer_partial" method for prec over corefile. */
2064 
2065 static enum target_xfer_status
2067  enum target_object object,
2068  const char *annex, gdb_byte *readbuf,
2069  const gdb_byte *writebuf, ULONGEST offset,
2070  ULONGEST len, ULONGEST *xfered_len)
2071 {
2072  if (object == TARGET_OBJECT_MEMORY)
2073  {
2074  if (record_full_gdb_operation_disable || !writebuf)
2075  {
2076  struct target_section *p;
2077 
2078  for (p = record_full_core_start; p < record_full_core_end; p++)
2079  {
2080  if (offset >= p->addr)
2081  {
2082  struct record_full_core_buf_entry *entry;
2083  ULONGEST sec_offset;
2084 
2085  if (offset >= p->endaddr)
2086  continue;
2087 
2088  if (offset + len > p->endaddr)
2089  len = p->endaddr - offset;
2090 
2091  sec_offset = offset - p->addr;
2092 
2093  /* Read readbuf or write writebuf p, offset, len. */
2094  /* Check flags. */
2095  if (p->the_bfd_section->flags & SEC_CONSTRUCTOR
2096  || (p->the_bfd_section->flags & SEC_HAS_CONTENTS) == 0)
2097  {
2098  if (readbuf)
2099  memset (readbuf, 0, len);
2100 
2101  *xfered_len = len;
2102  return TARGET_XFER_OK;
2103  }
2104  /* Get record_full_core_buf_entry. */
2105  for (entry = record_full_core_buf_list; entry;
2106  entry = entry->prev)
2107  if (entry->p == p)
2108  break;
2109  if (writebuf)
2110  {
2111  if (!entry)
2112  {
2113  /* Add a new entry. */
2114  entry = XNEW (struct record_full_core_buf_entry);
2115  entry->p = p;
2116  if (!bfd_malloc_and_get_section
2117  (p->the_bfd_section->owner,
2118  p->the_bfd_section,
2119  &entry->buf))
2120  {
2121  xfree (entry);
2122  return TARGET_XFER_EOF;
2123  }
2125  record_full_core_buf_list = entry;
2126  }
2127 
2128  memcpy (entry->buf + sec_offset, writebuf,
2129  (size_t) len);
2130  }
2131  else
2132  {
2133  if (!entry)
2134  return ops->beneath->to_xfer_partial (ops->beneath,
2135  object, annex,
2136  readbuf, writebuf,
2137  offset, len,
2138  xfered_len);
2139 
2140  memcpy (readbuf, entry->buf + sec_offset,
2141  (size_t) len);
2142  }
2143 
2144  *xfered_len = len;
2145  return TARGET_XFER_OK;
2146  }
2147  }
2148 
2149  return TARGET_XFER_E_IO;
2150  }
2151  else
2152  error (_("You can't do that without a process to debug."));
2153  }
2154 
2155  return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
2156  readbuf, writebuf, offset, len,
2157  xfered_len);
2158 }
2159 
2160 /* "to_insert_breakpoint" method for prec over corefile. */
2161 
2162 static int
2164  struct gdbarch *gdbarch,
2165  struct bp_target_info *bp_tgt)
2166 {
2167  return 0;
2168 }
2169 
2170 /* "to_remove_breakpoint" method for prec over corefile. */
2171 
2172 static int
2174  struct gdbarch *gdbarch,
2175  struct bp_target_info *bp_tgt,
2176  enum remove_bp_reason reason)
2177 {
2178  return 0;
2179 }
2180 
2181 /* "to_has_execution" method for prec over corefile. */
2182 
2183 static int
2185 {
2186  return 1;
2187 }
2188 
2189 static void
2191 {
2192  record_full_core_ops.to_shortname = "record-core";
2193  record_full_core_ops.to_longname = "Process record and replay target";
2195  "Log program while executing and replay execution from log.";
2226  /* Add bookmark target methods. */
2240 }
2241 
2242 /* Record log save-file format
2243  Version 1 (never released)
2244 
2245  Header:
2246  4 bytes: magic number htonl(0x20090829).
2247  NOTE: be sure to change whenever this file format changes!
2248 
2249  Records:
2250  record_full_end:
2251  1 byte: record type (record_full_end, see enum record_full_type).
2252  record_full_reg:
2253  1 byte: record type (record_full_reg, see enum record_full_type).
2254  8 bytes: register id (network byte order).
2255  MAX_REGISTER_SIZE bytes: register value.
2256  record_full_mem:
2257  1 byte: record type (record_full_mem, see enum record_full_type).
2258  8 bytes: memory length (network byte order).
2259  8 bytes: memory address (network byte order).
2260  n bytes: memory value (n == memory length).
2261 
2262  Version 2
2263  4 bytes: magic number netorder32(0x20091016).
2264  NOTE: be sure to change whenever this file format changes!
2265 
2266  Records:
2267  record_full_end:
2268  1 byte: record type (record_full_end, see enum record_full_type).
2269  4 bytes: signal
2270  4 bytes: instruction count
2271  record_full_reg:
2272  1 byte: record type (record_full_reg, see enum record_full_type).
2273  4 bytes: register id (network byte order).
2274  n bytes: register value (n == actual register size).
2275  (eg. 4 bytes for x86 general registers).
2276  record_full_mem:
2277  1 byte: record type (record_full_mem, see enum record_full_type).
2278  4 bytes: memory length (network byte order).
2279  8 bytes: memory address (network byte order).
2280  n bytes: memory value (n == memory length).
2281 
2282 */
2283 
2284 /* bfdcore_read -- read bytes from a core file section. */
2285 
2286 static inline void
2287 bfdcore_read (bfd *obfd, asection *osec, void *buf, int len, int *offset)
2288 {
2289  int ret = bfd_get_section_contents (obfd, osec, buf, *offset, len);
2290 
2291  if (ret)
2292  *offset += len;
2293  else
2294  error (_("Failed to read %d bytes from core file %s ('%s')."),
2295  len, bfd_get_filename (obfd),
2296  bfd_errmsg (bfd_get_error ()));
2297 }
2298 
2299 static inline uint64_t
2300 netorder64 (uint64_t input)
2301 {
2302  uint64_t ret;
2303 
2304  store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret),
2305  BFD_ENDIAN_BIG, input);
2306  return ret;
2307 }
2308 
2309 static inline uint32_t
2310 netorder32 (uint32_t input)
2311 {
2312  uint32_t ret;
2313 
2314  store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret),
2315  BFD_ENDIAN_BIG, input);
2316  return ret;
2317 }
2318 
2319 /* Restore the execution log from a core_bfd file. */
2320 static void
2322 {
2323  uint32_t magic;
2324  struct cleanup *old_cleanups;
2325  struct record_full_entry *rec;
2326  asection *osec;
2327  uint32_t osec_size;
2328  int bfd_offset = 0;
2329  struct regcache *regcache;
2330 
2331  /* We restore the execution log from the open core bfd,
2332  if there is one. */
2333  if (core_bfd == NULL)
2334  return;
2335 
2336  /* "record_full_restore" can only be called when record list is empty. */
2337  gdb_assert (record_full_first.next == NULL);
2338 
2339  if (record_debug)
2340  fprintf_unfiltered (gdb_stdlog, "Restoring recording from core file.\n");
2341 
2342  /* Now need to find our special note section. */
2343  osec = bfd_get_section_by_name (core_bfd, "null0");
2344  if (record_debug)
2345  fprintf_unfiltered (gdb_stdlog, "Find precord section %s.\n",
2346  osec ? "succeeded" : "failed");
2347  if (osec == NULL)
2348  return;
2349  osec_size = bfd_section_size (core_bfd, osec);
2350  if (record_debug)
2351  fprintf_unfiltered (gdb_stdlog, "%s", bfd_section_name (core_bfd, osec));
2352 
2353  /* Check the magic code. */
2354  bfdcore_read (core_bfd, osec, &magic, sizeof (magic), &bfd_offset);
2355  if (magic != RECORD_FULL_FILE_MAGIC)
2356  error (_("Version mis-match or file format error in core file %s."),
2357  bfd_get_filename (core_bfd));
2358  if (record_debug)
2360  " Reading 4-byte magic cookie "
2361  "RECORD_FULL_FILE_MAGIC (0x%s)\n",
2362  phex_nz (netorder32 (magic), 4));
2363 
2364  /* Restore the entries in recfd into record_full_arch_list_head and
2365  record_full_arch_list_tail. */
2369  old_cleanups = make_cleanup (record_full_arch_list_cleanups, 0);
2371 
2372  while (1)
2373  {
2374  uint8_t rectype;
2375  uint32_t regnum, len, signal, count;
2376  uint64_t addr;
2377 
2378  /* We are finished when offset reaches osec_size. */
2379  if (bfd_offset >= osec_size)
2380  break;
2381  bfdcore_read (core_bfd, osec, &rectype, sizeof (rectype), &bfd_offset);
2382 
2383  switch (rectype)
2384  {
2385  case record_full_reg: /* reg */
2386  /* Get register number to regnum. */
2387  bfdcore_read (core_bfd, osec, &regnum,
2388  sizeof (regnum), &bfd_offset);
2389  regnum = netorder32 (regnum);
2390 
2392 
2393  /* Get val. */
2395  rec->u.reg.len, &bfd_offset);
2396 
2397  if (record_debug)
2399  " Reading register %d (1 "
2400  "plus %lu plus %d bytes)\n",
2401  rec->u.reg.num,
2402  (unsigned long) sizeof (regnum),
2403  rec->u.reg.len);
2404  break;
2405 
2406  case record_full_mem: /* mem */
2407  /* Get len. */
2408  bfdcore_read (core_bfd, osec, &len,
2409  sizeof (len), &bfd_offset);
2410  len = netorder32 (len);
2411 
2412  /* Get addr. */
2413  bfdcore_read (core_bfd, osec, &addr,
2414  sizeof (addr), &bfd_offset);
2415  addr = netorder64 (addr);
2416 
2417  rec = record_full_mem_alloc (addr, len);
2418 
2419  /* Get val. */
2421  rec->u.mem.len, &bfd_offset);
2422 
2423  if (record_debug)
2425  " Reading memory %s (1 plus "
2426  "%lu plus %lu plus %d bytes)\n",
2428  rec->u.mem.addr),
2429  (unsigned long) sizeof (addr),
2430  (unsigned long) sizeof (len),
2431  rec->u.mem.len);
2432  break;
2433 
2434  case record_full_end: /* end */
2435  rec = record_full_end_alloc ();
2437 
2438  /* Get signal value. */
2439  bfdcore_read (core_bfd, osec, &signal,
2440  sizeof (signal), &bfd_offset);
2441  signal = netorder32 (signal);
2442  rec->u.end.sigval = (enum gdb_signal) signal;
2443 
2444  /* Get insn count. */
2445  bfdcore_read (core_bfd, osec, &count,
2446  sizeof (count), &bfd_offset);
2447  count = netorder32 (count);
2448  rec->u.end.insn_num = count;
2449  record_full_insn_count = count + 1;
2450  if (record_debug)
2452  " Reading record_full_end (1 + "
2453  "%lu + %lu bytes), offset == %s\n",
2454  (unsigned long) sizeof (signal),
2455  (unsigned long) sizeof (count),
2457  bfd_offset));
2458  break;
2459 
2460  default:
2461  error (_("Bad entry type in core file %s."),
2462  bfd_get_filename (core_bfd));
2463  break;
2464  }
2465 
2466  /* Add rec to record arch list. */
2468  }
2469 
2470  discard_cleanups (old_cleanups);
2471 
2472  /* Add record_full_arch_list_head to the end of record list. */
2477 
2478  /* Update record_full_insn_max_num. */
2480  {
2482  warning (_("Auto increase record/replay buffer limit to %u."),
2484  }
2485 
2486  /* Succeeded. */
2487  printf_filtered (_("Restored records from core file %s.\n"),
2488  bfd_get_filename (core_bfd));
2489 
2491 }
2492 
2493 /* bfdcore_write -- write bytes into a core file section. */
2494 
2495 static inline void
2496 bfdcore_write (bfd *obfd, asection *osec, void *buf, int len, int *offset)
2497 {
2498  int ret = bfd_set_section_contents (obfd, osec, buf, *offset, len);
2499 
2500  if (ret)
2501  *offset += len;
2502  else
2503  error (_("Failed to write %d bytes to core file %s ('%s')."),
2504  len, bfd_get_filename (obfd),
2505  bfd_errmsg (bfd_get_error ()));
2506 }
2507 
2508 /* Restore the execution log from a file. We use a modified elf
2509  corefile format, with an extra section for our data. */
2510 
2511 static void
2512 cmd_record_full_restore (const char *args, int from_tty)
2513 {
2514  core_file_command (args, from_tty);
2515  record_full_open (args, from_tty);
2516 }
2517 
2518 /* Save the execution log to a file. We use a modified elf corefile
2519  format, with an extra section for our data. */
2520 
2521 static void
2522 record_full_save (struct target_ops *self, const char *recfilename)
2523 {
2524  struct record_full_entry *cur_record_full_list;
2525  uint32_t magic;
2526  struct regcache *regcache;
2527  struct gdbarch *gdbarch;
2528  int save_size = 0;
2529  asection *osec = NULL;
2530  int bfd_offset = 0;
2531 
2532  /* Open the save file. */
2533  if (record_debug)
2534  fprintf_unfiltered (gdb_stdlog, "Saving execution log to core file '%s'\n",
2535  recfilename);
2536 
2537  /* Open the output file. */
2538  gdb_bfd_ref_ptr obfd (create_gcore_bfd (recfilename));
2539 
2540  /* Arrange to remove the output file on failure. */
2541  gdb::unlinker unlink_file (recfilename);
2542 
2543  /* Save the current record entry to "cur_record_full_list". */
2544  cur_record_full_list = record_full_list;
2545 
2546  /* Get the values of regcache and gdbarch. */
2548  gdbarch = regcache->arch ();
2549 
2550  /* Disable the GDB operation record. */
2551  scoped_restore restore_operation_disable
2553 
2554  /* Reverse execute to the begin of record list. */
2555  while (1)
2556  {
2557  /* Check for beginning and end of log. */
2559  break;
2560 
2562 
2563  if (record_full_list->prev)
2565  }
2566 
2567  /* Compute the size needed for the extra bfd section. */
2568  save_size = 4; /* magic cookie */
2571  switch (record_full_list->type)
2572  {
2573  case record_full_end:
2574  save_size += 1 + 4 + 4;
2575  break;
2576  case record_full_reg:
2577  save_size += 1 + 4 + record_full_list->u.reg.len;
2578  break;
2579  case record_full_mem:
2580  save_size += 1 + 4 + 8 + record_full_list->u.mem.len;
2581  break;
2582  }
2583 
2584  /* Make the new bfd section. */
2585  osec = bfd_make_section_anyway_with_flags (obfd.get (), "precord",
2586  SEC_HAS_CONTENTS
2587  | SEC_READONLY);
2588  if (osec == NULL)
2589  error (_("Failed to create 'precord' section for corefile %s: %s"),
2590  recfilename,
2591  bfd_errmsg (bfd_get_error ()));
2592  bfd_set_section_size (obfd.get (), osec, save_size);
2593  bfd_set_section_vma (obfd.get (), osec, 0);
2594  bfd_set_section_alignment (obfd.get (), osec, 0);
2595  bfd_section_lma (obfd.get (), osec) = 0;
2596 
2597  /* Save corefile state. */
2598  write_gcore_file (obfd.get ());
2599 
2600  /* Write out the record log. */
2601  /* Write the magic code. */
2602  magic = RECORD_FULL_FILE_MAGIC;
2603  if (record_debug)
2605  " Writing 4-byte magic cookie "
2606  "RECORD_FULL_FILE_MAGIC (0x%s)\n",
2607  phex_nz (magic, 4));
2608  bfdcore_write (obfd.get (), osec, &magic, sizeof (magic), &bfd_offset);
2609 
2610  /* Save the entries to recfd and forward execute to the end of
2611  record list. */
2613  while (1)
2614  {
2615  /* Save entry. */
2617  {
2618  uint8_t type;
2619  uint32_t regnum, len, signal, count;
2620  uint64_t addr;
2621 
2623  bfdcore_write (obfd.get (), osec, &type, sizeof (type), &bfd_offset);
2624 
2625  switch (record_full_list->type)
2626  {
2627  case record_full_reg: /* reg */
2628  if (record_debug)
2630  " Writing register %d (1 "
2631  "plus %lu plus %d bytes)\n",
2633  (unsigned long) sizeof (regnum),
2635 
2636  /* Write regnum. */
2638  bfdcore_write (obfd.get (), osec, &regnum,
2639  sizeof (regnum), &bfd_offset);
2640 
2641  /* Write regval. */
2642  bfdcore_write (obfd.get (), osec,
2644  record_full_list->u.reg.len, &bfd_offset);
2645  break;
2646 
2647  case record_full_mem: /* mem */
2648  if (record_debug)
2650  " Writing memory %s (1 plus "
2651  "%lu plus %lu plus %d bytes)\n",
2652  paddress (gdbarch,
2654  (unsigned long) sizeof (addr),
2655  (unsigned long) sizeof (len),
2657 
2658  /* Write memlen. */
2659  len = netorder32 (record_full_list->u.mem.len);
2660  bfdcore_write (obfd.get (), osec, &len, sizeof (len),
2661  &bfd_offset);
2662 
2663  /* Write memaddr. */
2664  addr = netorder64 (record_full_list->u.mem.addr);
2665  bfdcore_write (obfd.get (), osec, &addr,
2666  sizeof (addr), &bfd_offset);
2667 
2668  /* Write memval. */
2669  bfdcore_write (obfd.get (), osec,
2671  record_full_list->u.mem.len, &bfd_offset);
2672  break;
2673 
2674  case record_full_end:
2675  if (record_debug)
2677  " Writing record_full_end (1 + "
2678  "%lu + %lu bytes)\n",
2679  (unsigned long) sizeof (signal),
2680  (unsigned long) sizeof (count));
2681  /* Write signal value. */
2682  signal = netorder32 (record_full_list->u.end.sigval);
2683  bfdcore_write (obfd.get (), osec, &signal,
2684  sizeof (signal), &bfd_offset);
2685 
2686  /* Write insn count. */
2688  bfdcore_write (obfd.get (), osec, &count,
2689  sizeof (count), &bfd_offset);
2690  break;
2691  }
2692  }
2693 
2694  /* Execute entry. */
2696 
2697  if (record_full_list->next)
2699  else
2700  break;
2701  }
2702 
2703  /* Reverse execute to cur_record_full_list. */
2704  while (1)
2705  {
2706  /* Check for beginning and end of log. */
2707  if (record_full_list == cur_record_full_list)
2708  break;
2709 
2711 
2712  if (record_full_list->prev)
2714  }
2715 
2716  unlink_file.keep ();
2717 
2718  /* Succeeded. */
2719  printf_filtered (_("Saved core file %s with execution log.\n"),
2720  recfilename);
2721 }
2722 
2723 /* record_full_goto_insn -- rewind the record log (forward or backward,
2724  depending on DIR) to the given entry, changing the program state
2725  correspondingly. */
2726 
2727 static void
2729  enum exec_direction_kind dir)
2730 {
2731  scoped_restore restore_operation_disable
2733  struct regcache *regcache = get_current_regcache ();
2734  struct gdbarch *gdbarch = regcache->arch ();
2735 
2736  /* Assume everything is valid: we will hit the entry,
2737  and we will not hit the end of the recording. */
2738 
2739  if (dir == EXEC_FORWARD)
2741 
2742  do
2743  {
2745  if (dir == EXEC_REVERSE)
2747  else
2749  } while (record_full_list != entry);
2750 }
2751 
2752 /* Alias for "target record-full". */
2753 
2754 static void
2755 cmd_record_full_start (const char *args, int from_tty)
2756 {
2757  execute_command ("target record-full", from_tty);
2758 }
2759 
2760 static void
2761 set_record_full_insn_max_num (const char *args, int from_tty,
2762  struct cmd_list_element *c)
2763 {
2765  {
2766  /* Count down record_full_insn_num while releasing records from list. */
2768  {
2771  }
2772  }
2773 }
2774 
2775 /* The "set record full" command. */
2776 
2777 static void
2778 set_record_full_command (const char *args, int from_tty)
2779 {
2780  printf_unfiltered (_("\"set record full\" must be followed "
2781  "by an appropriate subcommand.\n"));
2782  help_list (set_record_full_cmdlist, "set record full ", all_commands,
2783  gdb_stdout);
2784 }
2785 
2786 /* The "show record full" command. */
2787 
2788 static void
2789 show_record_full_command (const char *args, int from_tty)
2790 {
2791  cmd_show_list (show_record_full_cmdlist, from_tty, "");
2792 }
2793 
2794 void
2796 {
2797  struct cmd_list_element *c;
2798 
2799  /* Init record_full_first. */
2800  record_full_first.prev = NULL;
2801  record_full_first.next = NULL;
2803 
2809 
2811  _("Start full execution recording."), &record_full_cmdlist,
2812  "record full ", 0, &record_cmdlist);
2813 
2815  _("Restore the execution log from a file.\n\
2816 Argument is filename. File must be created with 'record save'."),
2819 
2820  /* Deprecate the old version without "full" prefix. */
2821  c = add_alias_cmd ("restore", "full restore", class_obscure, 1,
2822  &record_cmdlist);
2824  deprecate_cmd (c, "record full restore");
2825 
2827  _("Set record options"), &set_record_full_cmdlist,
2828  "set record full ", 0, &set_record_cmdlist);
2829 
2831  _("Show record options"), &show_record_full_cmdlist,
2832  "show record full ", 0, &show_record_cmdlist);
2833 
2834  /* Record instructions number limit command. */
2835  add_setshow_boolean_cmd ("stop-at-limit", no_class,
2837 Set whether record/replay stops when record/replay buffer becomes full."), _("\
2838 Show whether record/replay stops when record/replay buffer becomes full."),
2839  _("Default is ON.\n\
2840 When ON, if the record/replay buffer becomes full, ask user what to do.\n\
2841 When OFF, if the record/replay buffer becomes full,\n\
2842 delete the oldest recorded instruction to make room for each new one."),
2843  NULL, NULL,
2845 
2846  c = add_alias_cmd ("stop-at-limit", "full stop-at-limit", no_class, 1,
2848  deprecate_cmd (c, "set record full stop-at-limit");
2849 
2850  c = add_alias_cmd ("stop-at-limit", "full stop-at-limit", no_class, 1,
2852  deprecate_cmd (c, "show record full stop-at-limit");
2853 
2854  add_setshow_uinteger_cmd ("insn-number-max", no_class,
2856  _("Set record/replay buffer limit."),
2857  _("Show record/replay buffer limit."), _("\
2858 Set the maximum number of instructions to be stored in the\n\
2859 record/replay buffer. A value of either \"unlimited\" or zero means no\n\
2860 limit. Default is 200000."),
2862  NULL, &set_record_full_cmdlist,
2864 
2865  c = add_alias_cmd ("insn-number-max", "full insn-number-max", no_class, 1,
2867  deprecate_cmd (c, "set record full insn-number-max");
2868 
2869  c = add_alias_cmd ("insn-number-max", "full insn-number-max", no_class, 1,
2871  deprecate_cmd (c, "show record full insn-number-max");
2872 
2873  add_setshow_boolean_cmd ("memory-query", no_class,
2875 Set whether query if PREC cannot record memory change of next instruction."),
2876  _("\
2877 Show whether query if PREC cannot record memory change of next instruction."),
2878  _("\
2879 Default is OFF.\n\
2880 When ON, query if PREC cannot record memory change of next instruction."),
2881  NULL, NULL,
2884 
2885  c = add_alias_cmd ("memory-query", "full memory-query", no_class, 1,
2887  deprecate_cmd (c, "set record full memory-query");
2888 
2889  c = add_alias_cmd ("memory-query", "full memory-query", no_class, 1,
2891  deprecate_cmd (c, "show record full memory-query");
2892 }
struct gdbarch * target_gdbarch(void)
Definition: gdbarch.c:5467
int hardware_watchpoint_inserted_in_range(const address_space *aspace, CORE_ADDR addr, ULONGEST len)
Definition: breakpoint.c:4156
#define target_can_async_p()
Definition: target.h:1778
int gdbarch_software_single_step_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:3241
void add_target(struct target_ops *t)
Definition: target.c:395
struct cmd_list_element * show_record_cmdlist
Definition: record.c:53
static struct record_full_core_buf_entry * record_full_core_buf_list
Definition: record-full.c:174
static enum exec_direction_kind record_full_execution_direction(struct target_ops *self)
Definition: record-full.c:1778
static struct cmd_list_element * set_record_full_cmdlist
Definition: record-full.c:227
Definition: record-full.c:143
void(* to_delete_record)(struct target_ops *) TARGET_DEFAULT_NORETURN(tcomplain())
Definition: target.h:1167
static struct record_full_entry * record_full_arch_list_head
Definition: record-full.c:195
int insert_single_step_breakpoints(struct gdbarch *gdbarch)
Definition: breakpoint.c:14623
int(* to_supports_stopped_by_hw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:499
static void record_full_core_store_registers(struct target_ops *ops, struct regcache *regcache, int regno)
Definition: record-full.c:2052
static int record_full_core_has_execution(struct target_ops *ops, ptid_t the_ptid)
Definition: record-full.c:2184
const char * to_longname
Definition: target.h:416
struct frame_info * get_selected_frame(const char *message)
Definition: frame.c:1638
void(* to_goto_bookmark)(struct target_ops *, const gdb_byte *, int) TARGET_DEFAULT_NORETURN(tcomplain())
Definition: target.h:693
static int record_full_is_replaying(struct target_ops *self, ptid_t ptid)
Definition: record-full.c:1846
void(* to_goto_record_begin)(struct target_ops *) TARGET_DEFAULT_NORETURN(tcomplain())
Definition: target.h:1184
static void record_full_goto_end(struct target_ops *self)
Definition: record-full.c:1908
static void record_full_arch_list_cleanups(void *ignore)
Definition: record-full.c:557
void(* to_save_record)(struct target_ops *, const char *filename) TARGET_DEFAULT_NORETURN(tcomplain())
Definition: target.h:1162
int gdbarch_process_record_signal(struct gdbarch *gdbarch, struct regcache *regcache, enum gdb_signal signal)
Definition: gdbarch.c:4151
union record_full_reg_entry::@148 u
static ptid_t record_full_wait_1(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options)
Definition: record-full.c:1030
bfd_vma CORE_ADDR
Definition: common-types.h:41
static void record_full_open(const char *name, int from_tty)
Definition: record-full.c:829
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
Definition: target.c:1451
void xfree(void *)
gdb_byte buf[sizeof(gdb_byte *)]
Definition: record-full.c:91
static void record_full_message(struct regcache *regcache, enum gdb_signal signal)
Definition: record-full.c:569
struct address_space * address_space
Definition: record-full.c:1570
int record_full_arch_list_add_reg(struct regcache *regcache, int regnum)
Definition: record-full.c:468
static void record_full_restore(void)
Definition: record-full.c:2321
struct target_section * p
Definition: record-full.c:166
void record_goto(const char *arg)
Definition: record.c:379
Definition: record-full.c:81
void warning(const char *fmt,...)
Definition: errors.c:26
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *cmd, const char *replacement)
Definition: cli-decode.c:292
regcache(gdbarch *gdbarch)
Definition: regcache.h:235
int query(const char *ctlstr,...)
Definition: utils.c:1063
int gdbarch_process_record(struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr)
Definition: gdbarch.c:4127
struct cmd_list_element * set_record_cmdlist
Definition: record.c:52
int mem_entry_not_accessible
Definition: record-full.c:87
static uint64_t netorder64(uint64_t input)
Definition: record-full.c:2300
void push_target(struct target_ops *t)
Definition: target.c:642
void(* to_record_stop_replaying)(struct target_ops *) TARGET_DEFAULT_IGNORE()
Definition: target.h:1180
int(* to_insert_breakpoint)(struct target_ops *, struct gdbarch *, struct bp_target_info *) TARGET_DEFAULT_FUNC(memory_insert_breakpoint)
Definition: target.h:466
static void record_full_exec_insn(struct regcache *regcache, struct gdbarch *gdbarch, struct record_full_entry *entry)
Definition: record-full.c:676
int build_section_table(struct bfd *some_bfd, struct target_section **start, struct target_section **end)
Definition: exec.c:509
void record_preopen(void)
Definition: record.c:86
static struct target_ops record_full_core_ops
Definition: record-full.c:211
void record_disconnect(struct target_ops *t, const char *args, int from_tty)
Definition: record.c:175
int unpush_target(struct target_ops *t)
Definition: target.c:689
void * memset(T *s, int c, size_t n)=delete
struct thread_info * inferior_thread(void)
Definition: thread.c:90
void delete_async_event_handler(async_event_handler **async_handler_ptr)
Definition: event-loop.c:1075
unsigned int record_debug
Definition: record.c:33
void target_pass_signals(int numsigs, unsigned char *pass_signals)
Definition: target.c:2251
#define VEC_unordered_remove(T, V, I)
Definition: vec.h:367
void(* to_close)(struct target_ops *)
Definition: target.h:431
void mark_async_event_handler(async_event_handler *async_handler_ptr)
Definition: event-loop.c:1036
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition: cli-decode.c:262
#define DEFAULT_RECORD_FULL_INSN_MAX_NUM
Definition: record-full.c:63
gdb_byte * ptr
Definition: record-full.c:101
static void init_record_full_ops(void)
Definition: record-full.c:1944
struct record_full_reg_entry reg
Definition: record-full.c:151
static void set_record_full_insn_max_num(const char *args, int from_tty, struct cmd_list_element *c)
Definition: record-full.c:2761
int yquery(const char *ctlstr,...)
Definition: utils.c:1046
void target_async(int enable)
Definition: target.c:3860
static void cmd_record_full_restore(const char *args, int from_tty)
Definition: record-full.c:2512
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition: completer.c:152
static int record_full_supports_stopped_by_sw_breakpoint(struct target_ops *ops)
Definition: record-full.c:1368
#define VEC_safe_push(T, V, O)
Definition: vec.h:276
static void record_full_sig_handler(int signo)
Definition: record-full.c:991
static int record_full_can_execute_reverse(struct target_ops *self)
Definition: record-full.c:1717
static int record_full_stopped_by_sw_breakpoint(struct target_ops *ops)
Definition: record-full.c:1359
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition: gdbarch.c:2039
void target_fetch_registers(struct regcache *regcache, int regno)
Definition: target.c:3437
void(* to_info_record)(struct target_ops *) TARGET_DEFAULT_IGNORE()
Definition: target.h:1158
bfd_byte * buf
Definition: record-full.c:167
static void record_full_list_release_first(void)
Definition: record-full.c:393
static int record_full_core_remove_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt, enum remove_bp_reason reason)
Definition: record-full.c:2173
#define _(String)
Definition: gdb_locale.h:35
static void record_full_goto_entry(struct record_full_entry *p)
Definition: record-full.c:1866
union record_full_mem_entry::@147 u
DEF_VEC_P(record_full_breakpoint_p)
static unsigned int record_full_insn_num
Definition: record-full.c:204
#define target_stopped_by_watchpoint()
Definition: target.h:1876
int record_full_is_used(void)
Definition: record-full.c:216
#define END_CATCH
unsigned short len
Definition: record-full.c:98
struct regcache * get_current_regcache(void)
Definition: regcache.c:446
static void ours()
Definition: target.c:483
gdb_byte buf[2 *sizeof(gdb_byte *)]
Definition: record-full.c:102
gdb_bfd_ref_ptr create_gcore_bfd(const char *filename)
Definition: gcore.c:55
void printf_filtered(const char *format,...)
Definition: utils.c:2045
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:2745
static void record_full_reg_release(struct record_full_entry *rec)
Definition: record-full.c:262
record_full_type
Definition: record-full.c:112
static unsigned int record_full_insn_max_num
Definition: record-full.c:202
#define XNEW(T)
Definition: poison.h:109
void execute_command(const char *, int)
Definition: top.c:540
enum gdb_signal sigval
Definition: record-full.c:108
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
Definition: cli-decode.c:367
static void record_full_mem_release(struct record_full_entry *rec)
Definition: record-full.c:290
scoped_restore_tmpl< T > make_scoped_restore(T *var)
void null_cleanup(void *arg)
Definition: cleanups.c:294
#define TRY
void add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:723
const char *const name
Definition: aarch64-tdep.c:76
static enum target_xfer_status record_full_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
Definition: record-full.c:1499
int(* to_record_is_replaying)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
Definition: target.h:1171
scoped_restore_tmpl< int > record_full_gdb_operation_disable_set(void)
Definition: record-full.c:662
#define VEC_iterate(T, V, I, P)
Definition: vec.h:181
#define OPS_MAGIC
Definition: target.h:1270
static int record_full_resume_step
Definition: record-full.c:905
static void record_full_end_release(struct record_full_entry *rec)
Definition: record-full.c:314
static struct record_full_entry * record_full_arch_list_tail
Definition: record-full.c:196
enum exec_direction_kind execution_direction
Definition: infrun.c:9088
#define CATCH(EXCEPTION, MASK)
static bool record_full_message_wrapper_safe(struct regcache *regcache, enum gdb_signal signal)
Definition: record-full.c:639
void inferior_event_handler(enum inferior_event_type event_type, gdb_client_data client_data)
Definition: inf-loop.c:37
static struct cmd_list_element * show_record_full_cmdlist
Definition: record-full.c:228
void observer_notify_record_changed(struct inferior *inferior, int started, const char *method, const char *format)
static void record_full_open_1(const char *name, int from_tty)
Definition: record-full.c:805
int record_read_memory(struct gdbarch *gdbarch, CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: record.c:139
int(* to_record_will_replay)(struct target_ops *, ptid_t ptid, int dir) TARGET_DEFAULT_RETURN(0)
Definition: target.h:1176
static void record_full_arch_list_add(struct record_full_entry *rec)
Definition: record-full.c:423
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
Definition: cli-decode.c:160
struct record_full_end_entry end
Definition: record-full.c:155
static void cmd_record_full_start(const char *args, int from_tty)
Definition: record-full.c:2755
Definition: ptid.h:35
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2018
struct record_full_mem_entry mem
Definition: record-full.c:153
int(* to_supports_stopped_by_sw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:486
static void record_full_async(struct target_ops *ops, int enable)
Definition: record-full.c:895
void(* to_resume)(struct target_ops *, ptid_t, int TARGET_DEBUG_PRINTER(target_debug_print_step), enum gdb_signal) TARGET_DEFAULT_NORETURN(noprocess())
Definition: target.h:447
void exception_print(struct ui_file *file, struct gdb_exception e)
Definition: exceptions.c:109
VEC(record_full_breakpoint_p)
Definition: record-full.c:1584
#define gdb_assert_not_reached(message)
Definition: gdb_assert.h:55
#define TARGET_WNOHANG
Definition: wait.h:28
static void record_full_list_release(struct record_full_entry *rec)
Definition: record-full.c:344
async_event_handler * create_async_event_handler(async_event_handler_func *proc, gdb_client_data client_data)
Definition: event-loop.c:1013
static void record_full_commit_resume(struct target_ops *ops)
Definition: record-full.c:980
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
Definition: cleanups.c:116
static void record_full_store_registers(struct target_ops *ops, struct regcache *regcache, int regno)
Definition: record-full.c:1440
target_xfer_status
Definition: target.h:206
int(* to_has_execution)(struct target_ops *, ptid_t)
Definition: target.h:661
Definition: gdbtypes.h:749
void iterate_over_bp_locations(walk_bp_location_callback callback)
Definition: breakpoint.c:2866
struct target_ops * find_record_target(void)
Definition: record.c:63
static enum record_full_type record_full_entry_release(struct record_full_entry *rec)
Definition: record-full.c:323
int len
Definition: record-full.c:84
static ptid_t record_full_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options)
Definition: record-full.c:1321
#define enable()
Definition: ser-go32.c:239
exec_direction_kind
Definition: infrun.h:67
void _initialize_record_full(void)
Definition: record-full.c:2795
struct gdbarch * get_current_arch(void)
Definition: arch-utils.c:798
static const char * type
Definition: language.c:113
void record_detach(struct target_ops *t, const char *args, int from_tty)
Definition: record.c:190
static void record_full_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal signal)
Definition: record-full.c:931
void write_gcore_file(bfd *obfd)
Definition: gcore.c:115
struct record_full_breakpoint * record_full_breakpoint_p
Definition: record-full.c:1579
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
Definition: gdbarch.c:2282
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
Definition: gnu-nat.c:1822
const char * to_doc
Definition: target.h:417
CORE_ADDR addr
Definition: record-full.c:83
static void record_full_info(struct target_ops *self)
Definition: record-full.c:1792
struct record_full_core_buf_entry * prev
Definition: record-full.c:165
Definition: record-full.c:163
int gdbarch_process_record_signal_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:4144
CORE_ADDR endaddr
Definition: target.h:2318
ptid_t ptid
Definition: gdbthread.h:219
union record_full_entry::@149 u
#define target_has_execution
Definition: target.h:1756
enum record_full_type type
Definition: record-full.c:147
enum target_xfer_status(* to_xfer_partial)(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
Definition: target.h:739
static struct record_full_entry record_full_first
Definition: record-full.c:193
static void record_full_wait_cleanups(void *ignore)
Definition: record-full.c:1005
static void show_record_full_command(const char *args, int from_tty)
Definition: record-full.c:2789
int regnum
Definition: aarch64-tdep.c:77
void printf_unfiltered(const char *format,...)
Definition: utils.c:2056
CORE_ADDR placed_address
Definition: breakpoint.h:248
gdb_byte * ptr
Definition: record-full.c:90
static gdb_byte * record_full_core_regbuf
Definition: record-full.c:171
static void record_full_core_fetch_registers(struct target_ops *ops, struct regcache *regcache, int regno)
Definition: record-full.c:2023
void(* to_detach)(struct target_ops *ops, const char *, int) TARGET_DEFAULT_IGNORE()
Definition: target.h:443
ULONGEST insn_num
Definition: record-full.c:109
static void record_full_core_open_1(const char *name, int from_tty)
Definition: record-full.c:775
struct record_full_entry * next
Definition: record-full.c:146
void(* to_async)(struct target_ops *, int) TARGET_DEFAULT_NORETURN(tcomplain())
Definition: target.h:670
#define RECORD_FULL_FILE_MAGIC
Definition: record-full.c:68
struct bfd_section * the_bfd_section
Definition: target.h:2320
static enum exec_direction_kind record_full_execution_dir
Definition: record-full.c:926
static struct target_section * record_full_core_start
Definition: record-full.c:172
void * xmalloc(YYSIZE_T)
static int record_full_stopped_by_hw_breakpoint(struct target_ops *ops)
Definition: record-full.c:1376
int record_check_stopped_by_breakpoint(const address_space *aspace, CORE_ADDR pc, enum target_stop_reason *reason)
Definition: record.c:237
int record_full_memory_query
Definition: record-full.c:161
int thread_has_single_step_breakpoints_set(struct thread_info *tp)
Definition: thread.c:148
target_object
Definition: target.h:132
void * gdb_client_data
Definition: event-loop.h:70
record_method
Definition: record.h:41
const address_space * aspace() const
Definition: regcache.h:257
void cmd_show_list(struct cmd_list_element *list, int from_tty, const char *prefix)
Definition: cli-setshow.c:657
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *old, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition: cli-decode.c:306
CORE_ADDR addr
Definition: target.h:2317
Definition: regdef.h:22
void record_mourn_inferior(struct target_ops *t)
Definition: record.c:205
void(* to_commit_resume)(struct target_ops *) TARGET_DEFAULT_IGNORE()
Definition: target.h:451
int record_full_arch_list_add_mem(CORE_ADDR addr, int len)
Definition: record-full.c:491
#define gdb_assert(expr)
Definition: gdb_assert.h:32
void(* to_disconnect)(struct target_ops *, const char *, int) TARGET_DEFAULT_NORETURN(tcomplain())
Definition: target.h:445
static enum target_xfer_status record_full_core_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
Definition: record-full.c:2066
void regcache_invalidate(struct regcache *regcache, int regnum)
Definition: regcache.c:378
void print_stack_frame(struct frame_info *, int print_level, enum print_what print_what, int set_current_sal)
Definition: stack.c:165
void add_deprecated_target_alias(struct target_ops *t, const char *alias)
Definition: target.c:403
static int record_full_core_insert_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition: record-full.c:2163
void record_kill(struct target_ops *t)
Definition: record.c:221
void core_file_command(const char *filename, int from_tty)
Definition: corefile.c:64
struct cmd_list_element * record_cmdlist
Definition: record.c:50
static int record_full_insert_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition: record-full.c:1620
bfd_byte gdb_byte
Definition: common-types.h:38
enum exec_direction_kind(* to_execution_direction)(struct target_ops *) TARGET_DEFAULT_FUNC(default_execution_direction)
Definition: target.h:828
static int record_full_gdb_operation_disable
Definition: record-full.c:659
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
Definition: cli-decode.c:1071
void discard_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:212
int non_stop
Definition: infrun.c:204
static enum target_stop_reason record_full_stop_reason
Definition: record-full.c:669
static struct target_section * record_full_core_end
Definition: record-full.c:173
static void record_full_goto_bookmark(struct target_ops *self, const gdb_byte *raw_bookmark, int from_tty)
Definition: record-full.c:1749
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
Definition: target.h:457
void(* to_mourn_inferior)(struct target_ops *) TARGET_DEFAULT_FUNC(default_mourn_inferior)
Definition: target.h:606
#define ALL_NON_EXITED_THREADS(T)
Definition: gdbthread.h:490
#define gdb_stderr
Definition: utils.h:344
#define XCNEW(T)
Definition: poison.h:121
enum record_method(* to_record_method)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(RECORD_METHOD_NONE)
Definition: target.h:1150
static struct target_ops record_full_ops
Definition: record-full.c:210
enum register_status regcache_raw_read(struct regcache *regcache, int regnum, gdb_byte *buf)
Definition: regcache.c:565
unsigned short num
Definition: record-full.c:97
static void record_full_core_kill(struct target_ops *ops)
Definition: record-full.c:2012
static struct cmd_list_element * record_full_cmdlist
Definition: record-full.c:231
void(* to_kill)(struct target_ops *) TARGET_DEFAULT_NORETURN(noprocess())
Definition: target.h:570
CORE_ADDR regcache_read_pc(struct regcache *regcache)
Definition: regcache.c:1229
gdb_byte *(* to_get_bookmark)(struct target_ops *, const char *, int) TARGET_DEFAULT_NORETURN(tcomplain())
Definition: target.h:690
static gdb_byte * record_full_get_bookmark(struct target_ops *self, const char *args, int from_tty)
Definition: record-full.c:1725
ptid_t inferior_ptid
Definition: infcmd.c:94
enum strata to_stratum
Definition: target.h:656
int(* to_stopped_by_sw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:483
static void record_full_delete(struct target_ops *self)
Definition: record-full.c:1838
static void record_full_list_release_following(struct record_full_entry *rec)
Definition: record-full.c:370
void(* to_goto_record_end)(struct target_ops *) TARGET_DEFAULT_NORETURN(tcomplain())
Definition: target.h:1188
enum record_method record_full_record_method(struct target_ops *self, ptid_t ptid)
Definition: record-full.c:1786
static struct record_full_entry * record_full_mem_alloc(CORE_ADDR addr, int len)
Definition: record-full.c:273
void(* to_open)(const char *, int)
Definition: target.h:426
int offset
Definition: agent.c:65
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:569
void registers_changed(void)
Definition: regcache.c:522
static ULONGEST record_full_insn_count
Definition: record-full.c:207
#define VEC_free(T, V)
Definition: vec.h:196
static gdb_byte * record_full_get_loc(struct record_full_entry *rec)
Definition: record-full.c:445
gdbarch * arch() const
Definition: regcache.c:221
enum register_status regcache_cooked_read(struct regcache *regcache, int regnum, gdb_byte *buf)
Definition: regcache.c:661
CORE_ADDR stop_pc
Definition: infcmd.c:98
int(* to_remove_breakpoint)(struct target_ops *, struct gdbarch *, struct bp_target_info *, enum remove_bp_reason) TARGET_DEFAULT_FUNC(memory_remove_breakpoint)
Definition: target.h:469
struct record_full_entry * prev
Definition: record-full.c:145
Definition: record-full.c:106
int(* to_stopped_by_watchpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:531
T * get() const
Definition: gdb_ref_ptr.h:130
static void bfdcore_write(bfd *obfd, asection *osec, void *buf, int len, int *offset)
Definition: record-full.c:2496
int gdbarch_process_record_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:4120
static void record_full_goto_begin(struct target_ops *self)
Definition: record-full.c:1894
static struct record_full_entry * record_full_reg_alloc(struct regcache *regcache, int regnum)
Definition: record-full.c:244
static int record_full_resumed
Definition: record-full.c:910
int(* to_stopped_by_hw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:496
static int record_full_remove_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt, enum remove_bp_reason reason)
Definition: record-full.c:1674
gdb::def_vector< gdb_byte > byte_vector
Definition: byte-vector.h:58
struct inferior * current_inferior(void)
Definition: inferior.c:58
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
Definition: regcache.c:1004
const char * to_shortname
Definition: target.h:415
void delete_single_step_breakpoints(struct thread_info *tp)
Definition: thread.c:126
unsigned long long ULONGEST
Definition: common-types.h:53
static int record_full_supports_stopped_by_hw_breakpoint(struct target_ops *ops)
Definition: record-full.c:1385
static void record_full_goto_insn(struct record_full_entry *entry, enum exec_direction_kind dir)
Definition: record-full.c:2728
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition: corelow.c:879
static void set_record_full_command(const char *args, int from_tty)
Definition: record-full.c:2778
int to_magic
Definition: target.h:1261
char * savestring(const char *ptr, size_t len)
Definition: common-utils.c:226
int register_size(struct gdbarch *gdbarch, int regnum)
Definition: regcache.c:164
void clear_async_event_handler(async_event_handler *async_handler_ptr)
Definition: event-loop.c:1044
static struct record_full_entry * record_full_end_alloc(void)
Definition: record-full.c:301
static int record_full_will_replay(struct target_ops *self, ptid_t ptid, int dir)
Definition: record-full.c:1854
static void init_record_full_core_ops(void)
Definition: record-full.c:2190
#define gdb_stdlog
Definition: utils.h:349
#define RECORD_FULL_IS_REPLAY
Definition: record-full.c:65
void handle_sigint(int sig)
Definition: event-top.c:967
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
Definition: regcache.c:1085
static void record_full_close(struct target_ops *self)
Definition: record-full.c:860
static void record_full_stop_replaying(struct target_ops *self)
Definition: record-full.c:1938
static struct async_event_handler * record_full_async_inferior_event_token
Definition: record-full.c:764
bfd * core_bfd
Definition: corefile.c:54
static void record_full_check_insn_num(void)
Definition: record-full.c:540
static int record_full_get_sig
Definition: record-full.c:986
void reinit_frame_cache(void)
Definition: frame.c:1809
static void record_full_core_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal signal)
Definition: record-full.c:1996
int(* to_stopped_data_address)(struct target_ops *, CORE_ADDR *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:535
struct address_space * placed_address_space
Definition: breakpoint.h:241
static int record_full_stopped_data_address(struct target_ops *ops, CORE_ADDR *addr_p)
Definition: record-full.c:1348
static void record_full_goto(struct target_ops *self, ULONGEST target_insn)
Definition: record-full.c:1924
static void bfdcore_read(bfd *obfd, asection *osec, void *buf, int len, int *offset)
Definition: record-full.c:2287
static void record_full_core_prepare_to_store(struct target_ops *self, struct regcache *regcache)
Definition: record-full.c:2044
void(* to_prepare_to_store)(struct target_ops *, struct regcache *) TARGET_DEFAULT_NORETURN(noprocess())
Definition: target.h:461
void(* to_store_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
Definition: target.h:459
#define target_thread_architecture(ptid)
Definition: target.h:1844
static int record_full_stopped_by_watchpoint(struct target_ops *ops)
Definition: record-full.c:1339
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_FUNC(default_target_wait)
Definition: target.h:453
static void record_full_async_inferior_event_handler(gdb_client_data data)
Definition: record-full.c:767
static uint32_t netorder32(uint32_t input)
Definition: record-full.c:2310
int record_full_arch_list_add_end(void)
Definition: record-full.c:522
Definition: record-full.c:95
void set_executing(ptid_t ptid, int executing)
Definition: thread.c:991
target_stop_reason
Definition: waitstatus.h:127
void error(const char *fmt,...)
Definition: errors.c:38
ptid_t minus_one_ptid
Definition: ptid.c:26
remove_bp_reason
Definition: breakpoint.h:47
static void record_full_registers_change(struct regcache *regcache, int regnum)
Definition: record-full.c:1393
struct target_ops * beneath
Definition: target.h:414
int(* to_can_execute_reverse)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:822
void do_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:174
void regcache_cooked_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
Definition: regcache.c:873
static int record_full_stop_at_limit
Definition: record-full.c:199
static void record_full_init_record_breakpoints(void)
Definition: record-full.c:1608
static struct record_full_entry * record_full_list
Definition: record-full.c:194
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition: defs.h:604
#define gdb_stdout
Definition: utils.h:340
void(* to_goto_record)(struct target_ops *, ULONGEST insn) TARGET_DEFAULT_NORETURN(tcomplain())
Definition: target.h:1192
static void record_full_save(struct target_ops *self, const char *recfilename)
Definition: record-full.c:2522