0
votes

Ruby 1.93 Windows 8.1 Could someone show me an example of the following debugger command being entered on a command line. I am debugging using "require 'debug'" but have same problem starting from command line. Basically just what you would type to show a constant contained in a class named 'Test'

v[ar] c[onst] show constants of object

Have no problems with any other debugger commands but not sure I know what is expected for this command. It tells me I need a Class/Module if i enter an object/instance. If I enter a class or module (both with constants) then I get

"uninitialized constant DEBUGGER__::Context::CONSTANT_VAL1 (NameError)"

======================================================================= Here is complete code and results from debugger perhaps someone could try in their environment to see if results are the same. Not sure where I am going wrong as puts Test::CONST_VAL works fine with or without debug
(rdb:1) puts Test::CONST_VAL
Constant Value String
nil
(rdb:1)
Not sure if that second line with a nil is meaningful

=======================================================================

ruby 1.9.3p484 (2013-11-22) [i386-mingw32] Windows 8.1

class Test
CONST_VAL = "Constant Value String"
end
obj = Test.new
puts Test::CONST_VAL # "Constant Value String" prints OK
require 'debug' # Same result at top of file
a = 1

Debug commands
v c Test::CONST_VAL Should be Class/Module: Test::CONST_VAL

v c Test block in debug_variable_info': uninitialized constant<br>
DEBUGGER__::Context::CONST_VAL (NameError)<br> =begin full printout - path info removed after first line - include in event can provide some info C:/Ruby/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/debug.rb:171: in
block in debugvariable_info': uninitialized constant DEBUGGER__::Context::CONST_VAL (NameError) 1.9.1/debug.rb:150:in eval' 1.9.1/debug.rb:150:inblock in var_list' 1.9.1/debug.rb:149:in each' 1.9.1/debug.rb:149:invar_list' 1.9.1/debug.rb:171:in debug_variable_info' 1.9.1/debug.rb:478:inblock in debug_command' 1.9.1/debug.rb:240:in catch' 1.9.1/debug.rb:240:indebug_command' 1.9.1/debug.rb:691:in trace_func' 1.9.1/debug.rb:905:inblock in ' from C:/Ruby/Notes/Control/Test2.rb:9:in `' =end

1
Somewhat unrelated, but where you obj = Test.new that is unneeded because the constant you're referencing is already defined without the Test class being instantiated. - digitalextremist

1 Answers

0
votes

Since you want what's within the Test module's scope:

puts Test::CONSTANT_VAL_1

... to output the contents of the constant.

Hopefully I understood your question properly.