Add a way to demangle C++ symbols
Gael Thomas [Thu, 10 Oct 2013 14:34:18 +0000 (16:34 +0200)]
Change-Id: If1c2831169a3a388c0702bea29b54cc5fdffd51c

scilab/modules/jit/Makefile.am
scilab/modules/jit/Makefile.in
scilab/modules/jit/src/perl/demangle.pl [new file with mode: 0644]

index eea4cef..08ff6fc 100644 (file)
@@ -74,7 +74,7 @@ testControlExp_LDADD  = $(check_LDADD)
 # This target transforms a basic code to llvm + clang code for the JIT
 BUILT_SOURCES = src/cpp/llvm-wrapper-generated.cpp
 src/cpp/llvm-wrapper-generated.cpp: src/cpp/llvm-wrapper.cpp
-       clang++ -emit-llvm  -I$(top_srcdir)/modules/types/includes/ -I$(top_srcdir)/modules/operations/includes/ -I$(top_srcdir)/modules/core/includes/  -I$(top_srcdir)/modules/ast/includes/ -I$(top_srcdir)/modules/localization/includes/ -I$(top_srcdir)/modules/symbol/includes/ -I$(top_srcdir)/modules/dynamic_link/includes/ $(EIGEN_CPPFLAGS) -c src/cpp/llvm-wrapper.cpp -o - |  llc-3.3 -march=cpp -cppgen=contents -o src/cpp/llvm-wrapper-generated.cpp || exit 1
+       clang++ -emit-llvm  -I$(top_srcdir)/modules/types/includes/ -I$(top_srcdir)/modules/operations/includes/ -I$(top_srcdir)/modules/core/includes/  -I$(top_srcdir)/modules/ast/includes/ -I$(top_srcdir)/modules/localization/includes/ -I$(top_srcdir)/modules/symbol/includes/ -I$(top_srcdir)/modules/dynamic_link/includes/ $(EIGEN_CPPFLAGS) -c src/cpp/llvm-wrapper.cpp -o - |  llc-3.3 -march=cpp -cppgen=contents -o - | perl src/perl/demangle.pl > src/cpp/llvm-wrapper-generated.cpp || exit 1
 
 include $(top_srcdir)/Makefile.incl.am
 
index c6f6a25..2f08dd7 100644 (file)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.3 from Makefile.am.
+# Makefile.in generated by automake 1.14 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -157,7 +157,8 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)" \
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
 libscijit_la_LIBADD =
 am__objects_1 = libscijit_la-jitter.lo
