svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
477 stars 31 forks source link

CodeLLDB for C++ cannot initialize due to timeout #56

Closed bertulli closed 8 months ago

bertulli commented 9 months ago

Hi again!

I'm trying to launch the debug session for an even simpler test case:

// file ~/C++/test/main.cpp
#include <cstdlib>
#include <iostream>

int main(int argc, char *argv[])
{
  int a;
  a = atoi(argv[1]);
  std::cout << a << "\n";
  return 0;
}

When I try to run M-x dape with the config codelldb-cc command-cwd "~/C++/test/" :program "main" :args ["1"] compile "g++ -o main main.cpp":

----------b---y---e---b---y---e----------

- buffer `*dape-server stderr*` shows

[ERROR codelldb::dap_session] Deserialization error: missing field seq at line 1 column 256 [ERROR codelldb::dap_session] Deserialization error: missing field seq at line 1 column 65

Process dape adapter stderr finished



It seems different from #1 .
Thanks again!
svaante commented 9 months ago

What version of jsonrpc are you using? Make sure you have the latest one.

Den tis 16 jan. 2024 20:32bertulli @.***> skrev:

Hi again!

I'm trying to launch the debug session for an even simpler test case:

// file ~/C++/test/main.cpp

include

include

int main(int argc, char *argv[]) { int a; a = atoi(argv[1]); std::cout << a << "\n"; return 0; }

When I try to run M-x dape with the config codelldb-cc command-cwd "~/C++/test/" :program "main" :args ["1"] compile "g++ -o main main.cpp":

  • the modeline keeps showing [Dape:starting]
  • buffer dape-repl shows
  • Welcome to Dape REPL! * Available Dape commands: debug, next, continue, pause, step, out, restart, kill, disconnect, quit Empty input will rerun last command.

  • Adapter server started with "~/.emacs.d/debug-adapters/codelldb/extension/adapter/codelldb --port 34825" *

  • Connection to adapter established at localhost:34825 *

and after a while it adds

  • Command initialize timeout * Initialize failed due to: timeout
  • Command disconnect timeout * Adapter connection shutdown without successfully initializing Configuration: modes (c-mode c-ts-mode c++-mode c++-ts-mode) command-args ("--port" "34825") ensure dape-ensure-command command-cwd "~/C++/test/" command "~/.emacs.d/debug-adapters/codelldb/extension/adapter/codelldb" port 34825 fn dape-config-autoport :type "lldb" :request "launch" :cwd "." :args ["1"] :program "main" compile "g++ -o main main.cpp" [ERROR codelldb::dap_session] Deserialization error: missing field seq at line 1 column 256 [ERROR codelldb::dap_session] Deserialization error: missing field seq at line 1 column 65

    • buffer dape-connection events shows

[client-reply] (id:1) Tue Jan 16 20:28:41 2024: (:jsonrpc "2.0" :id 1 :method nil :params (:clientID "dape" :adapterID "lldb" :pathFormat "path" :linesStartAt1 t :columnsStartAt1 t :supportsRunInTerminalRequest t :supportsProgressReporting t :supportsStartDebuggingRequest t)) [client-reply] (id:2) Tue Jan 16 20:28:51 2024: (:jsonrpc "2.0" :id 2 :method nil :params (:restart :json-false)) [internal] Tue Jan 16 20:29:01 2024: (:message "Connection state changed" :change "deleted\n")

----------b---y---e---b---y---e----------

  • buffer dape-server stderr shows

[ERROR codelldb::dap_session] Deserialization error: missing field seq at line 1 column 256 [ERROR codelldb::dap_session] Deserialization error: missing field seq at line 1 column 65

Process dape adapter stderr finished

It seems different from #1 https://github.com/svaante/dape/issues/1 . Thanks again!

— Reply to this email directly, view it on GitHub https://github.com/svaante/dape/issues/56, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITUPLTKGNL5ZVEWRUKRPTYO3IWPAVCNFSM6AAAAABB5LC7AWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA4DINRZGMZDKOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bertulli commented 9 months ago

I think I got the problem, I installed the package via git, so it didn't downloaded the dependent jsonrpc package. Thanks you, and sorry for bothering! Once installed the 1.0.24 version it all worked. May I suggest placing a guard in the code, using functions such as version<? As:

(when (version< (package-get-version) "1.0.19")
    (error "Version of jsonrpc is too old"))

Do you think it would help?

pawelkobojek commented 9 months ago

Edit: I thought I was running jsonrpc version 1.0.24 while, in fact, I was using the old one. Now it works perfectly with 1.0.24

Below is my original post: I encountered the exact same issue when tried to debug rust with dape. I have installed dape with straight.el if that matters. My jsonrpc version is 1.0.24.

Here's the minimal code I try to debug:

fn main() {
    let name = "World";
    let greeting = format!("Hello, {}!", name);
    println!("{}", greeting);
}

Dape REPL buffer contents:

* Welcome to Dape REPL! *
Available Dape commands: debug, next, continue, pause, step, out, restart, kill, disconnect, quit
Empty input will rerun last command.

* Adapter server started with "~/.emacs.d/debug-adapters/codelldb/extension/adapter/codelldb --port 62258 --settings {\"sourceLanguages\":[\"rust\"]}" *
* Connection to adapter established at localhost:62258 *
* Command initialize timeout *
Initialize failed due to: timeout
* Command disconnect timeout *
Adapter connection shutdown without successfully initializing
Configuration:
  modes (rust-mode rust-ts-mode)
  command-args ("--port" "62258" "--settings" "{\"sourceLanguages\":[\"rust\"]}")
  ensure dape-ensure-command
  command-cwd "/Users/pawelkobojek/Development/playground/hw/"
  command "~/.emacs.d/debug-adapters/codelldb/extension/adapter/codelldb"
  port 62258
  fn dape-config-autoport
  :type "lldb"
  :request "launch"
  :cwd "."
  :args []
  :program "target/debug/hw"
[ERROR codelldb::dap_session] Deserialization error: missing field `seq` at line 1 column 256
[ERROR codelldb::dap_session] Deserialization error: missing field `seq` at line 1 column 65
> 

and dape-connection events:

[client-reply] (id:1) Sat Jan 27 17:17:35 2024:
(:jsonrpc "2.0" :id 1 :method nil :params
          (:clientID "dape" :adapterID "lldb" :pathFormat "path" :linesStartAt1 t :columnsStartAt1 t :supportsRunInTerminalRequest t :supportsProgressReporting t :supportsStartDebuggingRequest t))
[client-reply] (id:2) Sat Jan 27 17:17:45 2024:
(:jsonrpc "2.0" :id 2 :method nil :params
          (:restart :json-false))
[internal] Sat Jan 27 17:17:55 2024:
(:message "Connection state changed" :change "deleted\n")

----------b---y---e---b---y---e----------
svaante commented 9 months ago

Hey @pawelkobojek emacs has not loaded an jsonrpc version <= 1.0.21 this is why you are getting this error.

Could you please share your way of installing dape so I can figure out why it doesn't pull the required jsonrpc version.

pawelkobojek commented 9 months ago

I've used straight with use-package. Here's na excerpt from my init file.

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

(use-package dape
  :config
  (setq dape-cwd-fn 'projectile-project-root))

I then installed jsonrpc manually with list-packages but it didn't help, even though list-packages reported version 1.0.24. I ended up rebuilding my Emacs (I'm running Emacs 30).

Let me know if you need any more info

timcharper commented 8 months ago

Yes please on the version assertion; I also installed from git

svaante commented 8 months ago

Warning added in e84de3d great input