2016-02-18 07:11:59 -08:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* OCaml *)
|
|
|
|
(* *)
|
|
|
|
(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* OCaml port by John Malecki and Xavier Leroy *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. This file is distributed under the terms of *)
|
|
|
|
(* the GNU Lesser General Public License version 2.1, with the *)
|
|
|
|
(* special exception on linking described in the file LICENSE. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
1996-11-29 08:55:09 -08:00
|
|
|
|
|
|
|
open Instruct
|
2000-03-06 14:12:09 -08:00
|
|
|
open Format
|
1996-11-29 08:55:09 -08:00
|
|
|
open Debugcom
|
|
|
|
open Checkpoints
|
|
|
|
open Events
|
|
|
|
open Symbols
|
|
|
|
open Frames
|
2010-01-20 08:26:46 -08:00
|
|
|
open Source
|
1996-11-29 08:55:09 -08:00
|
|
|
open Show_source
|
|
|
|
open Breakpoints
|
2014-01-23 01:07:09 -08:00
|
|
|
open Parameters
|
1996-11-29 08:55:09 -08:00
|
|
|
|
|
|
|
(* Display information about the current event. *)
|
2000-03-06 14:12:09 -08:00
|
|
|
let show_current_event ppf =
|
2012-10-17 05:26:42 -07:00
|
|
|
fprintf ppf "Time: %Li" (current_time ());
|
1996-11-29 08:55:09 -08:00
|
|
|
(match current_pc () with
|
2000-03-06 14:12:09 -08:00
|
|
|
| Some pc ->
|
2012-10-17 05:26:42 -07:00
|
|
|
fprintf ppf " - pc: %i" pc
|
1996-11-29 08:55:09 -08:00
|
|
|
| _ -> ());
|
|
|
|
update_current_event ();
|
|
|
|
reset_frame ();
|
|
|
|
match current_report () with
|
2000-03-06 14:12:09 -08:00
|
|
|
| None ->
|
|
|
|
fprintf ppf "@.Beginning of program.@.";
|
1996-11-29 08:55:09 -08:00
|
|
|
show_no_point ()
|
2005-08-25 08:35:16 -07:00
|
|
|
| Some {rep_type = (Event | Breakpoint); rep_program_pointer = pc} ->
|
|
|
|
let ev = get_current_event () in
|
|
|
|
fprintf ppf " - module %s@." ev.ev_module;
|
1997-05-19 08:42:21 -07:00
|
|
|
(match breakpoints_at_pc pc with
|
2000-03-06 14:12:09 -08:00
|
|
|
| [] ->
|
1997-05-19 08:42:21 -07:00
|
|
|
()
|
|
|
|
| [breakpoint] ->
|
2012-10-17 05:26:42 -07:00
|
|
|
fprintf ppf "Breakpoint: %i@." breakpoint
|
1997-05-19 08:42:21 -07:00
|
|
|
| breakpoints ->
|
2012-10-17 05:26:42 -07:00
|
|
|
fprintf ppf "Breakpoints: %a@."
|
2000-03-06 14:12:09 -08:00
|
|
|
(fun ppf l ->
|
|
|
|
List.iter
|
|
|
|
(function x -> fprintf ppf "%i " x) l)
|
2002-10-29 09:53:24 -08:00
|
|
|
(List.sort compare breakpoints));
|
2005-08-25 08:35:16 -07:00
|
|
|
show_point ev true
|
1996-11-29 08:55:09 -08:00
|
|
|
| Some {rep_type = Exited} ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "@.Program exit.@.";
|
1996-11-29 08:55:09 -08:00
|
|
|
show_no_point ()
|
|
|
|
| Some {rep_type = Uncaught_exc} ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf
|
|
|
|
"@.Program end.@.\
|
|
|
|
@[Uncaught exception:@ %a@]@."
|
1997-03-23 07:23:31 -08:00
|
|
|
Printval.print_exception (Debugcom.Remote_value.accu ());
|
1996-11-29 08:55:09 -08:00
|
|
|
show_no_point ()
|
|
|
|
| Some {rep_type = Trap_barrier} ->
|
1997-05-19 08:42:21 -07:00
|
|
|
(* Trap_barrier not visible outside *)
|
|
|
|
(* of module `time_travel'. *)
|
1996-11-29 08:55:09 -08:00
|
|
|
Misc.fatal_error "Show_information.show_current_event"
|
|
|
|
|
|
|
|
(* Display short information about one frame. *)
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let show_one_frame framenum ppf event =
|
2010-01-20 08:26:46 -08:00
|
|
|
let pos = Events.get_pos event in
|
|
|
|
let cnum =
|
|
|
|
try
|
|
|
|
let buffer = get_buffer pos event.ev_module in
|
|
|
|
snd (start_and_cnum buffer pos)
|
|
|
|
with _ -> pos.Lexing.pos_cnum in
|
2014-01-23 01:07:09 -08:00
|
|
|
if !machine_readable then
|
|
|
|
fprintf ppf "#%i Pc: %i %s char %i@."
|
|
|
|
framenum event.ev_pos event.ev_module
|
|
|
|
cnum
|
|
|
|
else
|
|
|
|
fprintf ppf "#%i %s %s:%i:%i@."
|
|
|
|
framenum event.ev_module
|
|
|
|
pos.Lexing.pos_fname pos.Lexing.pos_lnum
|
|
|
|
(pos.Lexing.pos_cnum - pos.Lexing.pos_bol + 1)
|
1996-11-29 08:55:09 -08:00
|
|
|
|
|
|
|
(* Display information about the current frame. *)
|
|
|
|
(* --- `select frame' must have succeded before calling this function. *)
|
2000-03-06 14:12:09 -08:00
|
|
|
let show_current_frame ppf selected =
|
1996-11-29 08:55:09 -08:00
|
|
|
match !selected_event with
|
2000-03-06 14:12:09 -08:00
|
|
|
| None ->
|
|
|
|
fprintf ppf "@.No frame selected.@."
|
1996-11-29 08:55:09 -08:00
|
|
|
| Some sel_ev ->
|
2000-03-06 14:12:09 -08:00
|
|
|
show_one_frame !current_frame ppf sel_ev;
|
1996-11-29 08:55:09 -08:00
|
|
|
begin match breakpoints_at_pc sel_ev.ev_pos with
|
2000-03-06 14:12:09 -08:00
|
|
|
| [] -> ()
|
1996-11-29 08:55:09 -08:00
|
|
|
| [breakpoint] ->
|
2012-10-17 05:26:42 -07:00
|
|
|
fprintf ppf "Breakpoint: %i@." breakpoint
|
1996-11-29 08:55:09 -08:00
|
|
|
| breakpoints ->
|
2012-10-17 05:26:42 -07:00
|
|
|
fprintf ppf "Breakpoints: %a@."
|
2000-03-06 14:12:09 -08:00
|
|
|
(fun ppf l ->
|
|
|
|
List.iter (function x -> fprintf ppf "%i " x) l)
|
2002-10-29 09:53:24 -08:00
|
|
|
(List.sort compare breakpoints);
|
1996-11-29 08:55:09 -08:00
|
|
|
end;
|
2005-08-25 08:35:16 -07:00
|
|
|
show_point sel_ev selected
|