Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.83k stars 252 forks source link

different exit value depending on error #908

Closed teto closed 7 years ago

teto commented 7 years ago

I am using the vim-rtags plugin, and I wonder if 'rc' could return different exit values depending on the error, to help the plugin act appropriately. For instance, the plugin runs: rc --absolute-path -U src/nvim/screen.c:1687:15 which returns Not indexed. I would like the plugin to propose the creation of a project or at least explain why the call failed.

I could parse Not indexed but what if the string changes ? or get translated ? acting on exit values seem more robust.

Andersbakken commented 7 years ago

Sorry about the long delay. I've been a little swamped.

What an excellent idea!

I just implemented it.

The error codes are here:

Success = 0,
GeneralFailure = 32,
NetworkFailure = 33,
TimeoutFailure = 34,
NotIndexed = 35,
ConnectionFailure = 36,
ProtocolFailure = 37,
ArgumentParseError = 38,
UnexpectedMessageError = 39,
UnknownMessageError = 40

I will try my hardest not to change them. You probably don't need to act differently on the majority of these but feel free to shoot me any question you might have about which ones occur when.

Thanks.

hessryanm commented 5 years ago

What are the causes of error 32? When I try to run rc, I get no results, and an exit status 32.

raven_v2 ryanhess@ryhess-8 ~/Code/adobe/axle/build $ /usr/local/bin/rc --absolute-path -f /Users/ryanhess/Code/adobe/axle/oberon/ice_conv/xml_conv.cpp:1157:45 raven_v2 ryanhess@ryhess-8 ~/Code/adobe/axle/build $ echo $? 32

casch-at commented 5 years ago

What does rdm say when you start it with '-vvv'?

Ryan Hess notifications@github.com writes:

What are the causes of error 32? When I try to run rc, I get no results, and an exit status 32.

raven_v2 ryanhess@ryhess-8 ~/Code/adobe/axle/build $ /usr/local/bin/rc --absolute-path -f /Users/ryanhess/Code/adobe/axle/oberon/ice_conv/xml_conv.cpp:1157:45 raven_v2 ryanhess@ryhess-8 ~/Code/adobe/axle/build $ echo $? 32

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

hessryanm commented 5 years ago

Ran /usr/local/bin/rdm --verbose --inactivity-timeout=300 --log-file=/usr/local/var/log/rtags.log -vvv Waited for it to finish indexing. Ran /usr/local/bin/rc --absolute-path -f /Users/ryanhess/Code/adobe/axle/oberon/xml-handlers/reports.cpp:552:47 Only output in the rdm logs: "/usr/local/bin/rc --absolute-path -f /Users/ryanhess/Code/adobe/axle/oberon/xml-handlers/reports.cpp:552:47"

What does rdm say when you start it with '-vvv'? Ryan Hess notifications@github.com writes: What are the causes of error 32? When I try to run rc, I get no results, and an exit status 32. raven_v2 @. ~/Code/adobe/axle/build $ /usr/local/bin/rc --absolute-path -f /Users/ryanhess/Code/adobe/axle/oberon/ice_conv/xml_conv.cpp:1157:45 raven_v2 @. ~/Code/adobe/axle/build $ echo $? 32 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

casch-at commented 5 years ago

@hessryanm Hmm, whats inside the log file?

hessryanm commented 5 years ago

@cslux I'm not sure what you mean. The actual RDM process itself doesn't output anything, despite the -vvv. The log only contains that line I put - basically it lists the command it was given.

casch-at commented 5 years ago

--log-file=/usr/local/var/log/rtags.log?

hessryanm commented 5 years ago

yep I'm running tail -f /usr/local/var/log/rtags.log. The only line that appears when I run the rc command is "/usr/local/bin/rc --absolute-path -f /Users/ryanhess/Code/adobe/axle/oberon/xml-handlers/reports.cpp:552:47"

casch-at commented 5 years ago

Can you post a step by step instruction what you have done please?

Also try this please.

rdm -vvv
rc -c gcc -c <(echo 'main(){}')

rdm should output something like that:

Source::parse ( gcc -c /dev/fd/63 ) => List<String>(gcc, -c, /dev/fd/63) /home/cschwarzgruber/                                                               
Found compiler /usr/bin/gcc for gcc
parsing argument 0 gcc
Found compiler /usr/bin/gcc for gcc
parsing argument 1 -c
parsing argument 2 /dev/fd/63
Source::parse No file for gcc -c /dev/fd/63
Got 0 sources, and List<Path>() from gcc -c /dev/fd/63
hessryanm commented 5 years ago

When running the way you said, pretty sure I got the same thing: /usr/local/Cellar/rtags/2.31/bin/rdm -vvv