-am__objects_2 = libscijit_la-sci_runVMKit.lo
+am__objects_2 = libscijit_la-jit_gw.lo libscijit_la-sci_enableJIT.lo \
+       libscijit_la-sci_disableJIT.lo libscijit_la-sci_isJIT.lo
 am_libscijit_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libscijit_la_OBJECTS = $(am_libscijit_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -512,7 +513,10 @@ JIT_CPP_SOURCES = \
        src/cpp/jitter.cpp
 
 GATEWAY_CPP_SOURCES = \
-sci_gateway/cpp/sci_runVMKit.cpp
+       sci_gateway/cpp/jit_gw.cpp \
+    sci_gateway/cpp/sci_enableJIT.cpp \
+    sci_gateway/cpp/sci_disableJIT.cpp \
+    sci_gateway/cpp/sci_isJIT.cpp
 
 libscijit_la_CPPFLAGS = \
        -Iincludes \
@@ -716,8 +720,11 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscijit_la-jit_gw.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscijit_la-jitter.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscijit_la-sci_runVMKit.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscijit_la-sci_disableJIT.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscijit_la-sci_enableJIT.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscijit_la-sci_isJIT.Plo@am__quote@
 
 .cpp.o:
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -747,12 +754,33 @@ libscijit_la-jitter.lo: src/cpp/jitter.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscijit_la-jitter.lo `test -f 'src/cpp/jitter.cpp' || echo '$(srcdir)/'`src/cpp/jitter.cpp
 
-libscijit_la-sci_runVMKit.lo: sci_gateway/cpp/sci_runVMKit.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscijit_la-sci_runVMKit.lo -MD -MP -MF $(DEPDIR)/libscijit_la-sci_runVMKit.Tpo -c -o libscijit_la-sci_runVMKit.lo `test -f 'sci_gateway/cpp/sci_runVMKit.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_runVMKit.cpp
-@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscijit_la-sci_runVMKit.Tpo $(DEPDIR)/libscijit_la-sci_runVMKit.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_runVMKit.cpp' object='libscijit_la-sci_runVMKit.lo' libtool=yes @AMDEPBACKSLASH@
+libscijit_la-jit_gw.lo: sci_gateway/cpp/jit_gw.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscijit_la-jit_gw.lo -MD -MP -MF $(DEPDIR)/libscijit_la-jit_gw.Tpo -c -o libscijit_la-jit_gw.lo `test -f 'sci_gateway/cpp/jit_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/jit_gw.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscijit_la-jit_gw.Tpo $(DEPDIR)/libscijit_la-jit_gw.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/jit_gw.cpp' object='libscijit_la-jit_gw.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscijit_la-sci_runVMKit.lo `test -f 'sci_gateway/cpp/sci_runVMKit.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_runVMKit.cpp
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscijit_la-jit_gw.lo `test -f 'sci_gateway/cpp/jit_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/jit_gw.cpp
+
+libscijit_la-sci_enableJIT.lo: sci_gateway/cpp/sci_enableJIT.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscijit_la-sci_enableJIT.lo -MD -MP -MF $(DEPDIR)/libscijit_la-sci_enableJIT.Tpo -c -o libscijit_la-sci_enableJIT.lo `test -f 'sci_gateway/cpp/sci_enableJIT.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_enableJIT.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscijit_la-sci_enableJIT.Tpo $(DEPDIR)/libscijit_la-sci_enableJIT.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_enableJIT.cpp' object='libscijit_la-sci_enableJIT.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscijit_la-sci_enableJIT.lo `test -f 'sci_gateway/cpp/sci_enableJIT.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_enableJIT.cpp
+
+libscijit_la-sci_disableJIT.lo: sci_gateway/cpp/sci_disableJIT.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscijit_la-sci_disableJIT.lo -MD -MP -MF $(DEPDIR)/libscijit_la-sci_disableJIT.Tpo -c -o libscijit_la-sci_disableJIT.lo `test -f 'sci_gateway/cpp/sci_disableJIT.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_disableJIT.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscijit_la-sci_disableJIT.Tpo $(DEPDIR)/libscijit_la-sci_disableJIT.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_disableJIT.cpp' object='libscijit_la-sci_disableJIT.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscijit_la-sci_disableJIT.lo `test -f 'sci_gateway/cpp/sci_disableJIT.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_disableJIT.cpp
+
+libscijit_la-sci_isJIT.lo: sci_gateway/cpp/sci_isJIT.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscijit_la-sci_isJIT.lo -MD -MP -MF $(DEPDIR)/libscijit_la-sci_isJIT.Tpo -c -o libscijit_la-sci_isJIT.lo `test -f 'sci_gateway/cpp/sci_isJIT.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_isJIT.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscijit_la-sci_isJIT.Tpo $(DEPDIR)/libscijit_la-sci_isJIT.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_isJIT.cpp' object='libscijit_la-sci_isJIT.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscijit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscijit_la-sci_isJIT.lo `test -f 'sci_gateway/cpp/sci_isJIT.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_isJIT.cpp
 
 mostlyclean-libtool:
        -rm -f *.lo
@@ -998,7 +1026,7 @@ uninstall-am: uninstall-libscijit_la_includeHEADERS \
        uninstall-pkglibLTLIBRARIES
 
 src/cpp/llvm-wrapper-generated.cpp: src/cpp/llvm-wrapper.cpp
-       clang++ -emit-llvm  -I$(top_srcdir)/modules/types/includes/ -I$(top_srcdir)/modules/operations/includes/ -I$(top_srcdir)/modules/core/includes/  -I$(top_srcdir)/modules/ast/includes/ -I$(top_srcdir)/modules/localization/includes/ -I$(top_srcdir)/modules/symbol/includes/ -I$(top_srcdir)/modules/dynamic_link/includes/ $(EIGEN_CPPFLAGS) -c src/cpp/llvm-wrapper.cpp -o - |  llc-3.3 -march=cpp -cppgen=contents -o src/cpp/llvm-wrapper-generated.cpp || exit 1
+       clang++ -emit-llvm  -I$(top_srcdir)/modules/types/includes/ -I$(top_srcdir)/modules/operations/includes/ -I$(top_srcdir)/modules/core/includes/  -I$(top_srcdir)/modules/ast/includes/ -I$(top_srcdir)/modules/localization/includes/ -I$(top_srcdir)/modules/symbol/includes/ -I$(top_srcdir)/modules/dynamic_link/includes/ $(EIGEN_CPPFLAGS) -c src/cpp/llvm-wrapper.cpp -o - |  llc-3.3 -march=cpp -cppgen=contents -o - | perl src/perl/demangle.pl > src/cpp/llvm-wrapper-generated.cpp || exit 1
 
 # This target enables tests for Scilab
 check-local: $(top_builddir)/scilab-bin test
diff --git a/scilab/modules/jit/src/perl/demangle.pl b/scilab/modules/jit/src/perl/demangle.pl
new file mode 100644 (file)
index 0000000..f5faecc
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+# In the generated file, replace the mangled symbols by the classical C++
+# symbol
+
+use strict;
+
+while (<>) {
+               if(/(.*)(\".*\")(.*)/) {
+                               my $command = "c++filt -n $2";
+                               my $k = `$command`;
+                               chomp $k;
+                               print "$1\"$k\"$3";
+               } else {
+                               print "$_"
+    }
+} 
+