ruby-debug / ruby-debug-ide

An interface which glues ruby-debug to IDEs like Eclipse (RDT), NetBeans and RubyMine.
https://www.jetbrains.com/ruby/features/ruby_debugger.html
Other
370 stars 83 forks source link

"Neither gdb nor lldb was found. Aborting." when using with rubymine #161

Closed ytan1 closed 5 years ago

ytan1 commented 5 years ago

Hi, I'm trying to use rubymine 'attach to process' to debug a running server in my docker container. So basic steps are:

  1. I install ssh in docker container , set the password and use makefile to start the server in docker;
  2. I configured a remote ruby sdk in rubymine through the ssh I just set, it was connected, cool...
  3. Rubymine automatically installed debase and ruby-debug-ide in my docker container;
  4. I click 'Run' > 'Attach to Process...' then it tries to run files in ruby-debug-ide in container and I got this error: /var/lib/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide/attach/util.rb:112:inchoose_debugger': Neither gdb nor lldb was found. Aborting. (RuntimeError) from /var/lib/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide/attach/util.rb:9:in block in attach_and_return_thread' so further look into the util.rb I found line if command_exists(LLDB.to_s) returns false, which should be true, it seems to me that the command execution in command_exists method cannot find the LLDB file. So I stuck here and cannot move forward since I'm a fresh freshman in ruby and all the stuff. Ive been searching for almost a week.. Not sure if this is an issue from rdebug-ide or rubymine or myself, If this is the right place, could someone solve the problem please? Thanks so much!
ViugiNick commented 5 years ago

@ytan1 Looks like you have linux inside your container, so it seems to me that it will be more likely to use gdb in your case. Can you please try to exec command -v lldb and command -v gdb inside the container, to check it one of them is installed.

In addition, you can always install gdb by adding it you your docker image

ytan1 commented 5 years ago

@ViugiNick Thanks for reply! ha, it is a linux, after install gdb, the previous error was gone.. though new error came: From console:

executed 'gdb /usr/bin/ruby -nh -nx'executed 'gdb /usr/bin/ruby -nh -nx'

