[mercury-users] Trouble debugging in 11.01 beta on mac

Julien Fischer juliensf at csse.unimelb.edu.au
Sun Mar 13 16:38:39 AEDT 2011


Hi,

On Sat, 12 Mar 2011, David Parks wrote:

> I'm going through the user's guide and I'm trying to follow the
> examples in the guide but I can't seem to make a debug build.  This is
> on MacOS 10.6 with gcc 4.2.1 (XCode 3.2.5).  Its a standard install of
> Mercury with the only change being that I also installed the java
> grade.
>
> The manual says that to make a debug build, run:
> mmc --debug hello.m
>
> I get this error on mac:
>
> mercury_compile: debugging is available only in low level C grades
>
> The mac instructions say that "none" is the default grade on mac and
> that asm and... something else aren't available.  I'd assume that none
> is correct but I also tried some other things (pretty randomly... I'm
> definitely still learning).  I had the most luck with this:

The instructions in README.MacOS do indeed refer to "none" (specifically
the grade "none.gc"), but what they are referring to is the grade that
will be used to build the Mecury compiler itself, not the default grade
that the compiler will ithen use to build programs.  The latter is always
hlc.gc on Mac OS X systems (barring the user setting it to something
else manually).  I will modify README.MacOS to clarify this situation.

The effect of the --debug option is to add the "debug" grade component,
to the currently selected grade.  On an installation using hlc.gc
as the default grade, the following

    mmc --debug hello

is effectively a request to build the program in the grade hlc.gc.debug.
(There is no such grade since mdb style debugging does not exist for
the high-level c (hlc) backend.)

> mmc -s none.gc.debug --debug hello.m
>
> Which produced a linker error:
>
> Undefined symbols:
>   "_MR_grade_v16_none_gc_tags3_ubf_debug9", referenced from:
>       _MR_grade in hello_init.o
>       _MR_grade in hello.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status

That type of error from the linker is generally an indication that some
of the object files generated by the compiler have been generated in a
different grade from the one you are attempting to use.

(The background here is that, in general, object files built in
different grades are incompatible; the Mercury system tries to catch
attempts to link object files built in different grades by generating a
grade-specific symbol in the runtime and the generating a reference to
that symbol in each object file.  Since the symbol is grade-specific,
object files built in a different grade will refer to a symbol of a
different name than the one defined in the runtime and you get the
above linker error.)

> (I get exactly the same message with "none.gc".)
>
> Any thoughts on how I can get past this?  I have been able to run
> normal c builds, java builds, and a static library so my installation
> can't be completely fubar.

I would first of all clean up any generated files that may be lying
about and then try again.

If that doesn't work, then you should check that the libraries are
installed in the grades you are attempting to use, e.g. do

     mmc --output-libgrades

and check that none.gc or none.gc.debug are listed amonst the output.

If all that fails, let us know and we will look into it further.

(As an aside, I would recommend using mmc's --make option; it should
report give better error messages if library grades are not available.
Also, if you are going to swap between grades, you should consider
using the --use-grade-subdirs option with --make.)

Julien.


More information about the users mailing list