Class: OsCtl::Cli::Debug
- Inherits:
-
Command
- Object
- Lib::Cli::Command
- Command
- OsCtl::Cli::Debug
show all
- Defined in:
- lib/osctl/cli/debug.rb
Constant Summary
collapse
- LOCK_FIELDS =
%i[
id
time
thread
object
type
state
backtrace
].freeze
Instance Method Summary
collapse
Methods inherited from Command
#cli_opt, #format_output, #osctld_call, #osctld_fmt, #osctld_open, #osctld_resp, run
Instance Method Details
#locks_ls ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/osctl/cli/debug.rb', line 13
def locks_ls
data = osctld_call(:debug_lock_registry)
if opts[:verbose]
format_output(
data.map do |lock|
lock[:backtrace] = lock[:backtrace].join("\n")
lock
end,
cols: %i[id time thread object type state backtrace],
layout: :rows
)
else
format_output(
data,
cols: %i[id thread object type state],
layout: :columns
)
end
end
|
#locks_show ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/osctl/cli/debug.rb', line 35
def locks_show
require_args!('id')
id = args[0].to_i
data = osctld_call(:debug_lock_registry)
lock = data.detect { |v| v[:id] == id }
return unless lock
lock[:backtrace] = lock[:backtrace].join("\n")
format_output(lock)
end
|
#threads_ls ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/osctl/cli/debug.rb', line 47
def threads_ls
data = osctld_call(:debug_thread_list)
data.map do |thread|
thread[:backtrace] = thread[:backtrace] && thread[:backtrace].join("\n")
thread
end
format_output(data, layout: :rows)
end
|
#ugids_ls ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/osctl/cli/debug.rb', line 56
def ugids_ls
data = osctld_call(:debug_ugid_registry)
if args[0].nil? || args[0] == 'all'
format_output(
(data[:allocated] + data[:free]).sort!.map! do |ugid|
{
ugid:,
free: !data[:allocated].include?(ugid)
}
end,
layout: :columns
)
elsif args[0] == 'taken'
data[:allocated].each { |ugid| puts ugid }
elsif args[0] == 'free'
data[:free].each { |ugid| puts ugid }
else
raise GLI::BadCommandLine
end
end
|