VSCode Ruby extension no longer mantained

It should. The issue is that VSCode deprecated the extension that used to support it. That shouldn’t affect other IDEs.

1 Like

I too tried various other VSCode Ruby debug extensions and couldn’t get any of them to connect to Sketchup. I don’t know enough TypeScript or VSCode extension coding to be of any help beyond trying it when you think it is ready, but please keep us posted here about your progress. Thanks for your effort!

1 Like

Any progress to report? Anything we can do to help?

@slbaumgartner

I’m working on the project, but due to professional commitments, it’s slower than I would like.
I believe that in two or three weeks I will have a minimally usable version.
At the moment I don’t need help yet, but I will need it for generation and testing on MacOS and Linux.

Thanks

2 Likes

Sirs,

I’m already sending breakpoint commands, but I believe there is an error in my workflow.

When adding a breakpoint, I expect to receive a warning/message from SURubyDebugger when reached, but this does not happen.

My flow is:

  • connect to the remote port
  • send “start” command
  • send “breakpoint” command, which responds as expected
  • I go to the SU and trigger the action that will reach the breakpoint, but nothing happens.

Is there a formal specification of the RDebug protocol used by SURubyDebugger or something that describes the operation/flow?

Any suggestion?

Thanks in advance

PS: Sorry my bad english or if this is not the correct place to post.

Below is a conversation with the debugger. The lines in color are responses from Sketchup to VSCODE.

Step by Step

  • set a breakpoint
  • receive a response with the ID number of the breakpoint
  • enable the breakpoint
  • receive breakpoint enabled message
  • when the code stops at a break point, receive a breakpoint message with the file and line numbers
  • send C for continue

This is copied from a telnet session

b C:\project\src\ex_hello_cube\main.rb:14
<breakpointAdded no="1" location="C:/project/src/ex_hello_cube/main.rb:14" />
enable breakpoints 1
<breakpointEnabled bp_id="1" />
<breakpoint file="C:/project/src/ex_hello_cube/main.rb" line="14" threadId="1" />
c
2 Likes

The Ruby Debug IDE protocol is specified here: ruby-debug-ide protocol

but… you’ll have to read the Sketchup Debugger source code to determine which commands have been implemented.

I’ve enjoyed following your work. Keep at it!

3 Likes

@sWilliams

Thank you for the information. With them I was able to send the break points and when reached, and returned to my program as expected.

Now, treat the others. :smiley:

1 Like

Hey guys.

I have a version that performs the main functions.
I’m having trouble getting information about the variables.

See this screen:

It reaches the stopping point and I recovered the local variables and all with nil. Which is to be expected.
When advancing a line, DAP requests information about the variables again.

But, the model variable comes with its value, which is expected, but the has_children information comes false.


The same thing happens to the others

This is the SuRubyDebbuger log:

77.9587	[35544]	Command from ruby-debug-ide client: var local
277.9595	[35544]	Sending response to ruby-debug-ide client:
277.9595	[35544]
<variables>
    <variable name="model" kind="local" value="#&lt;Sketchup::Model:0x000001ea5391f868&gt;"
        type="Sketchup::Model" hasChildren="false" objectId="0x1ea5391f868" />
    <variable name="group" kind="local" value="#&lt;Sketchup::Group:0x000001ea54f07bf8&gt;"
        type="Sketchup::Group" hasChildren="false" objectId="0x1ea54f07bf8" />
    <variable name="entities" kind="local" value="#&lt;Sketchup::Entities:0x000001ea54f06668&gt;"
        type="Sketchup::Entities" hasChildren="false" objectId="0x1ea54f06668" />
    <variable name="points" kind="local"
        value="[Point3d(0, 0, 0), Point3d(39.3701, 0, 0), Point3d(39.3701, 39.3701, 0), Point3d(0, 39.3701, 0)]"
        type="Array" hasChildren="false" objectId="0x1ea54f04f98" />
    <variable name="face" kind="local" value="#&lt;Sketchup::Face:0x000001ea54d8bd88&gt;"
        type="Sketchup::Face" hasChildren="false" objectId="0x1ea54d8bd88" />
</variables>

What is the logic of has_children?
Am I failing to do something or doing something wrong?

Thanks for any help.

Reminder: The protocol specification:

It indicates for collection types whether it has child objects.

You do not see these with the other variables you listed because those are API wrapped C++ objects.

Now even though entities is a collection type it isn’t a Ruby collection class. It is exposed to Ruby via a custom class interface. At the time you show it, the face hasn’t yet been added to this entities collection.

What is the entities value for has_children after the face has been added ?


2 Likes

In the Sketchup implementation of the ruby-debug-ide protocol hasChildren is true if the Class, Module, Object, etc. has any Instance Variables. Two examples where this would be true are:

class Bar
  def initialize
    @bar = 1
  end
end
Bar.new.inspect  #=> "#<Bar:0x0300c868 @bar=1>"

# and

model = Sketchup.active_model
model.instance_variable_set(:@foo,'bar')
model.inspect #=> #<Sketchup::Model:0x00018e1a984500 @foo='bar'1>

The debugger output stream will indicate that instance variable(s ) are present with the hasChildren flag.

<variables>
  <variable name="model" kind="local" 
  value="<Sketchup::Model:0x0001fb041fd000;" 
  type="Sketchup::Model" 
  hasChildren="true" 
  objectId="0x1fb041fd000" />
</variables>

More info than you want to know!

Here’s the call chain if you want to follow through the code.

The response is formatted in the RDIP interface of the Sketchup Ruby debugger
RDIP.cpp Line: 402
sketchup-ruby-debugger/DebugServer/UI/RDIP/RDIP.cpp at main · SketchUp/sketchup-ruby-debugger · GitHub

var.has_children is assigned in the method Server::GetVariables(()
Sketchup Ruby debugger
Setrver.cpp Line: 867
sketchup-ruby-debugger/DebugServer/Server.cpp at main · SketchUp/sketchup-ruby-debugger · GitHub

Which calls into Ruby to get the count of instance variables
Ruby 2.7.2
variable.c Line: 1511
ruby/variable.c at ruby_2_7 · ruby/ruby · GitHub
return the count of instance variables
rb_ivar_count(VALUE obj)

In addition, Ruby Object.inspect uses rb_ivar_count for the same purpose.
//Ruby 2.7.2
// Object.c
//Line: 732
ruby/object.c at ruby_2_7 · ruby/ruby · GitHub

1 Like

Completing the ideas put forward by Dan, the lib/ruby-debug-ide version of the debug library (Ruby 2.2) defines has_children in a slightly different way.

ruby-debug-ide/lib/ruby-debug-ide/xml_printer.rb at master · ruby-debug/ruby-debug-ide · GitHub

if value.is_a?(Array) || value.is_a?(Hash)
  has_children = !value.empty?
  ...

elsif value.is_a?(String)
  has_children = value.respond_to?('bytes') || value.respond_to?('encoding')
  ...

else
  has_children = !value.instance_variables.empty? || !value.class.class_variables.empty?

end
1 Like

Hey, just wanted to bump this and see if there’s been any progress since March. Is it usable at this point?