Comments (1)
I'll write down the process of debugging this as I do it:
My first approach is to run the executable under lldb to see if the crash is happening in C/C++ code. If it is, this will give me a stack trace and usually the problem is immediately clear.
If the crash is happening in Haskell code, lldb is generally not as useful. In this case I usually add additional print statements to the crashing code to determine exactly where the crash happens. (I could also use ghci for this, but editing the actual source is convenient since you can run it over and over and verify whether the problem is fixed.)
Generally knowing where the crash is tells me the source of the problem immediately. In this case the crash happens in Clang.String.unpack
, which means Clang.Cursor.getIncludedFile
returned a null value and probably needs to return a Maybe (File s)
instead of a File s
.
At that point looking at the source of Clang.Cursor.getIncludedFile
will tell me the low-level FFI function that it calls - in this case Clang.Internal.FFI.getIncludedFile
, which is defined in FFI.gc
. I can see from there that the C-level function being called is clang_getIncludedFile
. (The mapping between the various names is obvious in this case but sometimes it's less straightforward).
To verify my guess that clang_getIncludedFile
may fail and return null, I check its definition at the C level in clang/include/clang-c/Index.h
. It seems pretty clear that it's only designed to be called on inclusion directives. At the Haskell level, then, we definitely need it to return a Maybe, since we have no type-level way of restricting the kind of cursor you can pass in.
To fix this, then, I just need to update the definition of getIncludedFile
in FFI.gc
and the functions that call it. The details of doing that require some knowledge of greencard
but it's pretty easy to pick up. In this case we've needed this in several other places and there's already a maybe_file
"dis" available, so it's a very simple change.
You can view the referenced commit to see exactly what I did. If you feel comfortable debugging issues like this, we'd love to have the help!
from libclang.
Related Issues (20)
- LibClang won't build on the Haskell Platform 2013.2 because greencard is broken HOT 2
- libpthread symbol error? HOT 3
- Provide access to libclang headers needed for accurate parsing HOT 3
- Libclang on hackage doesn't compile (github master does compile) HOT 7
- Pull boundary values out of enumerations
- Make LibClang version track LLVM version HOT 2
- Make `newbuild` branch link correctly on OS X HOT 21
- Use --with-clang-resource-dir configure option HOT 1
- hackage greencard dependency won't build on 7.8 HOT 2
- Cabal 1.20 breaks Setup.hs HOT 13
- Crash when trying to enumerate Top Level Headers HOT 3
- Add an option to use out-of-tree llvm and clang HOT 4
- De-couple from Greencard HOT 3
- New release? HOT 2
- 3.4.0 Haddock Docs Have Not Been Built HOT 1
- Installing via Stack fails due to missing dist/build/Clang/Internal/FFI.chs.c HOT 1
- Doesn't build under Ubuntu HOT 3
- Doesn't build with ghc 8.0.1 HOT 2
- Static builds HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libclang.