Skip to content

Commit

Permalink
Add output parser for Wind River Diab compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergej Sawazki committed Jul 7, 2020
1 parent eb30c49 commit bd3f8f8
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 3 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -973,15 +973,17 @@
"gcc",
"gnuld",
"msvc",
"ghs"
"ghs",
"diab"
]
},
"default": [
"cmake",
"gcc",
"gnuld",
"msvc",
"ghs"
"ghs",
"diab"
],
"scope": "resource"
},
Expand Down
2 changes: 1 addition & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"cmake-tools.configuration.cmake.ctestPath.description": "Path to CTest executable. If null, will be inferred from cmake.cmakePath (recommended to leave null).",
"cmake-tools.configuration.cmake.ctest.parallelJobs.description": "The number of parallel test jobs. Use zero to use the value of cmake.parallelJobs.",
"cmake-tools.configuration.cmake.parseBuildDiagnostics.description": "Parse compiler output for warnings and errors.",
"cmake-tools.configuration.cmake.enabledOutputParsers.description": "Output parsers to use. Supported parsers 'cmake', 'gcc', 'gnuld' for GNULD-style inker output, 'msvc' for Microsoft Visual C++, and 'ghs' for the Green Hills compiler with --no_wrap_diagnostics --brief_diagnostics.",
"cmake-tools.configuration.cmake.enabledOutputParsers.description": "Output parsers to use. Supported parsers 'cmake', 'gcc', 'gnuld' for GNULD-style inker output, 'msvc' for Microsoft Visual C++, 'ghs' for the Green Hills compiler with --no_wrap_diagnostics --brief_diagnostics, and 'diab' for the Wind River Diab compiler.",
"cmake-tools.configuration.cmake.debugConfig.description": "The debug configuration to use when debugging a target.",
"cmake-tools.configuration.cmake.debugConfig.symbolSearchPath.description": "Visual Studio debugger symbol search paths.",
"cmake-tools.configuration.cmake.debugConfig.additionalSOLibSearchPath.description": "Paths for GDB or LLDB to search for .so files.",
Expand Down
4 changes: 4 additions & 0 deletions src/diagnostics/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as vscode from 'vscode';

import * as gcc from './gcc';
import * as ghs from './ghs';
import * as diab from './diab';
import * as gnu_ld from './gnu-ld';
import * as mvsc from './msvc';
import {FileDiagnostic, RawDiagnosticParser} from './util';
Expand All @@ -20,6 +21,7 @@ export class Compilers {

gcc = new gcc.Parser();
ghs = new ghs.Parser();
diab = new diab.Parser();
gnuLD = new gnu_ld.Parser();
msvc = new mvsc.Parser();
}
Expand All @@ -45,6 +47,7 @@ export class CompileOutputConsumer implements OutputConsumer {
switch (p) {
case 'warning':
return vscode.DiagnosticSeverity.Warning;
case 'catastrophic error':
case 'fatal error':
case 'error':
return vscode.DiagnosticSeverity.Error;
Expand All @@ -60,6 +63,7 @@ export class CompileOutputConsumer implements OutputConsumer {
GCC: this.compilers.gcc.diagnostics,
MSVC: this.compilers.msvc.diagnostics,
GHS: this.compilers.ghs.diagnostics,
DIAB: this.compilers.diab.diagnostics,
link: this.compilers.gnuLD.diagnostics,
};
const arrs = util.objectPairs(by_source).map(([source, diags]) => {
Expand Down
36 changes: 36 additions & 0 deletions src/diagnostics/diab.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Module for parsing Wind River Diab diagnostics
*/ /** */


import * as vscode from 'vscode';

import {oneLess, RawDiagnosticParser, FeedLineResult} from './util';

export const REGEX
= /^\"(.*)\",\s+(?:line\s+(\d+):\s+)?(info|warning|(?:|fatal |catastrophic )error)\s+\((.*)\):\s+(.*)$/;

export class Parser extends RawDiagnosticParser {
doHandleLine(line: string) {
const mat = REGEX.exec(line);
if (!mat) {
// Nothing to see on this line of output...
return FeedLineResult.NotMine;
}

const [full, file, lineno = '1', severity, code, message] = mat;
const column = '1';
if (file && severity && message) {
return {
full,
file,
location: new vscode.Range(oneLess(lineno), oneLess(column), oneLess(lineno), 999),
severity,
code,
message,
related: [],
};
}
return FeedLineResult.NotMine;
}
}
54 changes: 54 additions & 0 deletions test/unit-tests/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,60 @@ suite('Diagnostics', async () => {
expect(path.win32.isAbsolute(diag.file)).to.be.true;
});

test('Parsing DIAB Diagnostics', () => {
const lines = [
'"C:\\path\\source\\debug\\debug.c", line 631: warning (dcc:1518): variable i is never used'
];
feedLines(build_consumer, [], lines);
expect(build_consumer.compilers.diab.diagnostics).to.have.length(1);
const diag = build_consumer.compilers.diab.diagnostics[0];

expect(diag.location.start.line).to.eq(630);
expect(diag.location.start.character).to.eq(0);
expect(diag.message).to.eq('variable i is never used');
expect(diag.file).to.eq('C:\\path\\source\\debug\\debug.c');
expect(diag.code).to.eq('dcc:1518');
expect(diag.severity).to.eq('warning');
expect(path.win32.normalize(diag.file)).to.eq(diag.file);
expect(path.win32.isAbsolute(diag.file)).to.be.true;
});

test('Parsing DIAB Diagnostics catastrophic error', () => {
const lines = [
'"C:\\path\\source\\debug\\debug.c", line 631: catastrophic error (etoa:5711): cannot open source file "../debug.h"'
];
feedLines(build_consumer, [], lines);
expect(build_consumer.compilers.diab.diagnostics).to.have.length(1);
const diag = build_consumer.compilers.diab.diagnostics[0];

expect(diag.location.start.line).to.eq(630);
expect(diag.location.start.character).to.eq(0);
expect(diag.message).to.eq('cannot open source file "../debug.h"');
expect(diag.file).to.eq('C:\\path\\source\\debug\\debug.c');
expect(diag.code).to.eq('etoa:5711');
expect(diag.severity).to.eq('catastrophic error');
expect(path.win32.normalize(diag.file)).to.eq(diag.file);
expect(path.win32.isAbsolute(diag.file)).to.be.true;
});

test('Parsing DIAB Diagnostics fatal error without line number', () => {
const lines = [
'"C:\\path\\source\\debug\\debug.c", fatal error (etoa:1635): License error: FLEXlm error: License server machine is down or not responding.'
];
feedLines(build_consumer, [], lines);
expect(build_consumer.compilers.diab.diagnostics).to.have.length(1);
const diag = build_consumer.compilers.diab.diagnostics[0];

expect(diag.location.start.line).to.eq(0);
expect(diag.location.start.character).to.eq(0);
expect(diag.message).to.eq('License error: FLEXlm error: License server machine is down or not responding.');
expect(diag.file).to.eq('C:\\path\\source\\debug\\debug.c');
expect(diag.code).to.eq('etoa:1635');
expect(diag.severity).to.eq('fatal error');
expect(path.win32.normalize(diag.file)).to.eq(diag.file);
expect(path.win32.isAbsolute(diag.file)).to.be.true;
});

test('No parsing Make errors', () => {
const lines = [
`make[2]: *** [CMakeFiles/myApp.dir/build.make:87: CMakeFiles/myApp.dir/app.cpp.o] Error 1`,
Expand Down

0 comments on commit bd3f8f8

Please sign in to comment.