From e5447a86f81393062443df5850b9e9c01303c137 Mon Sep 17 00:00:00 2001 From: Denis Isaev Date: Wed, 11 Jun 2014 13:21:41 +0400 Subject: [PATCH 1/4] Add plugin python directory to python modules search path to fix 'gccutils not found' error --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index fc8bbeee..cc034e61 100644 --- a/Makefile +++ b/Makefile @@ -234,6 +234,10 @@ install: $(PLUGIN_DSO) gcc-with-$(PLUGIN_NAME).1.gz cp -a gccutils $(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR) cp -a libcpychecker $(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR) + # add python dir to python search path + mkdir -p $(shell $(PYTHON) -m site --user-site) + echo "$(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR)" > $(shell $(PYTHON) -m site --user-site)/gcc-python-plugin.pth + # Create "gcc-with-" support script: mkdir -p $(DESTDIR)$(bindir) install -m 755 gcc-with-python $(DESTDIR)/$(bindir)/gcc-with-$(PLUGIN_NAME) From 1e6bc28db0aefc7ab42b919b9355e1ba3d8174a1 Mon Sep 17 00:00:00 2001 From: Denis Isaev Date: Fri, 13 Jun 2014 18:25:39 +0400 Subject: [PATCH 2/4] Fix crashing on expr 'var = {CLOBBER};', because location of such expression has NULL filename --- gcc-c-api/gcc-location.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc-c-api/gcc-location.c b/gcc-c-api/gcc-location.c index c3b26875..d4e1d842 100644 --- a/gcc-c-api/gcc-location.c +++ b/gcc-c-api/gcc-location.c @@ -54,7 +54,7 @@ GCC_IMPLEMENT_PUBLIC_API (int) gcc_location_get_column (gcc_location loc) GCC_PUBLIC_API (bool) gcc_location_is_unknown (gcc_location loc) { - return UNKNOWN_LOCATION == loc.inner; + return UNKNOWN_LOCATION == loc.inner || !gcc_location_get_filename(loc); } GCC_IMPLEMENT_PUBLIC_API (bool) gcc_location_get_in_system_header (gcc_location loc) From 91906fa5527a36a17b239b2a6b174aac4a3e599b Mon Sep 17 00:00:00 2001 From: Denis Isaev Date: Sat, 21 Jun 2014 21:20:50 +0400 Subject: [PATCH 3/4] Fix exception in case of unrecognized source file encoding --- gccutils/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gccutils/__init__.py b/gccutils/__init__.py index 2d3064a5..2c8c5d2f 100644 --- a/gccutils/__init__.py +++ b/gccutils/__init__.py @@ -24,7 +24,10 @@ def sorted_dict_repr(d): def get_src_for_loc(loc): # Given a gcc.Location, get the source line as a string import linecache - return linecache.getline(loc.file, loc.line).rstrip() + try: + return linecache.getline(loc.file, loc.line).rstrip() + except SyntaxError: # unrecognized encoding of file + return '' def get_field_by_name(typeobj, name): check_isinstance(typeobj, From f9c2d2242fe3290818b9c13e57089bd01cb9e9a2 Mon Sep 17 00:00:00 2001 From: Denis Isaev Date: Sun, 28 Dec 2014 13:32:56 +0000 Subject: [PATCH 4/4] fix site dir --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cc034e61..229a6383 100644 --- a/Makefile +++ b/Makefile @@ -99,6 +99,7 @@ PYTHON_CONFIG=python-config PYTHON_INCLUDES=$(shell $(PYTHON_CONFIG) --includes) PYTHON_LIBS=$(shell $(PYTHON_CONFIG) --libs) +PYTHON_SITE_DIR=$(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") # Support having multiple named plugins # e.g. "python2.7" "python3.2mu" "python 3.2dmu" etc: @@ -235,8 +236,8 @@ install: $(PLUGIN_DSO) gcc-with-$(PLUGIN_NAME).1.gz cp -a libcpychecker $(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR) # add python dir to python search path - mkdir -p $(shell $(PYTHON) -m site --user-site) - echo "$(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR)" > $(shell $(PYTHON) -m site --user-site)/gcc-python-plugin.pth + mkdir -p $(PYTHON_SITE_DIR) + echo "$(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR)" > $(PYTHON_SITE_DIR)/gcc-python-plugin.pth # Create "gcc-with-" support script: mkdir -p $(DESTDIR)$(bindir)