executed `attach 10` command inside gdb.executed `attach 1` command inside gdb.

Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
executed `set scheduler-locking off` command inside gdb.
Target 'exec' cannot support this command.
executed `set scheduler-locking off` command inside gdb.
Target 'exec' cannot support this command.
executed `set unwindonsignal on` command inside gdb.
executed `info threads` command inside gdb.
executed `set unwindonsignal on` command inside gdb.
executed `info threads` command inside gdb.
executed `info threads` command inside gdb.
/var/lib/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide/attach/native_debugger.rb:108:in `call_start_attach': No main thread found. Did you forget to call `update_threads`? (RuntimeError)
    from /var/lib/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide/attach/gdb.rb:45:in `call_start_attach'
    from /var/lib/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide/attach/native_debugger.rb:113:in `wait_line_event'
    from /var/lib/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide/attach/util.rb:47:in `block in attach_and_return_thread`

From rubymine prompt: Cannot connect to the debugged process at port 56479 (random)

I feel more like this is an issue for individual. The system used unicorn to spawn 1 more worker.. Maybe I should ask somewhere else

ytan1 commented 5 years ago

A little update: I solve above issue by docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined But still error:

bash: line 0: cd: /Users/user/Documents/MyLocalRepo: No such file or directory
root
Fast Debugger (ruby-debug-ide 0.6.1, debase 0.2.2.beta10, file filtering is supported)
executed 'gdb /usr/bin/ruby -nh -nx'
executed `attach 10` command inside gdb.
executed 'gdb /usr/bin/ruby -nh -nx'
executed `attach 1` command inside gdb.
81  ../sysdeps/unix/syscall-template.S: No such file or directory.
executed `set scheduler-locking off` command inside gdb.
executed `set unwindonsignal on` command inside gdb.
executed `info threads` command inside gdb.
executed `info threads` command inside gdb.
thread_info:   2    Thread 0x7fd512664700 (LWP 11) "ruby-timer-thr" 0x00007fd511cecc9d in poll () at ../sysdeps/unix/syscall-template.S:81
thread_info: * 1    Thread 0x7fd51265a740 (LWP 1) "ruby2.2" 0x00007fd511cf1913 in select ()
executed `thread 2` command inside gdb.
81  ../sysdeps/unix/syscall-template.S: No such file or directory.
executed `bt` command inside gdb.
executed `thread 1` command inside gdb.
81  ../sysdeps/unix/syscall-template.S: No such file or directory.
executed `bt` command inside gdb.
executed `thread 1` command inside gdb.
executed `call dlopen("/var/lib/gems/2.2.0/gems/debase-0.2.2.beta10/lib/attach.so", 2)` command inside gdb.
executed `call debase_start_attach()` command inside gdb.
executed `tbreak __func_to_set_breakpoint_at` command inside gdb.
continuing
81  ../sysdeps/unix/syscall-template.S: No such file or directory.
executed `set scheduler-locking off` command inside gdb.
executed `set unwindonsignal on` command inside gdb.
executed `info threads` command inside gdb.
executed `info threads` command inside gdb.
thread_info:   2    Thread 0x7fd512664700 (LWP 12) "ruby-timer-thr" 0x00007fd511cecc9d in poll () at ../sysdeps/unix/syscall-template.S:81
thread_info: * 1    Thread 0x7fd51265a740 (LWP 10) "ruby2.2" 0x00007fd511cf1913 in select ()
executed `thread 2` command inside gdb.
81  ../sysdeps/unix/syscall-template.S: No such file or directory.
executed `bt` command inside gdb.
executed `thread 1` command inside gdb.
81  ../sysdeps/unix/syscall-template.S: No such file or directory.
executed `bt` command inside gdb.
executed `thread 1` command inside gdb.
executed `call dlopen("/var/lib/gems/2.2.0/gems/debase-0.2.2.beta10/lib/attach.so", 2)` command inside gdb.
executed `call debase_start_attach()` command inside gdb.
executed `tbreak __func_to_set_breakpoint_at` command inside gdb.
continuing

Process finished with exit code -1

From prompt: Cannot connect to the debugged process at port 56479 I can't even see what the problem is.. Thanks for watching

ViugiNick commented 5 years ago

@ytan1 can you please try to turn on the Experimental debugger option in RM, so attach will use newest versions of ruby-debug-ide and debase gems

ViugiNick commented 5 years ago

@ytan1 oh, or you can try to increase timeout in RM debugger settings. Your last snippet looks just ok

ytan1 commented 5 years ago

@ViugiNick Just tried to increase timeout, it seems to solve the above issue and got a number of following exceptions in docker console:

Fatal exception in DebugThread loop: wrong number of arguments (4 for 3)
Backtrace:
/var/lib/gems/2.2.0/gems/ruby-debug-ide-0.6.1/lib/ruby-debug-ide/greeter.rb:13:in `print_greeting_msg'
  from: /root/.gem/ruby/2.2.0/gems/ruby-debug-ide-0.7.0.beta6/lib/ruby-debug-ide.rb:125:in `block (2 levels) in start_control'
  from: /root/.gem/ruby/2.2.0/gems/ruby-debug-ide-0.7.0.beta6/lib/ruby-debug-ide.rb:159:in `notify_dispatcher_if_needed'
  from: /root/.gem/ruby/2.2.0/gems/ruby-debug-ide-0.7.0.beta6/lib/ruby-debug-ide.rb:123:in `block in start_control'
10: connection failed(1)

I'll probably try another way..

ViugiNick commented 5 years ago

@ytan1 yes, updating gems should help with that

ytan1 commented 5 years ago

Sorry for the late reply! yes finally after I dealt with some issues of my own, it works now! I should mention mapping remote file to local file and uncheck Registry resync in RubyMine are necessary steps. It is cool feature of attach to process but a few of steps are not mentioned in the same place in RM doc. Hopefully this thread can help others a little bit. Thank you for your guidance, learnt something new from you ! @ViugiNick 👍 (Not sure how to close the issue)

ViugiNick commented 5 years ago

@ytan1 Will add lldb/gdb requirements to documentation. https://youtrack.jetbrains.com/issue/RUBY-23931