how to write crash script to dump kernel variable in rbtree - crash

Would like dump the hrtimer infor in hrtimer_cpu_base.
But there are lots of timer in system with rbtree.
Is there any script/method could help dump all hrtimers?
Thanks,
Mark

Using tree command in crash
crash> hrtimer_cpu_base.clock_base[0].active.rb_root.rb_root ffff912c6fc1d040
clock_base[0].active.rb_root.rb_root = {
rb_node = 0xffffb07590be7e90
},
crash> tree -o hrtimer.node -N 0xffffb07590be7e90 -s hrtimer.function
ffffb07590be7e90
function = 0xffffffffa537d0b0
ffffb07590ddbe90
function = 0xffffffffa537d0b0
ffffb07584faba58
function = 0xffffffffa537d0b0
ffff912c6fc1d680
function = 0xffffffffa538da30
ffffb07586847e88
function = 0xffffffffa537d0b0
ffff912c6fc1d860
function = 0xffffffffa53d40d0
ffffb07586bffe88
function = 0xffffffffa537d0b0
ffffb07584df7e88
function = 0xffffffffa537d0b0

Related

Changes in lua language cause error in ai script

When I run script in game, I got an error message like this:
.\AI\haick.lua:104: bad argument #1 to 'find' (string expected, got nill)
local haick = {}
haick.type = type
haick.tostring = tostring
haick.require = require
haick.error = error
haick.getmetatable = getmetatable
haick.setmetatable = setmetatable
haick.ipairs = ipairs
haick.rawset = rawset
haick.pcall = pcall
haick.len = string.len
haick.sub = string.sub
haick.find = string.find
haick.seed = math.randomseed
haick.max = math.max
haick.abs = math.abs
haick.open = io.open
haick.rename = os.rename
haick.remove = os.remove
haick.date = os.date
haick.exit = os.exit
haick.time = GetTick
haick.actors = GetActors
haick.var = GetV
--> General > Seeding Random:
haick.seed(haick.time())
--> General > Finding Script Location:
local scriptLocation = haick.sub(_REQUIREDNAME, 1, haick.find(_REQUIREDNAME,'/[^\/:*?"<>|]+$'))
Last line (104 in file) causes error and I don`t know how to fix it.
There are links to .lua files below:
https://drive.google.com/file/d/1F90v-h4VjDb0rZUCUETY9684PPGw7IVG/view?usp=sharing
https://drive.google.com/file/d/1fi_wmM3rg7Ov33yM1uo7F_7b-bMPI-Ye/view?usp=sharing
Help, pls!
When you use a function in Lua, you are expected to pass valid arguments for the function.
To use a variable, you must first define it, _REQUIREDNAME in this case is not available, haick.lua file is incomplete. The fault is of the author of the file.
Lua has a very useful reference you can use if you need help, see here

Add help documentation for new command loaded from external redis module within redis-cli

Helps on commands within redis-cli are stored in redis/src/help.h.
I would like to provide my help for commands loaded via redis module (using loadmodule). I could find relevant information from Redis Modules: an introduction to the API
Do you have any suggestion?
I did a check on redis/src/redis-cli.c, the help is created during compile time. Currently there is no possibility to do that.
static void cliInitHelp(void) {
int commandslen = sizeof(commandHelp)/sizeof(struct commandHelp);
int groupslen = sizeof(commandGroups)/sizeof(char*);
int i, len, pos = 0;
helpEntry tmp;
helpEntriesLen = len = commandslen+groupslen;
helpEntries = zmalloc(sizeof(helpEntry)*len);
for (i = 0; i < groupslen; i++) {
tmp.argc = 1;
tmp.argv = zmalloc(sizeof(sds));
tmp.argv[0] = sdscatprintf(sdsempty(),"#%s",commandGroups[i]);
tmp.full = tmp.argv[0];
tmp.type = CLI_HELP_GROUP;
tmp.org = NULL;
helpEntries[pos++] = tmp;
}
for (i = 0; i < commandslen; i++) {
tmp.argv = sdssplitargs(commandHelp[i].name,&tmp.argc);
tmp.full = sdsnew(commandHelp[i].name);
tmp.type = CLI_HELP_COMMAND;
tmp.org = &commandHelp[i];
helpEntries[pos++] = tmp;
}
}
Redis module developers should not write their module command document in redis/src/help/h. I would suggest the following:
Using a new Module API function, module developer register new command documentation (consisting of command syntax, summary, since, group) into a system hash.
redis-cli reads additional command documentation from the system hash, to populate the helpEntries[].

Why does redirecting StandardOutput of GAWK always prepend fstat

I have following code to read and redict the output of gawk to a textfile (instead of doing this with shell-execute and using >):
var processStartInfo = new ProcessStartInfo
{
FileName = "gawk.exe",
Arguments = $#"-F ""{separator}"" -f ""{scriptFullFileName}"" ""{inputFullFileName}""",
UseShellExecute = false,
WorkingDirectory = workingDirectory,
RedirectStandardOutput = true,
CreateNoWindow = true
};
using (var process = Process.Start(processStartInfo))
{
using (var streamReader = process.StandardOutput)
{
var result = streamReader.ReadToEnd();
}
}
Inspecting result afterwards, it always starts with the following lines:
fstat < 0: fd = 0
fstat < 0: fd = 2
Whereas executing gawk.exe from the shell, these lines are not present.
What am I doing wrong - or better, how can I get rid of these 2 lines without additional parsing?
This very issue is connected to the used version of gawk.exe, which was 3.1.6.2962.
With 4.1.3 this problem does not occur.

How to get return value of shell command in Mono C#

I want to know how to interact with shell from Mono and I can't seem to find very much information about this. For example, I want to return the output of "ls" and stick it into a variable - Is this even possible?
Here's what I have so far:
var proc = new Process();
proc.StartInfo.FileName = "ls";
proc.Start ();
proc.Close ()
It is possible to get the shell output. Please try the following -
Process p = new Process();
p.StartInfo = new ProcessStartInfo("/bin/ls", "-l")
{
RedirectStandardOutput = true,
UseShellExecute = false
};
p.Start();
p.WaitForExit();
//The output of the shell command will be in the outPut variable after the
//following line is executed
var outPut = p.StandardOutput.ReadToEnd();

How to execute external program from Swift?

I am new in Swift and I did not found anything about executing external programs or access external processes using Swing language.
Is it possible to do in the current stage of the language development or I should use Objective-C instead?
Maybe there are some Objective-C libraries that can be used inside my Swift program?
Thanks.
You can run external programs using NSTask. For example, from Circle and Square:
import Foundation
func executeCommand(command: String, args: [String]) -> String {
let task = NSTask()
task.launchPath = command
task.arguments = args
let pipe = NSPipe()
task.standardOutput = pipe
task.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output: String = NSString(data: data, encoding: NSUTF8StringEncoding)
return output
}
let commandOutput = executeCommand("/bin/echo", ["Hello, I am here!"])
println("Command output: \(commandOutput)")
Improved version of Rob's answer (in that you don't need to specify the full path of your executable), and also updated for Swift 3:
import Foundation
func execCommand(command: String, args: [String]) -> String {
if !command.hasPrefix("/") {
let commandFull = execCommand(command: "/usr/bin/which", args: [command]).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
return execCommand(command: commandFull, args: args)
} else {
let proc = Process()
proc.launchPath = command
proc.arguments = args
let pipe = Pipe()
proc.standardOutput = pipe
proc.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
return String(data: data, encoding: String.Encoding.utf8)!
}
}