From eca7eaa83ac46ac73a445e0981d8f3217cd2d246 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Tue, 19 Oct 2021 09:37:51 -0400 Subject: [PATCH 1/3] Git ignore v8go.test Since `go test -c` is recommended as a way of running tests with a debugger. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b48ffed5a..f676dd07a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ deps/darwin-x86_64/libv8_debug.a c.out + +/v8go.test From 2e217d5af8aeefdd2ac4cafa9ff92eaae59ca249 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Tue, 19 Oct 2021 11:14:30 -0400 Subject: [PATCH 2/3] README: Add information on flushing for printf-style debugging --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 87b43a1b2..e46360c8e 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,19 @@ and select your pushed branch eg. `v8_7_upgrade`. 1) Once built, this should open 3 PRs against your branch to add the `libv8.a` for Linux, macOS and Windows; merge these PRs into your branch. You are now ready to raise the PR against `master` with the latest version of V8. +### Flushing after C/C++ standard library printing for debugging + +When using the C/C++ standard library functions for printing (e.g. `printf`), then the output will be buffered by default. +This can cause some confusion, especially because test the binary (created through `go test`) does not flush the buffer +at exit (at the time of writing). When standard output is the terminal, then it will use line buffering and flush when +a new line is printed, otherwise (e.g. if the output is redirected to a pipe or file) it will be fully buffered and not even +flush at the end of a line. When the test binary is executed through `go test .` (e.g. instead of +separately compiled with `go test -c` and run with `./v8go.test`) Go may redirect standard output internally, resulting in +standard output being fully buffered. + +A simple way to avoid this problem is to flush the standard output stream after printing with the `fflush(stdout);` statement. +Not relying on the flushing at exit can also help ensure the output is printed before a crash. + ### Formatting Go has `go fmt`, C has `clang-format`. Any changes to the `v8go.h|cc` should be formated with `clang-format` with the From b0859e0716aedd3a7b8a08e12dcca715c902bdc9 Mon Sep 17 00:00:00 2001 From: Genevieve Date: Tue, 19 Oct 2021 09:44:47 -0700 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e46360c8e..0f010a8d0 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ these PRs into your branch. You are now ready to raise the PR against `master` w ### Flushing after C/C++ standard library printing for debugging When using the C/C++ standard library functions for printing (e.g. `printf`), then the output will be buffered by default. -This can cause some confusion, especially because test the binary (created through `go test`) does not flush the buffer +This can cause some confusion, especially because the test binary (created through `go test`) does not flush the buffer at exit (at the time of writing). When standard output is the terminal, then it will use line buffering and flush when a new line is printed, otherwise (e.g. if the output is redirected to a pipe or file) it will be fully buffered and not even flush at the end of a line. When the test binary is executed through `go test .` (e.g. instead of