mirror of
https://github.com/jart/cosmopolitan.git
synced 2024-05-05 21:28:46 +00:00
f4f4caab0e
I wanted a tiny scriptable meltdown proof way to run userspace programs and visualize how program execution impacts memory. It helps to explain how things like Actually Portable Executable works. It can show you how the GCC generated code is going about manipulating matrices and more. I didn't feel fully comfortable with Qemu and Bochs because I'm not smart enough to understand them. I wanted something like gVisor but with much stronger levels of assurances. I wanted a single binary that'll run, on all major operating systems with an embedded GPL barrier ZIP filesystem that is tiny enough to transpile to JavaScript and run in browsers too. https://justine.storage.googleapis.com/emulator625.mp4
71 lines
2.9 KiB
Plaintext
Executable file
71 lines
2.9 KiB
Plaintext
Executable file
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
|
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
|
#
|
|
# OVERVIEW
|
|
#
|
|
# Header Symbol Index Generator
|
|
#
|
|
# DESCRIPTION
|
|
#
|
|
# This is a static source analyzer that lets us configure Emacs
|
|
# keybindings to insert #include lines.
|
|
#
|
|
# EXAMPLES
|
|
#
|
|
# build/htags -o HTAGS $(find . -name \*.h)
|
|
#
|
|
# (defun jart-add-include ()
|
|
# (interactive)
|
|
# (let* ((tag-file "HTAGS")
|
|
# (case-fold-search nil)
|
|
# (search (thing-at-point 'symbol))
|
|
# (buffer (find-file-noselect (format "%s/%s"
|
|
# (locate-dominating-file
|
|
# (buffer-name) tag-file)
|
|
# tag-file)))
|
|
# (header (with-current-buffer buffer
|
|
# (save-excursion
|
|
# (goto-char 0)
|
|
# (when (re-search-forward
|
|
# (concat "\177" search "\001") nil t)
|
|
# (when (re-search-backward "\f\n\\([^,]*\\)," nil t)
|
|
# (match-string 1)))))))
|
|
# (when header
|
|
# (save-excursion
|
|
# (goto-char 0)
|
|
# (re-search-forward "#include")
|
|
# (re-search-forward "^$")
|
|
# (insert (concat "#include \"" header "\"\n"))))))
|
|
# (defun jart-c-mode-common-hook ()
|
|
# (define-key c-mode-base-map (kbd "C-c C-h") 'jart-add-include))
|
|
# (eval-after-load 'markdown-mode
|
|
# '(progn
|
|
# (add-hook 'c-mode-common-hook 'jart-c-mode-common-hook)))
|
|
|
|
# ctags doesn't understand variable prototypes, e.g.
|
|
# extern char **environ;
|
|
set -- --regex-c='/^\(\(hidden\|extern\|const\) \)*[_[:alpha:]][_[:alnum:]]*[ *][ *]*\([_[:alpha:]][_[:alnum:]]*[ *][ *]*\)*\([_[:alpha:]][_$[:alnum:]]*\)/\4/b' "$@"
|
|
|
|
# ctags doesn't understand function prototypes, e.g.
|
|
# bool isheap(void *p) nothrow nocallback;
|
|
set -- --regex-c='/^[_[:alpha:]][_[:alnum:]]*[ *][ *]*\([_[:alpha:]][_[:alnum:]]*[ *][ *]*\)*\([_[:alpha:]][_$[:alnum:]]*\)(.*/\2/b' "$@"
|
|
|
|
# ctags doesn't understand function pointers, e.g.
|
|
# extern int32_t (*const SetEvent)(int64_t hEvent) wincall;
|
|
set -- --regex-c='/^extern [^(]*(\*const \([^)]*\))(/\1/b' "$@"
|
|
|
|
# ctags doesn't understand forward declarations, e.g.
|
|
# struct WorstSoftwareEver;
|
|
set -- --regex-c='/^struct.*;$/uehocruehcroue/b' "$@"
|
|
|
|
exec ${TAGS:-ctags} \
|
|
-e \
|
|
--langmap=c:.c.h \
|
|
--exclude=libc/nt/struct/imagefileheader.h \
|
|
--exclude=libc/nt/struct/imageseparatedebugheader.h \
|
|
--exclude=libc/nt/struct/importobjectheader.h \
|
|
--exclude=libc/nt/struct/nonpageddebuginfo.h \
|
|
--exclude=libc/nt/struct/ansistring.h \
|
|
--exclude=libc/nt/struct/filesegmentelement.h \
|
|
"$@"
|