6

I'm struggling to get vim (8.0 (2016 Sep 12)) to parse the output of my build system, and need help with defining my errorformat. The default gcc efm appears to not be matching any lines, so in quickfix I see basically every line of make output, but the lines that actually contain errors show up with odd characters inserted.

Example make output:

make: Entering directory '/home/tblack/SourceRAM/la/Blocks'
ZYNQ_GPP src/avpcva.cpp
src/avpcva.cpp: In destructor 'virtual Blocks::AVPCVA::~AVPCVA()':
src/avpcva.cpp:152:49: error: 'class AVBC::STC' has no member named 'getHandle'
         uint16_t handle = stIter->second->getHandle();
                                                 ^

For the above make output, the quickfix list shows:

|| make: Entering directory '/home/tblack/SourceRAM/la/Blocks'
|| ZYNQ_GPP src/avpcva.cpp
|| ^[[01m^[[Ksrc/avpcva.cpp:^[[m^[[K In destructor '^[[01m^[[Kvirtual Blocks::AVPCVA::~AVPCVA()^[[m^[[K':
|| ^[[01m^[[Ksrc/avpcva.cpp:152:49:^[[m^[[K ^[[01;31m^[[Kerror: ^[[m^[[K'^[[01m^[[Kclass AVBC::STC^[[m^[[K' has no member named '^[[01m^[[Kget    Handle^[[m^[[K'
||          uint16_t handle = stIter->second->getHandle();
|| ^[[01;32m^[[K                                                 ^^[[m^[[K

The default errorformat for vim's gcc compiler plugin (amazingly) does not appear to beconfigured to support multi-line output (doesn't include any of %E, %C, %Z). I suspect that I just need to adjust my errorformat accordingly, but:

  1. Would my using the default efm explain the odd characters in my quickfix?
  2. I could use help with the specification of an efm that will correctly parse my make output. I have been reading the vim docs and browsing the web for days and still not making headway on demystifying and troubleshooting multiline errorformats in vim.

I took a stab at this, using the errorformat below. The first line attempts to define my multi-line error format start(%E)/continue(%C)/end(%Z).

set errorformat =%E%f:%l:%c:\ %trror:\ %m,%-C,%-Z%p^
set errorformat+=%D%*\\a:\ Entering\ directory\ [`']%f'
set errorformat+=%X%*\\a:\ Leaving\ directory\ [`']%f'

But it does not result in any different behavior from what I described above.

Thank you.

2
  • It appears this might not be a vim issue after all, as I'm also seeing these characters when I redirect stdout + stderr from my make command to a file. For anyone looking here for help on troubleshooting multiline errorformat, this question has a very helpful response: stackoverflow.com/questions/16718444/…
    – timblaktu
    Commented Nov 13, 2017 at 21:40
  • The "odd characters" you see are ANSI escape codes, specifically, CSI sequences. In your pasted output, ^[ is the notation for an escape character. So, for example: ^[[01m is esc[01m or CSI 1 m, which is the escape sequence for the start of some bold text and, later in the line, ^[[m is CSI m which is the same as CSI 0 m: return to normal (non-bold) text. See en.wikipedia.org/wiki/ANSI_escape_code#Escape_sequences if you fancy translating the rest of them, too.
    – Rich
    Commented Nov 13, 2017 at 23:18

1 Answer 1

1

I was able to eliminate the escape codes by changing the -fdiagnostics-color option in gcc. So this answers my first question (the escape codes in vim's make output were caused by a gcc option that colorizes its output, and had nothing to do with vim).

I (mostly) answered my second question too. I was using this errorformat:

set errorformat =%E%f:%l:%c:\ %trror:\ %m,%-Z%p^,%+C%.%#
set errorformat+=%D%*\\a:\ Entering\ directory\ [`']%f'
set errorformat+=%X%*\\a:\ Leaving\ directory\ [`']%f'
set errorformat+=%-G%.%#

and it was correctly picking out all the multi-line error lines, and showing these in the quickfix (one line per error, as I've specified), but I could not jump to the source location. I assumed the quickfix-directory-stack is messed up, and changed the above %D and %X efm lines (which I copied from the defaults in gcc.vim) above to:

set errorformat+=%D%*\\a:\ Entering\ directory\ '%f'
set errorformat+=%X%*\\a:\ Leaving\ directory\ '%f'

This results in a sane quickfix-directory-stack, and now the quickfix window is working on all counts.

But, I must ask, is this a bug in the default patterns for parsing Entering/Leaving directories in gcc.vim? Why was it using [`']%f' instead of '%f'?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.