[m-rev.] for review: line numbers for collect.
Erwan Jahier
Erwan.Jahier at irisa.fr
Wed Jul 4 00:17:22 AEST 2001
Estimated hours taken: 3
branches: main.
Make line numbers available for collect.
browser/collect_lib.m:
Minor comment fixes.
extras/morphine/source/collect.in:
extras/morphine/source/collect.op
Add the line number event attribute.
trace/mercury_trace.h:
trace/mercury_trace.c:
Add the line number as argument of MR_COLLECT_filter.
trace/mercury_trace_external.h:
trace/mercury_trace_external.c:
Put the code that computes the line number in a function called
MR_get_line_number() to be able to call it in mercury_trace.c
to avoid duplicated code.
Index: browser/collect_lib.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/collect_lib.m,v
retrieving revision 1.5
diff -u -d -u -r1.5 collect_lib.m
--- browser/collect_lib.m 2000/10/16 01:33:22 1.5
+++ browser/collect_lib.m 2001/07/03 14:11:43
@@ -19,7 +19,7 @@
% variable that will contain the result of the monitoring
% activity.
% 2) The predicate initialize/1 which initializes the
-% collecting variable. initialize/1 should have the
+% collecting variable. initialize/1 should respect the
% following declarations:
% :- pred initialize(collected_type).
% :- mode initialize(out) is det.
@@ -30,11 +30,11 @@
% stops; if it is set to `continue', it continues. If this
% variable is always set to `continue', the collecting will
% process until the last event is reached. filter/4 should
-% follow the following declarations:
+% respect the following declarations:
% :- pred filter(event, collected_type, collected_type,
% stop_or_continue).
% :- mode filter(in, di, uo, out) is det.
@@ -91,7 +91,7 @@
{ MaybeHandle = ok(Handle) },
%
% Look up the address of the C functions corresponding to the
- % initialize/1 and filter/14 predicates in the collect module.
+ % initialize/1 and filter/15 predicates in the collect module.
%
dl__sym(Handle, "ML_COLLECT_initialize", MaybeInitialize),
dl__sym(Handle, "ML_COLLECT_filter", MaybeFilter),
Index: extras/morphine/source/collect.in
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/morphine/source/collect.in,v
retrieving revision 1.4
diff -u -d -u -r1.4 collect.in
--- extras/morphine/source/collect.in 2000/09/12 16:43:33 1.4
+++ extras/morphine/source/collect.in 2001/07/03 14:11:46
@@ -15,10 +15,10 @@
:- pred filter(event_number, call_number, depth_number, trace_port_type,
pred_or_func, declared_module_name, defined_module_name, proc_name,
arity, mode_number, arguments, determinism, goal_path_string,
- collected_type, collected_type, char).
+ line_number, collected_type, collected_type, char).
-:- mode filter(in, in, in, in, in, in, in, in, in, in, in, in, in, acc_in, acc_out, out)
- is det.
+:- mode filter(in, in, in, in, in, in, in, in, in, in, in, in, in, in,
+ acc_in, acc_out, out) is det.
:- pred send_collect_result(collected_type, io__output_stream, io__state,
io__state).
@@ -30,7 +30,7 @@
:- implementation.
:- pragma export(initialize(out), "ML_COLLECT_initialize").
-:- pragma export(filter(in, in, in, in, in, in, in, in, in, in, in, in, in,
+:- pragma export(filter(in, in, in, in, in, in, in, in, in, in, in, in, in, in,
acc_in, acc_out, out), "ML_COLLECT_filter").
:- pragma export(send_collect_result(in, in, di, uo),
"ML_COLLECT_send_collect_result").
@@ -86,6 +86,8 @@
:- type goal_path_string == string.
+:- type line_number == int.
+
:- type procedure --->
proc(pred_or_func, declared_module_name, proc_name, arity, mode_number).
@@ -105,7 +107,8 @@
mode_number,
arguments,
determinism,
- goal_path_string).
+ goal_path_string,
+ line_number).
:- func chrono(event::in) = (event_number::out) is det.
:- func call(event::in) = (call_number::out) is det.
@@ -120,6 +123,7 @@
:- func proc(event::in) = (procedure::out) is det.
:- func determinism(event::in) = (determinism::out) is det.
:- func goal_path(event::in) = (goal_path_string::out) is det.
+:- func line_number(event::in) = (line_number::out) is det.
:- func arguments(event::in) = (arguments::out) is det.
:- pragma inline(chrono/1).
@@ -134,50 +138,54 @@
:- pragma inline(proc_mode_number/1).
:- pragma inline(determinism/1).
:- pragma inline(goal_path/1).
+:- pragma inline(line_number/1).
:- pragma inline(arguments/1).
chrono(Event) = Chrono :-
- Event = event(Chrono, _, _, _, _, _, _, _, _, _, _, _, _).
+ Event = event(Chrono, _, _, _, _, _, _, _, _, _, _, _, _, _).
call(Event) = Call :-
- Event = event(_, Call, _, _, _, _, _, _, _, _, _, _, _).
+ Event = event(_, Call, _, _, _, _, _, _, _, _, _, _, _, _).
depth(Event) = Depth :-
- Event = event(_, _, Depth, _, _, _, _, _, _, _, _, _, _).
+ Event = event(_, _, Depth, _, _, _, _, _, _, _, _, _, _, _).
port(Event) = Port :-
- Event = event(_, _, _, Port, _, _, _, _, _, _, _, _, _).
+ Event = event(_, _, _, Port, _, _, _, _, _, _, _, _, _, _).
proc_type(Event) = ProcType :-
- Event = event(_, _, _, _, ProcType, _, _, _, _, _, _, _, _).
+ Event = event(_, _, _, _, ProcType, _, _, _, _, _, _, _, _, _).
decl_module(Event) = DeclModule :-
- Event = event(_, _, _, _, _, DeclModule, _, _, _, _, _, _, _).
+ Event = event(_, _, _, _, _, DeclModule, _, _, _, _, _, _, _, _).
def_module(Event) = DefModule :-
- Event = event(_, _, _, _, _, _, DefModule, _, _, _, _, _, _).
+ Event = event(_, _, _, _, _, _, DefModule, _, _, _, _, _, _, _).
proc_name(Event) = ProcName :-
- Event = event(_, _, _, _, _, _, _, ProcName, _, _, _, _, _).
+ Event = event(_, _, _, _, _, _, _, ProcName, _, _, _, _, _, _).
proc_arity(Event) = ProcArity :-
- Event = event(_, _, _, _, _, _, _, _, ProcArity, _, _, _, _).
+ Event = event(_, _, _, _, _, _, _, _, ProcArity, _, _, _, _, _).
proc_mode_number(Event) = ModeNumber :-
- Event = event(_, _, _, _, _, _, _, _, _, ModeNumber, _, _, _).
+ Event = event(_, _, _, _, _, _, _, _, _, ModeNumber, _, _, _, _).
proc(Event) = (proc(ProcType, DeclModule, Name, Arity, ModeNum)) :-
Event = event(_, _, _, _, ProcType, DeclModule, _, Name, Arity,
- ModeNum, _, _, _).
+ ModeNum, _, _, _, _).
arguments(Event) = ListArg :-
- Event = event(_, _, _, _, _, _, _, _, _, _, ListArg, _, _).
+ Event = event(_, _, _, _, _, _, _, _, _, _, ListArg, _, _, _).
determinism(Event) = Determinism :-
- Event = event(_, _, _, _, _, _, _, _, _, _, _, Determinism, _).
+ Event = event(_, _, _, _, _, _, _, _, _, _, _, Determinism, _, _).
goal_path(Event) = GoalPath :-
- Event = event(_, _, _, _, _, _, _, _, _, _, _, _, GoalPath).
+ Event = event(_, _, _, _, _, _, _, _, _, _, _, _, GoalPath, _).
+
+line_number(Event) = LineNumber :-
+ Event = event(_, _, _, _, _, _, _, _, _, _, _, _, _, LineNumber).
% Type of the fourth argument of filter/4 which tells whether to stop collecting
@@ -188,10 +196,10 @@
filter(EventNumber, CallNumber, DepthNumber, Port, PredOrFunc, DeclModuleName,
DefModuleName, PredName, Arity, ModeNum, Arguments, Determinism,
- Path, AccIn, AccOut, Char) :-
+ Path, LN, AccIn, AccOut, Char) :-
filter(event(EventNumber, CallNumber, DepthNumber, Port, PredOrFunc,
DeclModuleName, DefModuleName, PredName, Arity, ModeNum,
- Arguments, Determinism, Path), AccIn, AccOut, StopOrContinue),
+ Arguments, Determinism, Path, LN), AccIn, AccOut, StopOrContinue),
(
StopOrContinue = continue,
Char = 'n'
Index: extras/morphine/source/collect.op
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/morphine/source/collect.op,v
retrieving revision 1.6
diff -u -d -u -r1.6 collect.op
--- extras/morphine/source/collect.op 2001/06/15 13:02:33 1.6
+++ extras/morphine/source/collect.op 2001/07/03 14:11:47
@@ -76,7 +76,8 @@
arity,\n\
mode_number,\n\
determinism,\n\
- goal_path_string).\n\
+ goal_path_string,\n\
+ line_number).\n\
\n\
:- type event_number == int.\n\
:- type call_number == int.\n\
@@ -107,6 +108,7 @@
:- type mode_number == int.\n\
:- type determinism == int. \n\
:- type goal_path_string == string.\n\
+:- type line_number == int.\n\
:- type procedure ---> proc(\n\
pred_or_func, \n\
declarated_module_name, \n\
@@ -130,6 +132,7 @@
:- func proc(event::in) = (procedure::out) is det.\n\
:- func determinism(event::in) = (determinism::out) is det.\n\
:- func goal_path(event::in) = (goal_path_string::out) is det.\n\
+:- func line_number(event::in) = (line_number::out) is det.\n\
:- func arguments(event::in) = (arguments::out) is det. (*)\n\
\n\
(*) To be able to retrieve arguments, you to need to have the opium parameter \n\
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.43
diff -u -d -u -r1.43 mercury_trace.c
--- trace/mercury_trace.c 2001/05/31 06:00:24 1.43
+++ trace/mercury_trace.c 2001/07/03 14:11:50
@@ -174,7 +174,8 @@
MR_Word *saved_regs = event_info.MR_saved_regs;
int max_r_num;
const char *path;
- bool stop_collecting = FALSE;
+ bool stop_collecting = FALSE;
+ int lineno = 0;
max_r_num = layout->MR_sll_entry->MR_sle_max_r_num;
if (max_r_num + MR_NUM_SPECIAL_REG >
@@ -193,8 +194,11 @@
MR_copy_regs_to_saved_regs(event_info.MR_max_mr_num,
saved_regs);
MR_trace_init_point_vars(layout, saved_regs, port);
+
+ lineno = MR_get_line_number(saved_regs, layout, port);
+
MR_COLLECT_filter(MR_trace_ctrl.MR_filter_ptr, seqno,
- depth, port, layout, path, &stop_collecting);
+ depth, port, layout, path, lineno, &stop_collecting);
MR_copy_saved_regs_to_regs(event_info.MR_max_mr_num,
saved_regs);
if (stop_collecting) {
Index: trace/mercury_trace.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.h,v
retrieving revision 1.23
diff -u -d -u -r1.23 mercury_trace.h
--- trace/mercury_trace.h 2001/05/31 06:00:25 1.23
+++ trace/mercury_trace.h 2001/07/03 14:11:50
@@ -191,8 +191,8 @@
typedef void (*MR_FilterFuncPtr)(MR_Integer, MR_Integer,
MR_Integer, MR_Word, MR_Word, MR_String, MR_String, MR_String,
- MR_Integer, MR_Integer, MR_Word, MR_Integer, MR_String, MR_Word,
- MR_Word *, MR_Char *);
+ MR_Integer, MR_Integer, MR_Word, MR_Integer, MR_String, MR_Integer,
+ MR_Word, MR_Word *, MR_Char *);
typedef struct {
MR_Trace_Cmd_Type MR_trace_cmd;
Index: trace/mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.57
diff -u -d -u -r1.57 mercury_trace_external.c
--- trace/mercury_trace_external.c 2001/06/22 15:20:21 1.57
+++ trace/mercury_trace_external.c 2001/07/03 14:11:50
@@ -173,9 +173,9 @@
MR_Unsigned depth,
/* XXX registers */
const char *path, MR_Word search_data);
-static void MR_output_current_slots(const MR_Event_Info *event_info,
+static void MR_output_current_slots(const MR_Label_Layout *layout,
MR_Trace_Port port, MR_Unsigned seqno,
- MR_Unsigned depth, const char *path);
+ MR_Unsigned depth, const char *path, int lineno);
static void MR_output_current_vars(MR_Word var_list, MR_Word string_list);
static void MR_output_current_nth_var(MR_Word var);
static void MR_output_current_live_var_names(MR_Word var_names_list,
@@ -494,6 +494,7 @@
MR_Word modules_list;
MR_Retry_Result retry_result;
static MR_String MR_object_file_name;
+ int lineno = 0;
MR_trace_enabled = FALSE;
@@ -540,6 +541,8 @@
default:
MR_fatal_error("Software error in the debugger.\n");
}
+
+ lineno = MR_get_line_number(event_info->MR_saved_regs, layout, port);
/* loop to process requests read from the debugger socket */
for(;;) {
@@ -596,8 +599,8 @@
fprintf(stderr, "\nMercury runtime: "
"REQUEST_CURRENT_SLOTS\n");
}
- MR_output_current_slots(event_info, port, seqno,
- depth, path);
+ MR_output_current_slots(layout, port, seqno,
+ depth, path, lineno);
break;
case MR_REQUEST_RETRY:
@@ -808,8 +811,8 @@
*/
MR_COLLECT_filter(cmd->MR_filter_ptr,
seqno, depth, port, layout, path,
- &stop_collecting);
-
+ lineno, &stop_collecting);
+
if (stop_collecting) {
MR_send_collect_result();
MR_send_message_to_socket(
@@ -898,38 +901,10 @@
}
static void
-MR_output_current_slots(const MR_Event_Info *event_info,
+MR_output_current_slots(const MR_Label_Layout *layout,
MR_Trace_Port port, MR_Unsigned seqno, MR_Unsigned depth,
- const char *path)
+ const char *path, int lineno)
{
- const char *filename;
- const MR_Label_Layout *layout = event_info->MR_event_sll;
- const MR_Label_Layout *parent_layout;
- const char *problem;
- int lineno = 0;
- MR_Word *base_sp, *base_curfr;
-
-
- if ( port == MR_PORT_CALL || port == MR_PORT_EXIT ||
- port == MR_PORT_REDO || port == MR_PORT_FAIL )
- /*
- ** At external events, we want the line number where the call is made,
- ** not the one where the procedure is defined.
- */
- {
- base_sp = MR_saved_sp(event_info->MR_saved_regs);
- base_curfr = MR_saved_curfr(event_info->MR_saved_regs);
- parent_layout = MR_find_nth_ancestor(layout, 1,
- &base_sp, &base_curfr, &problem);
- if (parent_layout != NULL) {
- (void) MR_find_context(parent_layout, &filename, &lineno);
- }
-
- } else {
- (void) MR_find_context(layout, &filename, &lineno);
- } ;
-
-
if (MR_PROC_LAYOUT_COMPILER_GENERATED(layout->MR_sll_entry)) {
MR_TRACE_CALL_MERCURY(
ML_DI_output_current_slots_comp(
@@ -1493,7 +1468,7 @@
void
MR_COLLECT_filter(MR_FilterFuncPtr filter_ptr, MR_Unsigned seqno,
MR_Unsigned depth, MR_Trace_Port port, const MR_Label_Layout *layout,
- const char *path, bool *stop_collecting)
+ const char *path, int lineno, bool *stop_collecting)
{
MR_Char result;
MR_Word arguments;
@@ -1528,10 +1503,46 @@
arguments,
layout->MR_sll_entry->MR_sle_detism,
(MR_String) path,
+ lineno,
MR_collecting_variable,
&MR_collecting_variable,
&result));
*stop_collecting = (result == 'y');
+}
+
+/*
+** This function retrieves the line number of the current goal.
+*/
+int
+MR_get_line_number(MR_Word *saved_regs, const MR_Label_Layout *layout,
+ MR_Trace_Port port)
+{
+ const char *filename;
+ const MR_Label_Layout *parent_layout;
+ const char *problem;
+ int lineno = 0;
+ MR_Word *base_sp, *base_curfr;
+
+
+ if ( port == MR_PORT_CALL || port == MR_PORT_EXIT ||
+ port == MR_PORT_REDO || port == MR_PORT_FAIL )
+ /*
+ ** At external events, we want the line number
+ ** where the call is made, not the one where the
+ ** procedure is defined.
+ */
+ {
+ base_sp = MR_saved_sp(saved_regs);
+ base_curfr = MR_saved_curfr(saved_regs);
+ parent_layout = MR_find_nth_ancestor(layout, 1,
+ &base_sp, &base_curfr, &problem);
+ if (parent_layout != NULL) {
+ (void) MR_find_context(parent_layout, &filename, &lineno);
+ }
+ } else {
+ (void) MR_find_context(layout, &filename, &lineno);
+ } ;
+ return lineno;
}
static void
Index: trace/mercury_trace_external.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.h,v
retrieving revision 1.10
diff -u -d -u -r1.10 mercury_trace_external.h
--- trace/mercury_trace_external.h 2001/03/07 08:00:01 1.10
+++ trace/mercury_trace_external.h 2001/07/03 14:11:50
@@ -18,10 +18,12 @@
extern void MR_trace_final_external(void);
extern MR_Code *MR_trace_event_external(MR_Trace_Cmd_Info *cmd,
MR_Event_Info *event_info);
-extern void MR_COLLECT_filter(MR_FilterFuncPtr filter_ptr, MR_Unsigned seqno,
+extern void MR_COLLECT_filter(MR_FilterFuncPtr filter_ptr, MR_Unsigned seqno,
MR_Unsigned depth, MR_Trace_Port port,
const MR_Label_Layout *layout, const char *path,
- bool *stop_collecting);
+ int lineno, bool *stop_collecting);
+extern int MR_get_line_number(MR_Word *saved_regs, const MR_Label_Layout *layout,
+ MR_Trace_Port port);
/*
** External debugger socket streams.
--
R1.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list