diff: runtime/mercury_trace.c stylistic changes
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Feb 3 23:06:38 AEDT 1998
Zoltan, are these changes OK with you?
runtime/mercury_trace.c:
Various minor stylistic changes:
- Use `MR_' prefixes for all file-scope symbols
- Declare local functions as `static'
- When printing messages that won't fit on one line,
using ANSI C string literal concatenation rather
than multiple calls to fprintf().
Index: mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace.c,v
retrieving revision 1.6
diff -u -u -r1.6 mercury_trace.c
--- mercury_trace.c 1998/02/03 08:17:24 1.6
+++ mercury_trace.c 1998/02/03 12:02:39
@@ -77,22 +77,25 @@
MR_NO_INTERACT
} MR_trace_interact;
-void MR_trace_display(MR_trace_interact interact,
- const MR_stack_layout_entry *layout,
- MR_trace_port port, int seqno, int depth, const char *path);
-void MR_trace_browse(int var_count, const MR_stack_layout_vars *var_info);
-void MR_trace_browse_var(char *name, const MR_stack_layout_var *var);
-int MR_trace_get_cmd(void);
-void MR_trace_help(void);
+static void MR_trace_display(MR_trace_interact interact,
+ const MR_stack_layout_entry *layout,
+ MR_trace_port port, int seqno, int depth,
+ const char *path);
+static void MR_trace_browse(int var_count,
+ const MR_stack_layout_vars *var_info);
+static void MR_trace_browse_var(char *name,
+ const MR_stack_layout_var *var);
+static int MR_trace_get_cmd(void);
+static void MR_trace_help(void);
-#define port_is_final(port) (port == MR_PORT_EXIT || port == MR_PORT_FAIL)
+#define MR_port_is_final(port) (port == MR_PORT_EXIT || port == MR_PORT_FAIL)
/*
** This function is called from compiled code whenever an event to be traced
** occurs.
*/
-void
+static void
MR_trace(const Word *layout_word, MR_trace_port port,
int seqno, int depth, const char *path)
{
@@ -109,7 +112,8 @@
break;
case MR_CMD_JUMP:
- if (MR_trace_seqno == seqno && port_is_final(port)) {
+ if (MR_trace_seqno == seqno && MR_port_is_final(port))
+ {
interact = MR_INTERACT;
} else {
interact = MR_NO_INTERACT;
@@ -121,7 +125,8 @@
break;
case MR_CMD_SKIP:
- if (MR_trace_seqno == seqno && port_is_final(port)) {
+ if (MR_trace_seqno == seqno && MR_port_is_final(port))
+ {
MR_trace_display(MR_INTERACT, layout,
port, seqno, depth, path);
}
@@ -146,7 +151,8 @@
}
}
-void MR_trace_display(MR_trace_interact interact,
+static void
+MR_trace_display(MR_trace_interact interact,
const MR_stack_layout_entry *layout,
MR_trace_port port, int seqno, int depth, const char *path)
{
@@ -261,9 +267,9 @@
break;
case 'j':
- if (port_is_final(port)) {
- fprintf(stderr, "mtrace: cannot jump");
- fprintf(stderr, " from this port\n");
+ if (MR_port_is_final(port)) {
+ fprintf(stderr, "mtrace: cannot jump"
+ " from this port\n");
continue;
} else {
MR_trace_cmd = MR_CMD_JUMP;
@@ -282,16 +288,16 @@
layout->MR_sle_out_arg_count,
&layout->MR_sle_out_arg_info);
} else {
- fprintf(stderr, "mtrace: cannot print");
- fprintf(stderr, " from this port\n");
+ fprintf(stderr, "mtrace: cannot print"
+ " from this port\n");
}
continue;
case 's':
- if (port_is_final(port)) {
- fprintf(stderr, "mtrace: cannot skip");
- fprintf(stderr, " from this port\n");
+ if (MR_port_is_final(port)) {
+ fprintf(stderr, "mtrace: cannot skip"
+ " from this port\n");
continue;
} else {
MR_trace_cmd = MR_CMD_SKIP;
@@ -302,8 +308,8 @@
case EOF:
case 'a':
- fprintf(stderr, "mtrace: are you sure");
- fprintf(stderr, " you want to abort? ");
+ fprintf(stderr, "mtrace: are you sure"
+ " you want to abort? ");
if (MR_trace_get_cmd() == 'y') {
MR_trace_cmd = MR_CMD_ABORT;
@@ -321,9 +327,9 @@
}
}
-Word saved_regs[MAX_FAKE_REG];
+static Word MR_saved_regs[MAX_FAKE_REG];
-void
+static void
MR_trace_browse(int var_count, const MR_stack_layout_vars *vars)
{
int i;
@@ -343,7 +349,7 @@
** through a parameter to MR_trace; for the time being, we use 10.
*/
- save_regs_to_mem(saved_regs);
+ save_regs_to_mem(MR_saved_regs);
for (i = 0; i < var_count; i++) {
if (vars->MR_slvs_names != NULL &&
vars->MR_slvs_names[i] != NULL)
@@ -354,13 +360,13 @@
MR_trace_browse_var(name, &vars->MR_slvs_pairs[i]);
}
- restore_regs_from_mem(saved_regs);
+ restore_regs_from_mem(MR_saved_regs);
}
/* if you want to debug this code, you may want to set this var to 1 */
static int MR_trace_print_locn = 0;
-void
+static void
MR_trace_browse_var(char *name, const MR_stack_layout_var *var)
{
Integer locn;
@@ -385,7 +391,7 @@
case MR_LVAL_TYPE_R:
if (MR_trace_print_locn)
printf("r%d", locn_num);
- value = saved_reg(saved_regs, locn_num);
+ value = saved_reg(MR_saved_regs, locn_num);
print_value = TRUE;
break;
@@ -450,8 +456,9 @@
/*
** XXX It would be nice if we could call an exported C
** function version of the browser predicate, and thus
- ** avoid going through call_engine, but that causes the
- ** Mercury code in the browser to clobber part of the C stack.
+ ** avoid going through call_engine, but for some unknown
+ ** reason, that seems to cause the Mercury code in the
+ ** browser to clobber part of the C stack.
*/
r1 = (Word) var->MR_slv_shape->MR_sls_type;
@@ -462,7 +469,7 @@
printf("\n");
}
-int
+static int
MR_trace_get_cmd(void)
{
int cmd;
@@ -478,15 +485,15 @@
return cmd;
}
-void
+static void
MR_trace_help(void)
{
- fprintf(stderr, "valid commands are:\n");
- fprintf(stderr, " a: abort the current execution.\n");
- fprintf(stderr, " c: continue to end, not printing the trace.\n");
- fprintf(stderr, " d: continue to end, printing the trace.\n");
- fprintf(stderr, " n: go to the next trace event.\n");
- fprintf(stderr, " s: skip the current call, not printing trace.\n");
- fprintf(stderr, " j: jump to end of current call, printing trace.\n");
- fprintf(stderr, " p: print the variables live at this point.\n");
+ fprintf(stderr, "valid commands are:\n"
+ " a: abort the current execution.\n"
+ " c: continue to end, not printing the trace.\n"
+ " d: continue to end, printing the trace.\n"
+ " n: go to the next trace event.\n"
+ " s: skip the current call, not printing trace.\n"
+ " j: jump to end of current call, printing trace.\n"
+ " p: print the variables live at this point.\n");
}
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list