ghdl / ghdl-language-server

Language server based on ghdl
MIT License
91 stars 8 forks source link

'Go to context' crashes: 'files_map-editor.adb:396 explicit raise' and 'get_symbol: unhandled Context_Declaration' #6

Closed eine closed 5 years ago

eine commented 5 years ago

In VSC, I tried the following hdl-prj.json in VUnit's examples/vhdl/array_axis_vcs example:

{
    "options": {
        "ghdl_analysis": [
            "--std=08"
        ]
    },
    "files": [
        { "file": "src/fifo.vhd", "language": "vhdl" },
        { "file": "src/axis_buffer.vhd", "language": "vhdl" },
        { "file": "src/test/tb_axis_loop.vhd", "language": "vhdl" }
    ]
}

Analysis works. I can open fifo.vhd, and no errors are reported. This means that context clauses are properly parsed. I can also 'Go to Definition' of e.g. ieee_std_context, std_logic_vector or rising_edge. However, after jumping to the definition, ghdl-ls crashes.

Jumping to rising_edge first:

2019-06-17 18:26:55,591 [INFO] Args: ['/usr/local/bin/ghdl-ls', '-v']
2019-06-17 18:26:55,591 [INFO] Current directory is /tmp/files/vunit/examples/vhdl/array_axis_vcs
2019-06-17 18:26:55,591 [INFO] reading project file /tmp/files/vunit/examples/vhdl/array_axis_vcs/hdl-prj.json
2019-06-17 18:26:55,591 [INFO] Using options: ['--std=08']
2019-06-17 18:26:55,592 [INFO] loading src/fifo.vhd
2019-06-17 18:26:55,592 [INFO] loading src/axis_buffer.vhd
2019-06-17 18:26:55,592 [INFO] loading src/test/tb_axis_loop.vhd

raised CONSTRAINT_ERROR : files_map-editor.adb:396 explicit raise
[Info  - 18:27:09] Connection to server got closed. Server will restart.
[Error - 18:27:09] Request textDocument/documentSymbol failed.
Error: Connection got disposed.
    at Object.dispose (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/main.js:876:25)
    at Object.dispose (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-languageclient/lib/client.js:57:35)
    at LanguageClient.handleConnectionClosed (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-languageclient/lib/client.js:2036:42)
    at LanguageClient.handleConnectionClosed (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-languageclient/lib/main.js:127:15)
    at closeHandler (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-languageclient/lib/client.js:2023:18)
    at CallbackList.invoke (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
    at closeHandler (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/main.js:226:26)
    at CallbackList.invoke (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
    at StreamMessageWriter.fireClose (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27)
    at Socket.StreamMessageWriter.writable.on (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close [as _onclose] (net.js:596:12)
Args: ['/usr/local/bin/ghdl-ls', '-v']
Current directory: /tmp/files/vunit/examples/vhdl/array_axis_vcs
2019-06-17 18:27:09,372 [INFO] Args: ['/usr/local/bin/ghdl-ls', '-v']
2019-06-17 18:27:09,372 [INFO] Current directory is /tmp/files/vunit/examples/vhdl/array_axis_vcs
2019-06-17 18:27:09,372 [INFO] reading project file /tmp/files/vunit/examples/vhdl/array_axis_vcs/hdl-prj.json
2019-06-17 18:27:09,372 [INFO] Using options: ['--std=08']
2019-06-17 18:27:09,372 [INFO] loading src/fifo.vhd
2019-06-17 18:27:09,373 [INFO] loading src/axis_buffer.vhd
2019-06-17 18:27:09,373 [INFO] loading src/test/tb_axis_loop.vhd

Note that the server still works. This is not an unrecoverable crash. Further jumps to rising_edge, std_logic_vector or ieee_std_context works ok and it produces no additional error/crashes.

Jumping to ieee_std_context or std_logic_vector first:

2019-06-17 18:18:18,812 [ERROR] Uncaught error
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/vhdl_langserver/main.py", line 106, in main
    server.run()
  File "/usr/local/lib/python3.7/site-packages/vhdl_langserver/lsp.py", line 99, in run
    reply = self.handle(msg)
  File "/usr/local/lib/python3.7/site-packages/vhdl_langserver/lsp.py", line 117, in handle
    response = fmethod(**params)
  File "/usr/local/lib/python3.7/site-packages/vhdl_langserver/vhdl_ls.py", line 113, in textDocument_documentSymbol
    return doc.document_symbols()
  File "/usr/local/lib/python3.7/site-packages/vhdl_langserver/document.py", line 148, in document_symbols
    syms = symbols.get_symbols_chain(self._fe, nodes.Get_First_Design_Unit(self._tree))
  File "/usr/local/lib/python3.7/site-packages/vhdl_langserver/symbols.py", line 67, in get_symbols_chain
    res = [get_symbols(fe, el) for el in pyutils.chain_iter(n)]
  File "/usr/local/lib/python3.7/site-packages/vhdl_langserver/symbols.py", line 67, in <listcomp>
    res = [get_symbols(fe, el) for el in pyutils.chain_iter(n)]
  File "/usr/local/lib/python3.7/site-packages/vhdl_langserver/symbols.py", line 75, in get_symbols
    return get_symbols(fe, nodes.Get_Library_Unit(n))
  File "/usr/local/lib/python3.7/site-packages/vhdl_langserver/symbols.py", line 78, in get_symbols
    raise AssertionError("get_symbol: unhandled {}".format(pyutils.kind_image(k)))
AssertionError: get_symbol: unhandled Context_Declaration
[Error - 18:18:18] Connection to server got closed. Server will not be restarted.
[Error - 18:18:18] Request textDocument/documentSymbol failed.
Error: Connection got disposed.
    at Object.dispose (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/main.js:876:25)
    at Object.dispose (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-languageclient/lib/client.js:57:35)
    at LanguageClient.handleConnectionClosed (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-languageclient/lib/client.js:2036:42)
    at LanguageClient.handleConnectionClosed (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-languageclient/lib/main.js:127:15)
    at closeHandler (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-languageclient/lib/client.js:2023:18)
    at CallbackList.invoke (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
    at closeHandler (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/main.js:226:26)
    at CallbackList.invoke (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/events.js:120:36)
    at StreamMessageReader.fireClose (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
    at Socket.readable.on (/root/.vscode-server/extensions/tgingold.vhdl-lsp-0.1.0/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
    at Socket.emit (events.js:187:15)
    at Pipe._handle.close [as _onclose] (net.js:596:12)

The crash is unrecoverable: Connection to server got closed. Server will not be restarted.

tgingold commented 5 years ago

I think this is now fixed.

eine commented 5 years ago

Unfortunately, I cannot test it because some other issue was introduced. Now, I get:

Args: ['/usr/local/bin/ghdl-ls', '-v']
Current directory: /vunit/examples/vhdl/array_axis_vcs
2019-06-24 10:12:27,365 [INFO] Args: ['/usr/local/bin/ghdl-ls', '-v']
2019-06-24 10:12:27,365 [INFO] Current directory is /vunit/examples/vhdl/array_axis_vcs
2019-06-24 10:12:27,366 [INFO] reading project file /vunit/examples/vhdl/array_axis_vcs/hdl-prj.json
2019-06-24 10:12:27,366 [INFO] Using options: ['--std=08', '-Pvunit_out/ghdl/libraries/osvvm', '-Pvunit_out/ghdl/libraries/vunit_lib']

raised ERROROUT.OPTION_ERROR : errorout.adb:399

as soon as I open any VHDL file. Syntax highlighting works, but the language server does not.

eine commented 5 years ago

I can confirm that this is fixed now.