[m-dev.] For review: handling one by one variable retrieval within the external debugger
Erwan Jahier
Erwan.Jahier at irisa.fr
Wed Jul 29 23:29:08 AEST 1998
Many thanks for your comments Fergus.
Fergus Henderson wrote:
> I have a few comments. Could you please send a relative diff
> when you have addressed the comments below?
Sure:
--- std_util.m.save Wed Jul 29 14:58:18 1998
+++ std_util.m Wed Jul 29 14:58:25 1998
@@ -1319,6 +1319,7 @@
}
").
+% Export this function in order to use it in
runtime/mercury_trace_external.c
:- pragma export(type_name(in) = out, "ML_type_name").
type_name(Type) = TypeName :-
--- mercury_trace_external.c.save Wed Jul 29 15:10:43 1998
+++ mercury_trace_external.c Wed Jul 29 15:16:10 1998
@@ -54,9 +55,11 @@
MR_REQUEST_ABORT_PROG = 5, /* abort the current execution */
MR_REQUEST_ERROR = 6, /* something went wrong
*/
MR_REQUEST_CURRENT_LIVE_VAR_NAMES
- = 7, /* report data for current_live_var_names query */
+ = 7, /* report data for
+ current_live_var_names query */
MR_REQUEST_CURRENT_NTH_VAR
- = 8 /* report data for current_nth_var query */
+ = 8 /* report data for
+ current_nth_var query */
} MR_debugger_request_type;
@@ -79,7 +82,8 @@
static void MR_output_current_nth_var(Word var);
static void MR_output_current_live_var_names(Word var_names_list,
Word type_list);
-static Word MR_trace_make_var_names_list(const MR_Stack_Layout_Label
*layout);
+static Word MR_trace_make_var_names_list(
+ const MR_Stack_Layout_Label *layout);
static Word MR_trace_make_type_list(const MR_Stack_Layout_Label
*layout);
static Word MR_trace_make_nth_var(const MR_Stack_Layout_Label *layout,
Word debugger_request);
@@ -366,9 +370,11 @@
case MR_REQUEST_CURRENT_LIVE_VAR_NAMES:
if (MR_debug_socket) {
fprintf(stderr, "\nMercury runtime: "
- "MR_REQUEST_CURRENT_LIVE_VAR_NAMES\n");
+ "MR_REQUEST_CURRENT_LIVE_VAR"
+ "_NAMES\n");
}
- var_names_list = MR_trace_make_var_names_list(layout);
+ var_names_list =
+ MR_trace_make_var_names_list(layout);
type_list = MR_trace_make_type_list(layout);
MR_output_current_live_var_names(var_names_list,
type_list);
@@ -380,8 +386,10 @@
"REQUEST_CURRENT_VARS\n");
}
var_list = MR_trace_make_var_list(layout);
- var_names_list = MR_trace_make_var_names_list(layout);
- MR_output_current_vars(var_list, var_names_list);
+ var_names_list =
+ MR_trace_make_var_names_list(layout);
+ MR_output_current_vars(var_list,
+ var_names_list);
break;
case MR_REQUEST_CURRENT_NTH_VAR:
@@ -568,10 +576,7 @@
name = MR_name_if_present(vars, i);
var = &vars->MR_slvs_pairs[i];
- if ((strncmp(name, "TypeInfo", 8) == 0)
- || (strncmp(name, "ModuleInfo", 10) == 0)
- || (strncmp(name, "HLDS", 4) == 0)
- || !MR_trace_get_type(var, NULL, &type_info))
+ if (MR_trace_get_type_filtered(var, name, &type_info))
{
continue;
}
@@ -591,7 +596,8 @@
*/
static Word
-MR_trace_make_nth_var(const MR_Stack_Layout_Label *layout, Word
debugger_request)
+MR_trace_make_nth_var(const MR_Stack_Layout_Label *layout,
+ Word debugger_request)
{
int var_number;
const MR_Stack_Layout_Vars *vars;
@@ -604,7 +610,8 @@
Word univ;
var_number = MR_get_var_number(debugger_request);
- /* debugger_request should be of the form:
current_nth_var(var_number) */
+ /* debugger_request should be of the form:
+ current_nth_var(var_number) */
vars = &layout->MR_sll_var_info;
name = MR_name_if_present(vars, var_number);
var = &vars->MR_slvs_pairs[var_number];
@@ -612,16 +619,12 @@
restore_transient_registers();
incr_hp(univ, 2);
- if ((strncmp(name, "TypeInfo", 8) == 0)
- || (strncmp(name, "ModuleInfo", 10) == 0)
- || (strncmp(name, "HLDS", 4) == 0)
- || !MR_trace_get_type_and_value(var, NULL, &type_info, &value))
+
+ if (!MR_trace_get_type_and_value_filtered(var, name, &type_info,
+ &value))
{
field(mktag(0), univ, UNIV_OFFSET_FOR_TYPEINFO) = type_info;
field(mktag(0), univ, UNIV_OFFSET_FOR_DATA) = value;
- } else {
- field(mktag(0), univ, UNIV_OFFSET_FOR_TYPEINFO) = type_info;
- field(mktag(0), univ, UNIV_OFFSET_FOR_DATA) = value;
}
save_transient_registers();
@@ -640,9 +643,6 @@
static int
MR_get_var_number(Word debugger_request)
{
- int result;
-
- result = MR_DI_get_var_number(debugger_request);
- return result;
+ return MR_DI_get_var_number(debugger_request);
}
#endif /* MR_USE_EXTERNAL_DEBUGGER */
--- mercury_trace_util.c.save Wed Jul 29 14:55:21 1998
+++ mercury_trace_util.c Wed Jul 29 14:55:33 1998
@@ -155,10 +155,8 @@
** fails, are not of interest to the trace analyzer.
*/
- if ((strncmp(name, "TypeInfo", 8) == 0)
- || (strncmp(name, "ModuleInfo", 10) == 0)
- || (strncmp(name, "HLDS", 4) == 0)
- || !MR_trace_get_type_and_value(var, NULL, &type_info, &value))
+ if (MR_trace_get_type_and_value_filtered(var, name, &type_info,
+ &value))
{
continue;
}
@@ -371,3 +369,24 @@
}
+bool
+MR_trace_get_type_and_value_filtered(const MR_Stack_Layout_Var *var,
+ const char *name,
+ Word *type_info, Word *value)
+{
+ return ((strncmp(name, "TypeInfo", 8) == 0)
+ || (strncmp(name, "ModuleInfo", 10) == 0)
+ || (strncmp(name, "HLDS", 4) == 0)
+ || !MR_trace_get_type_and_value(var, NULL, type_info, value));
+}
+
+
+bool
+MR_trace_get_type_filtered(const MR_Stack_Layout_Var *var,
+ const char *name, Word *type_info)
+{
+ return ((strncmp(name, "TypeInfo", 8) == 0)
+ || (strncmp(name, "ModuleInfo", 10) == 0)
+ || (strncmp(name, "HLDS", 4) == 0)
+ || !MR_trace_get_type(var, NULL, type_info));
+}
--- mercury_trace_util.h.save Wed Jul 29 14:49:46 1998
+++ mercury_trace_util.h Wed Jul 29 14:49:52 1998
@@ -27,6 +27,11 @@
extern bool MR_trace_get_type_and_value_base(const MR_Stack_Layout_Var
*var,
bool saved_regs_valid, Word *base_sp, Word *base_curfr,
Word *type_params, Word *type_info, Word *value);
+extern bool MR_trace_get_type(const MR_Stack_Layout_Var *var,
+ Word *type_params, Word *type_info);
+extern bool MR_trace_get_type_base(const MR_Stack_Layout_Var *var,
+ bool saved_regs_valid, Word *base_sp, Word *base_curfr,
+ Word *type_params, Word *type_info);
/*
--
R1.
More information about the developers
mailing list