[m-dev.] quoting procedure names when necessary in mdb output
Peter Moulder
Peter.Moulder at infotech.monash.edu.au
Wed Aug 20 01:45:18 AEST 2003
Appended is a patch that has mdb quote procedure names when necessary
in its output. This is useful for front-ends that use mdb, such as the
emacs interface. In pathalogical cases it can be useful even when
humans parse the output. (Actually, `/' (and to a lesser extent `-') are
fairly common cases where it's at least a bit clearer to read with
quoting.)
The quoting style used in the patch is the same as the syntax for
quoted names in Mercury code. For example, a newline is written as `\n'
(with the name being enclosed by single quotes, 'like\nso'), and octal
escapes have a trailing backslash ('\154\ike \163\o').
However, I've noticed when testing this that mdb uses a different
quoting mechanism
(trace/mercury_trace_internal.c:MR_trace_break_off_one_word;
MR_trace_continue_line is relevant to a lesser degree). It doesn't
support octal escapes or \n etc., though backslash-apostrophe can be
used to enter names containing an apostrophe.
So I wonder whether I should modify the patch to use mdb's existing
quoting style, or modify MR_trace_break_off_one_word to use
Mercury-name-style quoting, or leave both as they are.
As a user, I'd expect the argument of `break' to allow the same quoting
syntax as is used in Mercury code to refer to the corresponding name.
It's also more convenient to use octal escapes for some characters than
trying to type that character. (Tab completion wouldn't in general
solve the problem even if it worked. I noticed yesterday that it
doesn't work for names containing spaces.)
I haven't checked gdb's source code, but its quoting mechanism seems
similar to mdb's (with special-casing of C characters, e.g. "print '\n'").
An advantage of the patch's existing quoting style is that it's easier
to parse with regexps (e.g. the emacs interface to mdb) than if names
can be split over multiple lines (names containing newlines).
Another advantage is that names with this quoting style are always
human-legible even if they contain non-printable characters (or terminal
escape sequences), unlike if the patch were to use mdb's existing input
quoting style.
Disadvantages of changing mdb's input quoting style:
- Work. The coding is only a few minutes' worth, though there's
testing, reviewing, and probably documentation to update.
Hmm, that "few minutes" estimate doesn't include the tab-completion
code, which may well take significant work. However, given that
tab-completion already doesn't work, I wouldn't mind if other
patches went in without fixing this.
It looks as if rl_filename_quoting_function and
rl_filename_dequoting_function are relevant in adapting completion
to different quoting styles.
- Backwards compatibility? Not really an issue in practice, assuming
that no-one (or no mdb-interfacing code, more to the point) is using
a redundant backslash in front of [0-9abrftnv].
At the moment my feeling is that it's OK for the patch to retain its
Mercury-name quoting, and that it would be good to have a separate patch
that changed MR_trace_break_off_one_word to accept Mercury-name-style
escape sequences.
The patch doesn't do any quoting for module names at the moment. The
simple implementation of passing MR_user_decl_module to MR_maybe_quote
would do the wrong thing for submodules. The use of a single string for
MR_user_decl_module suggests that it's impossible for quoted module
names in Mercury to contain `.'. Quote-needing module names aren't
particularly useful, except perhaps having a module name beginning with
a capital letter or underscore, though it doesn't matter too much if we
don't quote names matching [A-Z_][a-zA-Z0-9_]*.
I'm happy to add a is_module flag to MR_maybe_quote that "escapes"
embedded `.' characters as "'.'" if doing quoting for the module name.
I'd apply MR_needs_quoting to the whole string, even if that resulted
in output like 'unneeded_here'.'quotes only needed here'.predname .
The decision of whether or not to use quoting is currently based on
whether or not the name is lexically a valid unquoted name (*see
(mercury_ref)Tokens). As a result, ClassMethod_for_blah gets quoted (it
begins with a capital letter). As far as emacs etc. are concerned, I'd
guess it would be fine to change the test to matching [a-zA-Z0-9_]+
instead of the existing [a-z][a-zA-Z0-9_]*. My intuition is to retain
the existing test. I don't think it's too much loss to add a pair of
quotes around those long ClassMethod names. It's good to encourage the
user to use proper quoting when entering queries. However, I've no
strong objection to changing MR_needs_quoting to test for just
[a-zA-Z0-9_]+.
I decided not to use quoting for compiler-generated procedures
(MR_PROC_LAYOUT_COMPILER_GENERATED): i.e. I decided to have
__Unify__ for mymodule.'my type'/0-0
rather than
'__Unify__' for mymodule.'my type'/0-0
In coming to that decision, I assumed that all MR_comp_pred_name's match
[a-zA-Z0-9_]+, or at least never contain newlines or non-printing chars
or the string " for ". I've no strong feeling on this question, though,
and am happy to pass the name through MR_maybe_quote for greater
consistency with non-compiler-generated procedures.
I append the existing patch & change comment. I expect to repost to
mercury-reviews once ppl have had a chance to comment on the above.
pjm.
Estimated hours taken: 3
Get mdb to quote procedure names when beneficial to do so.
runtime/mercury_stack_trace.c:
(MR_print_proc_id_internal): Write the pred/func/type name as a quoted
name if it isn't a valid unquoted name (*see (mercury_ref)Tokens).
tests/debugger/breakpoints.exp:
tests/debugger/breakpoints.exp2:
tests/debugger/existential_type_classes.exp:
tests/debugger/existential_type_classes.exp2:
tests/debugger/implied_instance.exp:
tests/debugger/multi_parameter.exp:
tests/debugger/multi_parameter.exp2:
tests/debugger/no_inline_builtins.exp:
tests/debugger/queens.exp2:
tests/debugger/retry.exp2:
Update output accordingly.
Index: tests/debugger/breakpoints.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/breakpoints.exp,v
retrieving revision 1.9
diff -d -u -r1.9 breakpoints.exp
--- tests/debugger/breakpoints.exp 17 Jan 2003 05:56:51 -0000 1.9
+++ tests/debugger/breakpoints.exp 19 Aug 2003 07:35:37 -0000
@@ -37,24 +37,24 @@
4: + stop all pred breakpoints.qperm/2-0 (nondet)
mdb> break /
Ambiguous procedure specification. The matches are:
-0: func breakpoints.//2-0 (det)
-1: func breakpoints.print_list.//2-0 (det)
+0: func breakpoints.'/'/2-0 (det)
+1: func breakpoints.print_list.'/'/2-0 (det)
Which do you want to put a breakpoint on (0-1 or *)? 0
- 5: + stop interface func breakpoints.//2-0 (det)
+ 5: + stop interface func breakpoints.'/'/2-0 (det)
mdb> break //2
Ambiguous procedure specification. The matches are:
-0: func breakpoints.//2-0 (det)
-1: func breakpoints.print_list.//2-0 (det)
+0: func breakpoints.'/'/2-0 (det)
+1: func breakpoints.print_list.'/'/2-0 (det)
Which do you want to put a breakpoint on (0-1 or *)? 0
- 6: + stop interface func breakpoints.//2-0 (det)
+ 6: + stop interface func breakpoints.'/'/2-0 (det)
mdb> break breakpoints.print_list.-/2
- 7: + stop interface func breakpoints.print_list.-/2-0 (det)
+ 7: + stop interface func breakpoints.print_list.'-'/2-0 (det)
mdb> break breakpoints.print_list.--0
- 8: + stop interface func breakpoints.print_list.-/2-0 (det)
+ 8: + stop interface func breakpoints.print_list.'-'/2-0 (det)
mdb> break breakpoints__print_list__/-0
- 9: + stop interface func breakpoints.print_list.//2-0 (det)
+ 9: + stop interface func breakpoints.print_list.'/'/2-0 (det)
mdb> break breakpoints__print_list__print_list
10: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
mdb> break breakpoints.print_list.print_list/3
@@ -65,11 +65,11 @@
2: + stop interface pred breakpoints.safe/1-0 (semidet)
3: + stop entry pred breakpoints.qperm/2-0 (nondet)
4: + stop all pred breakpoints.qperm/2-0 (nondet)
- 5: + stop interface func breakpoints.//2-0 (det)
- 6: + stop interface func breakpoints.//2-0 (det)
- 7: + stop interface func breakpoints.print_list.-/2-0 (det)
- 8: + stop interface func breakpoints.print_list.-/2-0 (det)
- 9: + stop interface func breakpoints.print_list.//2-0 (det)
+ 5: + stop interface func breakpoints.'/'/2-0 (det)
+ 6: + stop interface func breakpoints.'/'/2-0 (det)
+ 7: + stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 8: + stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 9: + stop interface func breakpoints.print_list.'/'/2-0 (det)
10: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
11: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
mdb> delete 0
@@ -79,11 +79,11 @@
2: + stop interface pred breakpoints.safe/1-0 (semidet)
3: + stop entry pred breakpoints.qperm/2-0 (nondet)
4: + stop all pred breakpoints.qperm/2-0 (nondet)
- 5: + stop interface func breakpoints.//2-0 (det)
- 6: + stop interface func breakpoints.//2-0 (det)
- 7: + stop interface func breakpoints.print_list.-/2-0 (det)
- 8: + stop interface func breakpoints.print_list.-/2-0 (det)
- 9: + stop interface func breakpoints.print_list.//2-0 (det)
+ 5: + stop interface func breakpoints.'/'/2-0 (det)
+ 6: + stop interface func breakpoints.'/'/2-0 (det)
+ 7: + stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 8: + stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 9: + stop interface func breakpoints.print_list.'/'/2-0 (det)
10: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
11: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
mdb> disable 3
@@ -112,11 +112,11 @@
2: E stop interface pred breakpoints.safe/1-0 (semidet)
3: D stop entry pred breakpoints.qperm/2-0 (nondet)
4: E stop all pred breakpoints.qperm/2-0 (nondet)
- 5: E stop interface func breakpoints.//2-0 (det)
- 6: E stop interface func breakpoints.//2-0 (det)
- 7: E stop interface func breakpoints.print_list.-/2-0 (det)
- 8: E stop interface func breakpoints.print_list.-/2-0 (det)
- 9: E stop interface func breakpoints.print_list.//2-0 (det)
+ 5: E stop interface func breakpoints.'/'/2-0 (det)
+ 6: E stop interface func breakpoints.'/'/2-0 (det)
+ 7: E stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 8: E stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 9: E stop interface func breakpoints.print_list.'/'/2-0 (det)
10: E stop interface pred breakpoints.print_list.print_list/3-0 (det)
11: E stop interface pred breakpoints.print_list.print_list/3-0 (det)
mdb> break info
Index: tests/debugger/breakpoints.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/breakpoints.exp2,v
retrieving revision 1.5
diff -d -u -r1.5 breakpoints.exp2
--- tests/debugger/breakpoints.exp2 17 Jan 2003 05:56:51 -0000 1.5
+++ tests/debugger/breakpoints.exp2 19 Aug 2003 07:35:37 -0000
@@ -37,32 +37,32 @@
4: + stop all pred breakpoints.qperm/2-0 (nondet)
mdb> break /
Ambiguous procedure specification. The matches are:
-0: func breakpoints.//2-0 (det)
-1: func breakpoints.print_list.//2-0 (det)
-2: func dir.//2-0 (det)
-3: func float.//2-0 (det)
-4: func int.//2-0 (det)
-5: func rational.//2-0 (det)
+0: func breakpoints.'/'/2-0 (det)
+1: func breakpoints.print_list.'/'/2-0 (det)
+2: func dir.'/'/2-0 (det)
+3: func float.'/'/2-0 (det)
+4: func int.'/'/2-0 (det)
+5: func rational.'/'/2-0 (det)
Which do you want to put a breakpoint on (0-5 or *)? 0
- 5: + stop interface func breakpoints.//2-0 (det)
+ 5: + stop interface func breakpoints.'/'/2-0 (det)
mdb> break //2
Ambiguous procedure specification. The matches are:
-0: func breakpoints.//2-0 (det)
-1: func breakpoints.print_list.//2-0 (det)
-2: func dir.//2-0 (det)
-3: func float.//2-0 (det)
-4: func int.//2-0 (det)
-5: func rational.//2-0 (det)
+0: func breakpoints.'/'/2-0 (det)
+1: func breakpoints.print_list.'/'/2-0 (det)
+2: func dir.'/'/2-0 (det)
+3: func float.'/'/2-0 (det)
+4: func int.'/'/2-0 (det)
+5: func rational.'/'/2-0 (det)
Which do you want to put a breakpoint on (0-5 or *)? 0
- 6: + stop interface func breakpoints.//2-0 (det)
+ 6: + stop interface func breakpoints.'/'/2-0 (det)
mdb> break breakpoints.print_list.-/2
- 7: + stop interface func breakpoints.print_list.-/2-0 (det)
+ 7: + stop interface func breakpoints.print_list.'-'/2-0 (det)
mdb> break breakpoints.print_list.--0
- 8: + stop interface func breakpoints.print_list.-/2-0 (det)
+ 8: + stop interface func breakpoints.print_list.'-'/2-0 (det)
mdb> break breakpoints__print_list__/-0
- 9: + stop interface func breakpoints.print_list.//2-0 (det)
+ 9: + stop interface func breakpoints.print_list.'/'/2-0 (det)
mdb> break breakpoints__print_list__print_list
10: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
mdb> break breakpoints.print_list.print_list/3
@@ -73,11 +73,11 @@
2: + stop interface pred breakpoints.safe/1-0 (semidet)
3: + stop entry pred breakpoints.qperm/2-0 (nondet)
4: + stop all pred breakpoints.qperm/2-0 (nondet)
- 5: + stop interface func breakpoints.//2-0 (det)
- 6: + stop interface func breakpoints.//2-0 (det)
- 7: + stop interface func breakpoints.print_list.-/2-0 (det)
- 8: + stop interface func breakpoints.print_list.-/2-0 (det)
- 9: + stop interface func breakpoints.print_list.//2-0 (det)
+ 5: + stop interface func breakpoints.'/'/2-0 (det)
+ 6: + stop interface func breakpoints.'/'/2-0 (det)
+ 7: + stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 8: + stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 9: + stop interface func breakpoints.print_list.'/'/2-0 (det)
10: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
11: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
mdb> delete 0
@@ -87,11 +87,11 @@
2: + stop interface pred breakpoints.safe/1-0 (semidet)
3: + stop entry pred breakpoints.qperm/2-0 (nondet)
4: + stop all pred breakpoints.qperm/2-0 (nondet)
- 5: + stop interface func breakpoints.//2-0 (det)
- 6: + stop interface func breakpoints.//2-0 (det)
- 7: + stop interface func breakpoints.print_list.-/2-0 (det)
- 8: + stop interface func breakpoints.print_list.-/2-0 (det)
- 9: + stop interface func breakpoints.print_list.//2-0 (det)
+ 5: + stop interface func breakpoints.'/'/2-0 (det)
+ 6: + stop interface func breakpoints.'/'/2-0 (det)
+ 7: + stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 8: + stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 9: + stop interface func breakpoints.print_list.'/'/2-0 (det)
10: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
11: + stop interface pred breakpoints.print_list.print_list/3-0 (det)
mdb> disable 3
@@ -120,11 +120,11 @@
2: E stop interface pred breakpoints.safe/1-0 (semidet)
3: D stop entry pred breakpoints.qperm/2-0 (nondet)
4: E stop all pred breakpoints.qperm/2-0 (nondet)
- 5: E stop interface func breakpoints.//2-0 (det)
- 6: E stop interface func breakpoints.//2-0 (det)
- 7: E stop interface func breakpoints.print_list.-/2-0 (det)
- 8: E stop interface func breakpoints.print_list.-/2-0 (det)
- 9: E stop interface func breakpoints.print_list.//2-0 (det)
+ 5: E stop interface func breakpoints.'/'/2-0 (det)
+ 6: E stop interface func breakpoints.'/'/2-0 (det)
+ 7: E stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 8: E stop interface func breakpoints.print_list.'-'/2-0 (det)
+ 9: E stop interface func breakpoints.print_list.'/'/2-0 (det)
10: E stop interface pred breakpoints.print_list.print_list/3-0 (det)
11: E stop interface pred breakpoints.print_list.print_list/3-0 (det)
mdb> break info
Index: tests/debugger/existential_type_classes.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/existential_type_classes.exp,v
retrieving revision 1.14
diff -d -u -r1.14 existential_type_classes.exp
--- tests/debugger/existential_type_classes.exp 17 Jan 2003 05:56:52 -0000 1.14
+++ tests/debugger/existential_type_classes.exp 19 Aug 2003 07:35:37 -0000
@@ -20,7 +20,7 @@
HeadVar__1 42
mdb>
E4: C4 4 CALL existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 42
mdb> continue -a
@@ -29,7 +29,7 @@
E6: C5 5 EXIT existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E7: C4 4 EXIT existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
E8: C3 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E9: C2 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:51)
@@ -49,7 +49,7 @@
HeadVar__1 "blah"
mdb>
E12: C8 4 CALL existential_type_classes.m:25
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____string__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____string__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 "blah"
mdb> continue -a
@@ -58,7 +58,7 @@
E14: C9 5 EXIT existential_type_classes.m:47 (from existential_type_classes.m:25)
pred existential_type_classes.string_foo/2-0 (det)
E15: C8 4 EXIT existential_type_classes.m:25
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____string__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____string__arity0______existential_type_classes__foo_2'/2-0 (det)
E16: C7 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E17: C6 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:52)
@@ -82,7 +82,7 @@
HeadVar__1 43
mdb>
E22: C13 4 CALL existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 43
mdb> continue -a
@@ -91,7 +91,7 @@
E24: C14 5 EXIT existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E25: C13 4 EXIT existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
E26: C12 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E27: C11 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:53)
@@ -119,7 +119,7 @@
HeadVar__1 43
mdb>
E34: C19 4 CALL existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 43
mdb> continue -a
@@ -128,7 +128,7 @@
E36: C20 5 EXIT existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E37: C19 4 EXIT existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
E38: C18 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E39: C17 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:54)
@@ -156,7 +156,7 @@
HeadVar__1 45
mdb>
E46: C25 4 CALL existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 45
mdb> continue -a
@@ -165,7 +165,7 @@
E48: C26 5 EXIT existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E49: C25 4 EXIT existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
E50: C24 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E51: C23 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:55)
Index: tests/debugger/existential_type_classes.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/existential_type_classes.exp2,v
retrieving revision 1.15
diff -d -u -r1.15 existential_type_classes.exp2
--- tests/debugger/existential_type_classes.exp2 30 Jan 2003 05:59:26 -0000 1.15
+++ tests/debugger/existential_type_classes.exp2 19 Aug 2003 07:35:37 -0000
@@ -20,20 +20,20 @@
HeadVar__1 42
mdb>
E4: C4 4 CALL existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 42
mdb> continue -a
E5: C5 5 CALL existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E6: C6 6 CALL int.m:NNNN (from existential_type_classes.m:44)
- func int.*/2-0 (det)
+ func int.'*'/2-0 (det)
E7: C6 6 EXIT int.m:NNNN (from existential_type_classes.m:44)
- func int.*/2-0 (det)
+ func int.'*'/2-0 (det)
E8: C5 5 EXIT existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E9: C4 4 EXIT existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
E10: C3 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E11: C2 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:51)
@@ -53,7 +53,7 @@
HeadVar__1 "blah"
mdb>
E14: C9 4 CALL existential_type_classes.m:25
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____string__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____string__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 "blah"
mdb> continue -a
@@ -66,7 +66,7 @@
E18: C10 5 EXIT existential_type_classes.m:47 (from existential_type_classes.m:25)
pred existential_type_classes.string_foo/2-0 (det)
E19: C9 4 EXIT existential_type_classes.m:25
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____string__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____string__arity0______existential_type_classes__foo_2'/2-0 (det)
E20: C8 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E21: C7 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:52)
@@ -90,20 +90,20 @@
HeadVar__1 43
mdb>
E26: C15 4 CALL existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 43
mdb> continue -a
E27: C16 5 CALL existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E28: C17 6 CALL int.m:NNNN (from existential_type_classes.m:44)
- func int.*/2-0 (det)
+ func int.'*'/2-0 (det)
E29: C17 6 EXIT int.m:NNNN (from existential_type_classes.m:44)
- func int.*/2-0 (det)
+ func int.'*'/2-0 (det)
E30: C16 5 EXIT existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E31: C15 4 EXIT existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
E32: C14 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E33: C13 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:53)
@@ -131,20 +131,20 @@
HeadVar__1 43
mdb>
E40: C22 4 CALL existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 43
mdb> continue -a
E41: C23 5 CALL existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E42: C24 6 CALL int.m:NNNN (from existential_type_classes.m:44)
- func int.*/2-0 (det)
+ func int.'*'/2-0 (det)
E43: C24 6 EXIT int.m:NNNN (from existential_type_classes.m:44)
- func int.*/2-0 (det)
+ func int.'*'/2-0 (det)
E44: C23 5 EXIT existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E45: C22 4 EXIT existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
E46: C21 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E47: C20 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:54)
@@ -172,20 +172,20 @@
HeadVar__1 45
mdb>
E54: C29 4 CALL existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
mdb> P
HeadVar__1 45
mdb> continue -a
E55: C30 5 CALL existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E56: C31 6 CALL int.m:NNNN (from existential_type_classes.m:44)
- func int.*/2-0 (det)
+ func int.'*'/2-0 (det)
E57: C31 6 EXIT int.m:NNNN (from existential_type_classes.m:44)
- func int.*/2-0 (det)
+ func int.'*'/2-0 (det)
E58: C30 5 EXIT existential_type_classes.m:44 (from existential_type_classes.m:21)
pred existential_type_classes.int_foo/2-0 (det)
E59: C29 4 EXIT existential_type_classes.m:21
- pred existential_type_classes.ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2/2-0 (det)
+ pred existential_type_classes.'ClassMethod_for_existential_type_classes__fooable____int__arity0______existential_type_classes__foo_2'/2-0 (det)
E60: C28 3 EXIT (from existential_type_classes.m:68)
pred existential_type_classes.foo/2-0 (det)
E61: C27 2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:55)
Index: tests/debugger/implied_instance.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/implied_instance.exp,v
retrieving revision 1.10
diff -d -u -r1.10 implied_instance.exp
--- tests/debugger/implied_instance.exp 17 Jan 2003 05:56:53 -0000 1.10
+++ tests/debugger/implied_instance.exp 19 Aug 2003 07:35:37 -0000
@@ -11,7 +11,7 @@
mdb> P
HeadVar__1 2
mdb>
- 3: 3 3 CALL pred implied_instance.ClassMethod_for_implied_instance__sumable____int__arity0______implied_instance__p_2/2-0 (det)
+ 3: 3 3 CALL pred implied_instance.'ClassMethod_for_implied_instance__sumable____int__arity0______implied_instance__p_2'/2-0 (det)
mdb> P
HeadVar__1 2
mdb> break -e p
@@ -19,13 +19,13 @@
mdb> continue -a
4: 4 4 CALL pred implied_instance.copy_int/2-0 (det)
5: 4 4 EXIT pred implied_instance.copy_int/2-0 (det)
- 6: 3 3 EXIT pred implied_instance.ClassMethod_for_implied_instance__sumable____int__arity0______implied_instance__p_2/2-0 (det)
+ 6: 3 3 EXIT pred implied_instance.'ClassMethod_for_implied_instance__sumable____int__arity0______implied_instance__p_2'/2-0 (det)
7: 2 2 EXIT pred implied_instance.p/2-0 (det)
8: 5 2 CALL pred implied_instance.p/2-0 (det)
mdb> P
HeadVar__1 [42, 24, 1, 2, 3]
mdb>
- 9: 6 3 CALL pred implied_instance.ClassMethod_for_implied_instance__sumable____list__list__arity1______implied_instance__p_2/2-0 (det)
+ 9: 6 3 CALL pred implied_instance.'ClassMethod_for_implied_instance__sumable____list__list__arity1______implied_instance__p_2'/2-0 (det)
mdb> P
HeadVar__1 [42, 24, 1, 2, 3]
mdb>
@@ -38,7 +38,7 @@
mdb> P
HeadVar__1 42
mdb>
- 13: 9 6 CALL pred implied_instance.ClassMethod_for_implied_instance__sumable____int__arity0______implied_instance__p_2/2-0 (det)
+ 13: 9 6 CALL pred implied_instance.'ClassMethod_for_implied_instance__sumable____int__arity0______implied_instance__p_2'/2-0 (det)
mdb> P
HeadVar__1 42
mdb> continue -S
Index: tests/debugger/multi_parameter.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/multi_parameter.exp,v
retrieving revision 1.12
diff -d -u -r1.12 multi_parameter.exp
--- tests/debugger/multi_parameter.exp 17 Jan 2003 05:56:54 -0000 1.12
+++ tests/debugger/multi_parameter.exp 19 Aug 2003 07:35:37 -0000
@@ -14,12 +14,12 @@
mdb> print *
HeadVar__1 'z'
mdb>
- 4: 4 4 CALL pred multi_parameter.ClassMethod_for_multi_parameter__m____character__arity0__int__arity0______multi_parameter__a_2/2-0 (det)
+ 4: 4 4 CALL pred multi_parameter.'ClassMethod_for_multi_parameter__m____character__arity0__int__arity0______multi_parameter__a_2'/2-0 (det)
multi_parameter.m:20
mdb> print *
HeadVar__1 'z'
mdb>
- 5: 4 4 EXIT pred multi_parameter.ClassMethod_for_multi_parameter__m____character__arity0__int__arity0______multi_parameter__a_2/2-0 (det)
+ 5: 4 4 EXIT pred multi_parameter.'ClassMethod_for_multi_parameter__m____character__arity0__int__arity0______multi_parameter__a_2'/2-0 (det)
multi_parameter.m:20
mdb> print *
HeadVar__1 'z'
Index: tests/debugger/multi_parameter.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/multi_parameter.exp2,v
retrieving revision 1.12
diff -d -u -r1.12 multi_parameter.exp2
--- tests/debugger/multi_parameter.exp2 17 Jan 2003 05:56:54 -0000 1.12
+++ tests/debugger/multi_parameter.exp2 19 Aug 2003 07:35:37 -0000
@@ -14,7 +14,7 @@
mdb> print *
HeadVar__1 'z'
mdb>
- 4: 4 4 CALL pred multi_parameter.ClassMethod_for_multi_parameter__m____character__arity0__int__arity0______multi_parameter__a_2/2-0 (det)
+ 4: 4 4 CALL pred multi_parameter.'ClassMethod_for_multi_parameter__m____character__arity0__int__arity0______multi_parameter__a_2'/2-0 (det)
multi_parameter.m:20
mdb> print *
HeadVar__1 'z'
@@ -30,7 +30,7 @@
Character (arg 1) 'z'
Int (arg 2) 122
mdb>
- 7: 4 4 EXIT pred multi_parameter.ClassMethod_for_multi_parameter__m____character__arity0__int__arity0______multi_parameter__a_2/2-0 (det)
+ 7: 4 4 EXIT pred multi_parameter.'ClassMethod_for_multi_parameter__m____character__arity0__int__arity0______multi_parameter__a_2'/2-0 (det)
multi_parameter.m:20
mdb> print *
HeadVar__1 'z'
Index: tests/debugger/no_inline_builtins.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/no_inline_builtins.exp,v
retrieving revision 1.1
diff -d -u -r1.1 no_inline_builtins.exp
--- tests/debugger/no_inline_builtins.exp 30 Jan 2003 05:59:26 -0000 1.1
+++ tests/debugger/no_inline_builtins.exp 19 Aug 2003 07:35:37 -0000
@@ -5,14 +5,14 @@
Contexts will not be printed.
mdb> register --quiet
mdb> break int.+/2-0
- 0: + stop interface func int.+/2-0 (det)
+ 0: + stop interface func int.'+'/2-0 (det)
mdb> continue
- 2: 2 2 CALL func int.+/2-0 (det)
+ 2: 2 2 CALL func int.'+'/2-0 (det)
mdb> print 1
HeadVar__1 40
mdb> print 2
HeadVar__2 2
mdb> continue
- 3: 2 2 EXIT func int.+/2-0 (det)
+ 3: 2 2 EXIT func int.'+'/2-0 (det)
mdb> continue -n
42
Index: tests/debugger/queens.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens.exp2,v
retrieving revision 1.8
diff -d -u -r1.8 queens.exp2
--- tests/debugger/queens.exp2 25 Jun 2003 19:13:24 -0000 1.8
+++ tests/debugger/queens.exp2 19 Aug 2003 07:35:37 -0000
@@ -211,13 +211,13 @@
E41: C16 4 SWTC queens.m:61
pred queens.nodiag/3-0 (semidet) s2;
E42: C17 5 CALL int.m:NNNN (from queens.m:62)
- func int.-/2-0 (det)
+ func int.'-'/2-0 (det)
E43: C17 5 EXIT int.m:NNNN (from queens.m:62)
- func int.-/2-0 (det)
+ func int.'-'/2-0 (det)
E44: C18 5 CALL int.m:NNNN (from queens.m:63)
- func int.-/2-0 (det)
+ func int.'-'/2-0 (det)
E45: C18 5 EXIT int.m:NNNN (from queens.m:63)
- func int.-/2-0 (det)
+ func int.'-'/2-0 (det)
E46: C16 4 COND queens.m:64
pred queens.nodiag/3-0 (semidet) s2;c6;?;
E47: C16 4 THEN queens.m:65
Index: tests/debugger/retry.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/retry.exp2,v
retrieving revision 1.7
diff -d -u -r1.7 retry.exp2
--- tests/debugger/retry.exp2 14 May 2003 10:12:06 -0000 1.7
+++ tests/debugger/retry.exp2 19 Aug 2003 07:35:37 -0000
@@ -10,8 +10,8 @@
0: + stop interface pred retry.det_without_cut_1/2-0 (det)
mdb> continue -a
E2: C2 2 CALL pred retry.det_without_cut/2-0 (det)
- E3: C3 3 CALL func int.+/2-0 (det)
- E4: C3 3 EXIT func int.+/2-0 (det)
+ E3: C3 3 CALL func int.'+'/2-0 (det)
+ E4: C3 3 EXIT func int.'+'/2-0 (det)
E5: C4 3 CALL pred retry.det_without_cut_1/2-0 (det)
mdb> disable 0
0: - stop interface pred retry.det_without_cut_1/2-0 (det)
@@ -31,8 +31,8 @@
mdb> break det_without_cut_2
1: + stop interface pred retry.det_without_cut_2/2-0 (det)
mdb> continue -a
- E3: C3 3 CALL func int.+/2-0 (det)
- E4: C3 3 EXIT func int.+/2-0 (det)
+ E3: C3 3 CALL func int.'+'/2-0 (det)
+ E4: C3 3 EXIT func int.'+'/2-0 (det)
E5: C4 3 CALL pred retry.det_without_cut_1/2-0 (det)
E7: C5 4 CALL pred retry.det_without_cut_2/2-0 (det)
mdb> delete *
@@ -68,13 +68,13 @@
0: + stop interface pred retry.det_with_cut_2/2-0 (det)
mdb> continue -a
E2: C2 2 CALL pred retry.det_without_cut/2-0 (det)
- E3: C3 3 CALL func int.+/2-0 (det)
- E4: C3 3 EXIT func int.+/2-0 (det)
+ E3: C3 3 CALL func int.'+'/2-0 (det)
+ E4: C3 3 EXIT func int.'+'/2-0 (det)
E5: C4 3 CALL pred retry.det_without_cut_1/2-0 (det)
E7: C5 4 CALL pred retry.det_without_cut_2/2-0 (det)
E14: C5 4 EXIT pred retry.det_without_cut_2/2-0 (det)
- E15: C8 4 CALL func int.*/2-0 (det)
- E16: C8 4 EXIT func int.*/2-0 (det)
+ E15: C8 4 CALL func int.'*'/2-0 (det)
+ E16: C8 4 EXIT func int.'*'/2-0 (det)
E6: C4 3 EXIT pred retry.det_without_cut_1/2-0 (det)
E8: C2 2 EXIT pred retry.det_without_cut/2-0 (det)
E9: C6 2 CALL pred retry.det_with_cut/2-0 (det)
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.55
diff -d -u -r1.55 mercury_stack_trace.c
--- runtime/mercury_stack_trace.c 16 Apr 2003 12:37:39 -0000 1.55
+++ runtime/mercury_stack_trace.c 19 Aug 2003 07:35:37 -0000
@@ -144,11 +144,11 @@
MR_dump_stack_record_frame(fp, prev_label_layout,
old_trace_sp, old_trace_curfr, print_stack_record);
- MR_dump_stack_record_flush(fp, print_stack_record);
- return problem;
+ MR_dump_stack_record_flush(fp, print_stack_record);
+ return problem;
} else {
- MR_dump_stack_record_frame(fp, prev_label_layout,
- old_trace_sp, old_trace_curfr, print_stack_record);
+ MR_dump_stack_record_frame(fp, prev_label_layout,
+ old_trace_sp, old_trace_curfr, print_stack_record);
}
frames_dumped_so_far++;
@@ -1029,6 +1029,84 @@
MR_print_proc_id_internal(fp, entry, MR_TRUE);
}
+/* Like islower, but ignoring locale. */
+static MR_bool
+MR_is_lower(unsigned c)
+{
+ return ((c >= 'a')
+ && (c <= 'z')
+ && (c - ('i' + 1u) >= 'j' - ('i' + 1u)) /* In ebcdic, 'j' - 'i' != 1. */
+ && (c - ('r' + 1u) >= 's' - ('r' + 1u))); /* In ebcdic, 's' - 'r' != 1. */
+ /* (For ascii, I'm fairly sure that gcc will optimize away those
+ last two conjuncts, but I'm not so sure if we did something
+ like ((c <= 'i') || (c >= 'j')). (('i' + 1 == 'j') || ...)
+ should be fine though. */
+}
+
+static MR_bool
+MR_is_alnum_or_underscore(unsigned c)
+{
+ return (MR_is_lower(c)
+ || (c == '_')
+ || ((c >= 'A')
+ && (c <= 'Z')
+ && (c - ('I' + 1u) >= 'J' - ('I' + 1u)) /* In ebcdic, 'J' - 'I' != 1. */
+ && (c - ('R' + 1u) >= 'S' - ('R' + 1u))) /* In ebcdic, 'S' - 'R' != 1. */
+ || ((c >= '0') && (c <= '9')));
+}
+
+static MR_bool
+MR_needs_quoting(char const *name)
+{
+ unsigned c = (unsigned char) *name;
+ if(!MR_is_lower(c))
+ return MR_TRUE;
+ while((c = (unsigned char) *++name) != '\0')
+ if(!MR_is_alnum_or_underscore(c))
+ return MR_TRUE;
+ return MR_FALSE;
+}
+
+static void
+MR_maybe_quote(FILE *fp, char const *name)
+{
+ if(!MR_needs_quoting(name))
+ fputs(name, fp);
+ else {
+ unsigned c;
+ putc('\'', fp);
+ for(; (c = (unsigned char) *name) != '\0'; ++name) {
+ if(isprint(c)) {
+ putc(c, fp);
+ if((c == '\\') || (c == '\''))
+ putc(c, fp);
+ /*
+ ** Don't quote apostrophes as "\'": that would make it hard to
+ ** write a regexp that matches a name. Here we use "''", which
+ ** is fairly human-friendly while needing only minor extra
+ ** regexp fluff. ([a-zA-Z_0-9]+|(?:'[^']*')+)
+ */
+ }
+ else {
+ putc('\\', fp);
+ switch(c) {
+ case '\a': putc('a', fp); break;
+ case '\b': putc('b', fp); break;
+ case '\r': putc('r', fp); break;
+ case '\f': putc('f', fp); break;
+ case '\t': putc('t', fp); break;
+ case '\n': putc('n', fp); break;
+ case '\v': putc('v', fp); break;
+ default: fprintf(fp, "%o\\", c); break;
+ }
+ }
+ }
+ putc('\'', fp);
+ /* todo: Add some test cases trying to establish that all strings not
+ containing NUL bytes are round-trippable. */
+ }
+}
+
static void
MR_print_proc_id_internal(FILE *fp, const MR_Proc_Layout *entry, MR_bool spec)
{
@@ -1042,10 +1120,11 @@
"for compiler generated procedures");
}
- fprintf(fp, "%s for %s.%s/%ld-%ld",
+ fprintf(fp, "%s for %s.",
entry->MR_sle_comp.MR_comp_pred_name,
- entry->MR_sle_comp.MR_comp_type_module,
- entry->MR_sle_comp.MR_comp_type_name,
+ entry->MR_sle_comp.MR_comp_type_module);
+ MR_maybe_quote(fp, entry->MR_sle_comp.MR_comp_type_name);
+ fprintf(fp, "/%ld-%ld",
(long) entry->MR_sle_comp.MR_comp_type_arity,
(long) entry->MR_sle_comp.MR_comp_mode);
@@ -1069,9 +1148,9 @@
fprintf(fp, " ");
}
- fprintf(fp, "%s.%s/%ld-%ld",
- entry->MR_sle_user.MR_user_decl_module,
- entry->MR_sle_user.MR_user_name,
+ fprintf(fp, "%s.", entry->MR_sle_user.MR_user_decl_module);
+ MR_maybe_quote(fp, entry->MR_sle_user.MR_user_name);
+ fprintf(fp, "/%ld-%ld",
(long) MR_sle_user_adjusted_arity(entry),
(long) entry->MR_sle_user.MR_user_mode);
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list