Rockdoor / systemverilog

SystemVerilog extension for Visual Studio Code
MIT License
12 stars 3 forks source link

Error on startup (similar to #5) #7

Open udif opened 5 years ago

udif commented 5 years ago

I got this message on the output window, and none of the features work:

[Error - 12:00:22 PM] Notification handler 'workspace/didChangeConfiguration' failed with message: Cannot read property 'symbol' of undefined

This is similar to issue #5

hfming225 commented 5 years ago

I got the same error

Rockdoor commented 5 years ago

I cannot reproduce it in my usage. Could you give me a test case?

udif commented 5 years ago

I don't know what else can I add. I tried the following steps:

  1. disabled all extensions.
  2. closed all windows
  3. enabled and reloaded this extension. So far everything is silent. Now I click on "empty.sv" in my open folder, containing only: module empty; endmodule Now, 1-2 seconds later, I get the error above, and it comes from the "Language server for SystemVerilog" log.

If it helps, here is the list of disabled extensions I had at the time (disabled especially for this test):

  "aaron-bond.better-comments",
  "CoenraadS.bracket-pair-colorizer",
  "eamodio.gitlens",
  "eirikpre.systemverilog",
  "jinsihou.diff-tool",
  "srfrnk.user-extensions",
  "wk-j.save-and-run"

Another unrelated bug I haven't open an issue for yet (because it might not exist if this bug is solved) is that the "aaron-bond.better-comments" extension above, that colors comments based on their type, does not work with your extension, but work with "eirikpre.systemverilog" when I enable it.

I'm running the latest vscode on Ubuntu 16.04.05LTS

Rockdoor commented 5 years ago

Thanks for information, udif. Unfortunately, I have not got the same situation yet. Working clean with the other extensions that you indicated.

I'm developing this on Windows10, and I tried on Ubuntu (on WSL), but it was not reproduced (I suspected the difference of path).

Can you enable option svlog.server.enLogging = ture? Once it is enabled, traces will appear in your console. Then I can find when the extension crashed, it might be helpful.

udif commented 5 years ago

OK, played a little bit with this. The error was caused by a specific file containing some verification code disabled/enabled by the preprocessor :

`ifndef NOT_USED
....
`endif

I'm toggling between ifdef/ifndef when I synthesize/verify this one-file module (the code inside this preprocessor is simply $display() loop of some constant function values. It is not a top level DV block).

The logs even contained some stack trace:

TypeError: Cannot read property 'symbol' of undefined
    at sv_preprocessor.exitPp_ifdef (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/out/sv_parser/sv_preprocessor.js:216:40)
    at Pp_ifdefContext.exitRule (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/out/sv_parser/antlr_out/SystemVerilogParser.js:34567:22)
    at ParseTreeWalker.exitRule (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/node_modules/antlr4ts/tree/ParseTreeWalker.js:79:13)
    at ParseTreeWalker.walk (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/node_modules/antlr4ts/tree/ParseTreeWalker.js:43:26)
    at sv_analyzer.parseText (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/out/sv_parser/sv_analyzer.js:51:40)
    at scanContent (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/out/server/server.js:37:9)
    at documents.onDidSave (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/out/server/server.js:154:5)
    at CallbackList.invoke (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/node_modules/vscode-jsonrpc/lib/events.js:120:36)
    at connection.onDidSaveTextDocument (/home/udif/.vscode/extensions/rockdoor.systemverilog-0.1.4/node_modules/vscode-languageserver/lib/main.js:223:33)

The preprocessor symbol NOT_USED is ofcourse undefined. Further checks revealed that changing the `ifndef to `ifdef fixes the problem. Another hint I just noticed is that `ifndef is not highlighted in the same blue color as other preprocessor commands, but it is rather appearing in white.

Looking at syntaxes/sv.tmLanguage.json, I see that `ifndef is not there.

However other than that minor syntax highlighting issue, looking at your Parser & Lexer reveals no obvious issue there. Maybe ppifndef is missing here? sv_preprocessor.js:266

let anchors = [ppifdef].concat(ppelifs).concat(ppelse_arr).concat(ppendif);
udif commented 5 years ago

Also it seems your parser has an issue with statements beginning with a delay:

always @(posedge clk)
begin
  #0 -> some_event;
end

This was found in some automatically generate code by one of the big-3 EDA vendors.

udif commented 5 years ago

And another issue is that the parser only accepts single identifiers on function input/output ports:

function f;
input integer x,y;
...

Yields an error.

Rockdoor commented 5 years ago

Understood. But preprocessing is a weak point of this extension. Very difficult to perfectly integrate text substitution into vscode editor. Please wait future updates patiently.