[m-rev.] diff: fix another problem with mdb interactive queries on OS X

Julien Fischer jfischer at opturion.com
Wed Sep 2 20:23:08 AEST 2015


Fix another problem with mdb interactive queries on OS X.

browser/name_mangle.m:
     Fix a problem that was preventing interactive queries (and dynamic
     linking) from working in asm_fast grades on OS X.  On OS X, the dlsym
     function will add the underscore prefix to the symbol name for us,
     so this module does not need to add to it to asm labels itself.

NEWS:
     Announce that interactive queries now work on OS X.

Julien.

diff --git a/NEWS b/NEWS
index 620f672..98a00b5 100644
--- a/NEWS
+++ b/NEWS
@@ -200,6 +200,10 @@ Changes to the Mercury compiler:
  * Class files generated for executables in the Java grade are now automatically
    packaged up into Java archives (JARs).

+Change to the Mercury debugger:
+
+* Interactive queries are now supported on OS X.
+
  Changes to the extras distribution:

  * We have added support for Unicode and other enhancements to the lex and
diff --git a/browser/name_mangle.m b/browser/name_mangle.m
index fc54f9b..bf99f65 100644
--- a/browser/name_mangle.m
+++ b/browser/name_mangle.m
@@ -120,7 +120,12 @@ llds_proc_name_mangle(MercuryProc) = LabelName :-
      ),
      string.append("mercury__", LabelName3, LabelName4),
      ( if use_asm_labels then
-        string.append("_entry_", LabelName4, LabelName)
+        % On OS X dlsym will insert the leading underscore for us.
+        % XXX this has been the behaviour of dlsym on OS X since at least
+        % version 10.6, but according to the man page some older versions
+        % didn't do that.
+        EntryPrefix = ( if system_is_osx then "entry_" else "_entry_" ),
+        string.append(EntryPrefix, LabelName4, LabelName)
      else
          LabelName = LabelName4
      ).
@@ -271,6 +276,19 @@ convert_to_valid_c_identifier_2(String, Name) :-
  use_asm_labels :-
      private_builtin.sorry("use_asm_labels").

+:- pred system_is_osx is semidet.
+
+:- pragma foreign_proc("C",
+    system_is_osx,
+    [will_not_call_mercury, promise_pure, thread_safe],
+"
+#if defined(MR_MAC_OSX)
+    SUCCESS_INDICATOR = MR_TRUE;
+#else
+    SUCCESS_INDICATOR = MR_FALSE;
+#endif
+").
+
  :- pred high_level_code is semidet.

  :- pragma foreign_proc("C",



More information about the reviews mailing list