nodejs: start sketch

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-10-08 00:00:00 +00:00
parent 3c3deb14dc
commit a9856a47a8
3 changed files with 45 additions and 13 deletions

View File

@@ -1108,7 +1108,7 @@ sudo apt-get install gcc-aarch64-linux-gnu qemu-system-aarch64
--arch aarch64 \
--qemu-which host \
--userland-build-id host \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
--userland-args 'asdf "qw er"' \
;
....
@@ -1142,7 +1142,7 @@ and <<user-mode-gdb>>:
--gcc-which host \
--qemu-which host \
--userland-build-id host \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
--userland-args 'asdf "qw er"' \
;
....
@@ -2646,7 +2646,7 @@ Source: link:rootfs_overlay/lkmc/gdbserver.sh[].
And on host:
....
./run-gdb --gdbserver --userland userland/c/print_argv.c main
./run-gdb --gdbserver --userland userland/c/command_line_arguments.c main
....
or alternatively with the path to the executable itself:
@@ -3584,12 +3584,12 @@ See also: xref:user-mode-simulation-with-glibc[xrefstyle=full]
=== QEMU user mode getting started
Let's run link:userland/c/print_argv.c[] built with the Buildroot toolchain on QEMU user mode:
Let's run link:userland/c/command_line_arguments.c[] built with the Buildroot toolchain on QEMU user mode:
....
./build user-mode-qemu
./run \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
--userland-args='asdf "qw er"' \
;
....
@@ -3620,7 +3620,7 @@ It's nice when <<gdb,the obvious>> just works, right?
./run \
--arch aarch64 \
--gdb-wait \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
--userland-args 'asdf "qw er"' \
;
....
@@ -3630,7 +3630,7 @@ and on another shell:
....
./run-gdb \
--arch aarch64 \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
main \
;
....
@@ -3641,7 +3641,7 @@ Or alternatively, if you are using <<tmux>>, do everything in one go with:
./run \
--arch aarch64 \
--gdb \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
--userland-args 'asdf "qw er"' \
;
....
@@ -3793,7 +3793,7 @@ Example:
./run \
--arch aarch64 \
--static \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
--userland-args 'asdf "qw er"' \
;
....
@@ -3879,7 +3879,7 @@ So let's just play with some static ones:
./run \
--arch aarch64 \
--emulator gem5 \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
--userland-args 'asdf "qw er"' \
;
....
@@ -3894,14 +3894,14 @@ TODO: how to escape spaces on the command line arguments?
--emulator gem5 \
--gdb-wait \
--static \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
--userland-args 'asdf "qw er"' \
;
./run-gdb \
--arch aarch64 \
--emulator gem5 \
--static \
--userland userland/c/print_argv.c \
--userland userland/c/command_line_arguments.c \
main \
;
....
@@ -12854,7 +12854,7 @@ Programs under link:userland/c/[] are examples of https://en.wikipedia.org/wiki/
** link:userland/c/exit0.c[]
** link:userland/c/exit1.c[]
** link:userland/c/exit2.c[]
** link:userland/c/print_argv.c[]
** link:userland/c/command_line_arguments.c[]
* Standard library
** `assert.h`
*** link:userland/c/assert_fail.c[]
@@ -13164,6 +13164,33 @@ How to debug: https://stackoverflow.com/questions/6261201/how-to-find-memory-lea
Example: link:userland/c/memory_leak.c[]
=== Interpreted languages
Maybe some day someone will use this setup to study the performance of interpreters:
* <<node-js>>
=== Node.js
Parent section: <<interpreted-languages>>.
Install the interpreter with:
....
./build-buildroot --config 'BR2_PACKAGE_NODEJS=y'
....
TODO: broken as of 3c3deb14dc8d6511680595dc42cb627d5781746d + 1:
....
ERROR: package host-nodejs installs executables without proper RPATH
....
Examples:
* process
** link:rootfs_overlay/lkmc/nodejs/command_line_arguments.js[]
=== Userland content bibliography
* The Linux Programming Interface by Michael Kerrisk https://www.amazon.co.uk/Linux-Programming-Interface-System-Handbook/dp/1593272200 Lots of open source POSIX examples: https://github.com/cirosantilli/linux-programming-interface-kerrisk

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env node
for (const arg of process.argv) {
console.log(arg);
}