Steve Fink's collection of random tools
These are tools that I think might be useful to other people.
- json : Interactive navigation of a JSON file
- debug : Start up a debugger within emacs on various types of files
- em : Start up emacs on the files touched by a patch, on a relevant line number
- traverse.py : Gecko-specific, sorta. Utility for traversing a callgraph.
- wig : Patch harder
I also have a set of gdb initialization files that I version-control here.
- gdbstart.py : gdb init file that loads all of the below gdb startup files
- gdbinit : basic gdb configuration
- gdbinit.py : gdb python init file, defines some miscellany
- gdbinit.symbols.py : Ted Mielczarek's source server integration for gdb
- gdbinit.pahole.py : pahole and overlap commands, loaded by gdbstart.py
- gdbinit.gecko.py : configuration to assist with debugging Gecko and SpiderMonkey
- gdbinit.misc : some miscellaneous gdb helper commands
- gdbinit.rr.py : gdb helper commands for running under rr (lots here!)
- gdbinit.sfink : a couple of things that depend on my personal file layout
The easiest way to use these is to create a
~/.gdbinit file with something
like the following, with the appropriate path to your sfink-tools checkout:
That will load all of the above except for
gdbinit.sfink. Alternatively, you
could just source the individual files you want to use from the above list.
Other configuration files:
- hgrc : Mercurial configuration
I use this via a symlink from ~/.hgrc.
json - Interactive navigation of a JSON file
Created to explore a problem with a large sessionstore.js file. It mimics a UNIX shell prompt, allowing you to cd, ls, grep, and similar.
Requires the Perl module 'JSON'. Installable on Fedora with
dnf install perl-JSON
Run json --help for a full help message. Here's an excerpt:
Usage: json <filename.json> [initial-path]
ls [PATH] - show contents of structure cd PATH - change current view to PATH cat [PATH] - display the value at the given PATH delete SPEC - delete the given key or range of keys (see below for a description of SPEC) set KEY VALUE - modify an existing value (VALUE may optionally - be quoted) mv PATH PATH - move a subtree grep [-l] PATTERN PATH - search for PATTERN in given PATH write [-pretty] [FILENAME] - write out the whole structure as JSON. Use '-' as FILENAME to write to stdout. pretty - prettyprint current structure to stdout size PATH - display how many bytes the JSON of the substructure at PATH would take up load [FILENAME] - load in the given JSON file (reload current file if no filename given)
debug - Start up a debugger within emacs on various types of files
debug --help for usage.
Usual usage is to prepend whatever command you want to debug with 'debug'.
debug firefox -no-remote -P BugPictures
runs firefox within gdb within emacs, with the given arguments
debug -i firefox -no-remote -P NakedBugPictures
same, but stops at the gdb prompt before running firefox
debug somescript.pl x y z
runs somescript.pl within perldb within emacs, with the given arguments
debug --record js testfile.js
js testfile.js with rr, then replays the recording in gdb in emacs
The script goes to insane lengths to figure out what you really meant to run. For example, if you alias ff in your shell to 'firefox -no-remote', you can just do
It will discover that there's no command ff in $PATH and start up a subshell, look for the alias 'ff', and use that command instead.
em - Edit files relevant to a patch
em foo.txt:33will run
emacs +33 foo.txtso will
em foo.txt:33: (easier cut & paste of trailing colon for error messages) and foo.txt will be found anywhere in the current hg tree (if not in cwd)
emwith no args will run emacs on the files changed in the cwd, or if none, then by the cwd's parent rev
em 01faf51a0accwill run emacs on the files changed by that rev.
em foo.txt.rejwill run emacs on both foo.txt and foo.txt.rej, but at the lines containing the first patch hunk and the line number of the original that it applies to (ok, so this is probably where this script jumped the shark.)
If your $EDITOR is not set to emacs, you won't get the fancy line number stuff.
traverse.py - various traversals over the known portion of a callgraph.
The callgraph is in the format generated by the rooting hazard analysis.
help resolve callers callees route - Find a route from SOURCE to DEST [avoiding FUNC] quit allcounts reachable rootpaths canreach manyroutes roots routes verbose callee caller edges output
help <cmd> to figure out what they do; I'm not going to spend time doing that right now.
wig - Apply a patch loosely. Works if the surrounding code has changed.
My usual use is to do some VCS command that spits out .rej files, then do
file1.rej followed by
wig file2.rej etc. That lets me see any failures one
at a time. But the tool also supports scanning for all reject files.