listening /Users/ryanhess/.rdm
Running with 12 jobs, using args: -ferror-limit=50 -Wall -fspell-checking -Wno-unknown-warning-option
Restoring /Users/ryanhess/Code/adobe/axle/ ...........................................

/usr/local/Cellar/rtags/2.31/bin/rc -c gcc -c <(echo 'main(){}')

Source::parse ( gcc -c /dev/fd/63 ) => List<String>(gcc, -c, /dev/fd/63) /Users/ryanhess/Code/adobe/axle/build/
Found compiler /usr/bin/gcc for gcc
parsing argument 0 gcc
Found compiler /usr/bin/gcc for gcc
parsing argument 1 -c
parsing argument 2 /dev/fd/63
Source::parse No file for gcc -c /dev/fd/63

When I run an actual rc command, however, the logs spit out some errors (when running with -vvv):

/usr/local/Cellar/rtags/2.31/bin/rc --absolute-path -f /Users/ryanhess/Code/adobe/axle/oberon/xml-handlers/reports.cpp:1043:21
Error during validation: /usr/local/Cellar/ice/3.7.1_1/include/Ice/BatchRequestQueueF.h /Users/ryanhess/.cache/rtags/%2FUsers%2Fryanhess%2FCode%2Fadobe%2Faxle%2F/5251/symbols doesn't exist
Failed to open /Users/ryanhess/.cache/rtags/%2FUsers%2Fryanhess%2FCode%2Fadobe%2Faxle%2F/3561/symbols /Users/ryanhess/Code/adobe/axle/oberon/xml-handlers/reports.cpp No such file or directory (2) 128
Error during validation: /usr/local/Cellar/ice/3.7.1_1/include/Ice/BatchRequestQueueF.h No such file or directory (2) 128 /Users/ryanhess/.cache/rtags/%2FUsers%2Fryanhess%2FCode%2Fadobe%2Faxle%2F/5251/symnames

It looks like the "Failed to open /Users/ryanhess/.cache/rtags/%2FUsers%2Fryanhess%2FCode%2Fadobe%2Faxle%2F/3822/symbols No such file or directory (2) 128" is the repeatable part of the issue.

casch-at commented 5 years ago

Please wipe/move the cache away and reparse the project with verbose logging enabled.

hessryanm commented 5 years ago

Log file is too big to attach here. I uploaded it on google drive: https://drive.google.com/open?id=1NOH81SsKU4H6EcMezHoFIVVqH8abJHqx

casch-at commented 5 years ago

Hmm, you could try the --enable-compiler-manager flag, your includes seem to be messed up. Can you post one or two compile commands from the compile_commands.json. You are on MacOS? Is this an opensource project.

Also pleases reparse, it with just one or two compile commands but verbose logging turned on like requested already.

rdm -vv --enable-compiler-manager

Ryan Hess notifications@github.com writes:

Log file is too big to attach here. I uploaded it on google drive: https://drive.google.com/open?id=1NOH81SsKU4H6EcMezHoFIVVqH8abJHqx

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

hessryanm commented 5 years ago

Unfortunately we aren't using cmake, we're using some weird ancient custom make extension, and we can't generate compile_commands.json.

I am on OS X, and the project is not open-source.

Here's a minimal log file. I ran rdm with /usr/local/Cellar/rtags/2.31/bin/rdm -vvv --enable-compiler-manager -L /Users/ryanhess/Code/rtags/log/rdm-verbose-single.log Then I ran rc with: /usr/local/Cellar/rtags/2.31/bin/rc --silent --compile ccache o64-clang++ .src_omni/tools/datacenter/main_datacenter-info.cpp -isystem/Users/ryanhess/Code/adobe/axle/build -I/usr/local/Cellar/readline/7.0/include -I/usr/local/Cellar/gettext/0.19.8.1/include -I/usr/local/Cellar/openssl/1.0.2r/include -I/usr/local/Cellar/lua/5.2.4_4/include/lualib.h -isystem/usr/local/include -I.src_omni -g -I.src_omni -std=c++1y -stdlib=libc++ -I/usr/local/Cellar/libxml2/2.9.4/include/libxml2 -I/usr/local/Cellar/mysql-connector-c/6.1.3/include -isystem/usr/local/include -isystem.src_omni/vlib/ext -D__STDC_LIMIT_MACROS -I'/usr/include/lua5.2' -Wall -Wextra -Wnon-virtual-dtor -Wwrite-strings -Wcast-align -Wimport -Wdisabled-optimization -Winvalid-pch -Winit-self -Wmissing-format-attribute -Wpointer-arith -Wundef -Wvolatile-register-var -Wunknown-pragmas -Wno-multichar -Wno-unused-lambda-capture -Werror -Wno-cast-align -Qunused-arguments -Wno-overloaded-virtual -Wno-deprecated-register -M -MG -MP -Wno-error rdm-verbose-single.log