Home Download Buy Blog Forum Support

clang (C/C++/Objective-C/Objective-C++) autocomplete

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby sublimator on Sun Jun 24, 2012 4:42 am

So, I just got a lockup, the console was open and there was a traceback:

Code: Select all
Traceback (most recent call last):

    File ".\sublimeclang.py", line 553, in recompile
    File ".\translationunitcache.py", line 776, in reparse
    File ".\translationunitcache.py", line ???, in get_opts_script
    File ".\common.py", line 82, in expand_path

TypeError: unsupported operand type(s) for %:  'NoneType' and 'dict'


(FFFF I just typed that in by hand and seem to have fucked up one of the line numbers :))

Dunno how it's related to the lockup, but that 's the last bit info in the console.
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 648
Joined: Thu Mar 20, 2008 5:41 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby sublimator on Sun Jun 24, 2012 4:56 am

From a superficial look, not really understanding the why/what/how of the locking , I can see a lack of try/finally with some uses of the locks, so an exception will mean the lock doesn't get released.

Seems like it's a `dictlike.get(key, None) % dict()` situation

Will take a look
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 648
Joined: Thu Mar 20, 2008 5:41 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby sublimator on Sun Jun 24, 2012 5:01 am

Ah, using a Lock() instead of a reentrant lock, which if you grab in the same thread again, won't cause these locks.

I made a 1 character change to RLock and that same exception no longer causes the freeze.

Code: Select all
Traceback (most recent call last):
  File ".\sublimeclang.py", line 553, in recompile
  File ".\translationunitcache.py", line 776, in reparse
  File ".\translationunitcache.py", line 806, in get_opts_script
  File ".\common.py", line 82, in expand_path
TypeError: unsupported operand type(s) for %: 'NoneType' and 'dict'


I'll patch LockedVariable to make it a context manager.
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 648
Joined: Thu Mar 20, 2008 5:41 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby sublimator on Sun Jun 24, 2012 6:09 am

Is there any way to get contextually aware auto completion?

For example, say I have my cursor, represented as "|", inside `#include <|`, I'm getting completion choices for macros and what have you.
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 648
Joined: Thu Mar 20, 2008 5:41 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby quarnster on Sun Jun 24, 2012 6:43 am

You can disable the fast completions with alt+d,alt+f which will then fall back to clang's built in autocomplete functionality which is more accurate but slower.
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby sublimator on Sun Jun 24, 2012 7:28 am

Sweet, cheers :D

I'll be sending you some paypal love when I have some credit.

I've been getting paid cash via western union so nothing in the pig atm :roll:
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 648
Joined: Thu Mar 20, 2008 5:41 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby quarnster on Sun Jun 24, 2012 7:29 am

How did you end up in the situation where options_script is None anyway? Because by default it's set to "" so wouldn't trigger this issue...
Code: Select all
09:11 /tmp/SublimeClang $ curl -O http://cloud.github.com/downloads/quarnster/SublimeClang/SublimeClang.sublime-package
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 11.1M  100 11.1M    0     0  4207k      0  0:00:02  0:00:02 --:--:-- 4330k
09:11 /tmp/SublimeClang $ unzip SublimeClang.sublime-package
Archive:  SublimeClang.sublime-package
  inflating: Context.sublime-menu   
  inflating: Default.sublime-commands 
  inflating: Default.sublime-keymap 
  inflating: Main.sublime-menu       
  inflating: README.creole           
  inflating: SublimeClang.sublime-settings 
   creating: clang/
  inflating: clang/__init__.py       
  inflating: clang/cindex.py         
   creating: clang/include/
  inflating: clang/include/altivec.h 
  inflating: clang/include/arm_neon.h 
  inflating: clang/include/avxintrin.h 
  inflating: clang/include/emmintrin.h 
  inflating: clang/include/float.h   
  inflating: clang/include/immintrin.h 
  inflating: clang/include/iso646.h 
  inflating: clang/include/limits.h 
  inflating: clang/include/mm3dnow.h 
  inflating: clang/include/mm_malloc.h 
  inflating: clang/include/mmintrin.h 
  inflating: clang/include/nmmintrin.h 
  inflating: clang/include/pmmintrin.h 
  inflating: clang/include/smmintrin.h 
  inflating: clang/include/stdalign.h 
  inflating: clang/include/stdarg.h 
  inflating: clang/include/stdbool.h 
  inflating: clang/include/stddef.h 
  inflating: clang/include/stdint.h 
  inflating: clang/include/tgmath.h 
  inflating: clang/include/tmmintrin.h 
  inflating: clang/include/varargs.h 
  inflating: clang/include/wmmintrin.h 
  inflating: clang/include/x86intrin.h 
  inflating: clang/include/xmmintrin.h 
  inflating: common.py               
  inflating: errormarkers.py         
  inflating: libcache.dll           
  inflating: libcache.dylib         
  inflating: libcache_x64.dll       
  inflating: libclang.dll           
  inflating: libclang.dylib         
  inflating: libclang_x64.dll       
  inflating: package.json           
   creating: parsehelp/
extracting: parsehelp/__init__.py   
  inflating: parsehelp/parsehelp.py 
   creating: src/
   creating: src/clang-c/
  inflating: src/clang-c/Index.h     
  inflating: src/CMakeLists.txt     
  inflating: src/main.cpp           
  inflating: staticanalyzer.py       
  inflating: sublimeclang.py         
  inflating: sublimeclang.sublime-project 
  inflating: translationunitcache.py 
09:11 /tmp/SublimeClang $ cat SublimeClang.sublime-settings | grep options_script
    "options_script": "",
09:11 /tmp/SublimeClang $


The right fix is to do try finally blocks as there shouldn't be a need for reentrance. I'll patch this up.
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby sublimator on Sun Jun 24, 2012 7:42 am

how did you end up in the situation where options_script is None ?


Code: Select all
return expand_path(get_setting("options_script", None, view), view.window())


I think after nuking/recloning fresh I just rewound the history on the settings file using a backups plugin. The keys must have changed.

I'll revert it to make sure I have all the latest settings.

The right fix is to do try finally blocks as there shouldn't be a need for reentrance


Yeah, I just changed it to use RLock as it was a quick 1 character fix to stop it locking so I could take a look at the code.

I don't like editing in notepad LOL

I'll patch this up.


Context managers, ie with blocks, are nice for that. Saves having try/finally every where.
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 648
Joined: Thu Mar 20, 2008 5:41 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby RyanJ on Mon Jun 25, 2012 3:12 pm

quarnster wrote:RyanJ, I think your issue has been fixed. As issue 74 hasn't been fixed yet, could you use package control to remove SublimeClang, quit Sublime Text 2, delete the SublimeClang package folder and then re-install it via Package Control and see if the issue is gone now please?


Thanks, no luck though. I've tried making a test project with the same include paths, but the error is sporadic. I don't think that the one path which caused the error before is really the issue -- it seems to be something else which happened to be triggered in this case.

I printed out the filename & opts in translationunitcache.py in the parse/reparse functions, but nothing seemed unusual.
RyanJ
 
Posts: 18
Joined: Mon Sep 26, 2011 1:59 pm

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby quarnster on Mon Jun 25, 2012 3:40 pm

RyanJ, You could compile libcache (and possibly libclang too) yourself with debug symbols enabled, and you should be able to attach a debugger to Sublime Text 2 and get a proper stacktrace for this issue.
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 4 guests