From c4d1405eb02e9bf1f27c3e475e00402999b2238c Mon Sep 17 00:00:00 2001 From: amdoku Date: Sat, 3 Oct 2020 15:55:59 +0200 Subject: [PATCH 1/8] src:fix non-void function not return in a value When compiling with gcc-10.2.0 this would emit a warning --- src/printer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/printer.cc b/src/printer.cc index 377adc34..3f51da17 100644 --- a/src/printer.cc +++ b/src/printer.cc @@ -511,7 +511,7 @@ std::string Printer::Stringify(v8::Map map, Error& err) { return std::string(tmp) + ":" + Stringify(descriptors, err) + ">"; } else { - std::string(tmp) + ">"; + return std::string(tmp) + ">"; } } From e2594c5a340833bd41e7b850ee107c1f27bd056c Mon Sep 17 00:00:00 2001 From: amdoku Date: Sat, 3 Oct 2020 16:07:05 +0200 Subject: [PATCH 2/8] src:fix warning use reference type to prevent copy When compiling under gcc-10.2.0 this line would emit a warning --- src/llscan.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llscan.cc b/src/llscan.cc index a8dd29f8..7e500c53 100644 --- a/src/llscan.cc +++ b/src/llscan.cc @@ -596,7 +596,7 @@ bool FindReferencesCmd::DoExecute(SBDebugger d, char** cmd, void FindReferencesCmd::ScanForReferences(ObjectScanner* scanner) { // Walk all the object instances and handle them according to their type. TypeRecordMap mapstoinstances = llscan_->GetMapsToInstances(); - for (auto const entry : mapstoinstances) { + for (auto const& entry : mapstoinstances) { TypeRecord* typerecord = entry.second; for (uint64_t addr : typerecord->GetInstances()) { From 14728f687adaac089b6dfdd52a6fded545645afc Mon Sep 17 00:00:00 2001 From: amdoku Date: Sat, 3 Oct 2020 17:24:22 +0200 Subject: [PATCH 3/8] src: Fix signed-unsigned comparison in printer.cc When compiling under gcc-10.2.0 this would emit a warning --- src/printer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/printer.cc b/src/printer.cc index 3f51da17..12e60c85 100644 --- a/src/printer.cc +++ b/src/printer.cc @@ -365,7 +365,7 @@ std::string Printer::Stringify(v8::JSArrayBuffer js_array_buffer, Error& err) { } else { res += " [\n "; - int display_length = std::min(*byte_length, options_.length); + size_t display_length = std::min(*byte_length, options_.length); res += llv8_->LoadBytes(*data, display_length, err); if (display_length < *byte_length) { @@ -430,7 +430,7 @@ std::string Printer::Stringify(v8::JSTypedArray js_typed_array, Error& err) { res += " [\n "; - int display_length = std::min(*byte_length, options_.length); + size_t display_length = std::min(*byte_length, options_.length); res += llv8_->LoadBytes(*data + *byte_offset, display_length, err); if (display_length < *byte_length) { From c66fcaf0734d24cf58ff03a532c490c8488ccde6 Mon Sep 17 00:00:00 2001 From: amdoku Date: Sat, 3 Oct 2020 20:29:05 +0200 Subject: [PATCH 4/8] src: Remove warning about (malformed) trigraph When compiling under gcc-10.2.0 this would emit a warning By escaping the '?' it will no longer be detected as a trigraph. --- src/llv8.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llv8.cc b/src/llv8.cc index c3a331ab..5b665ba2 100644 --- a/src/llv8.cc +++ b/src/llv8.cc @@ -733,7 +733,7 @@ std::string Symbol::ToString(Error& err) { return "Symbol()"; } HeapObject name = Name(err); - RETURN_IF_INVALID(name, "Symbol(???)"); + RETURN_IF_INVALID(name, "Symbol(\?\?\?)"); return "Symbol('" + String(name).ToString(err) + "')"; } From a0546212a573d9902bcdeda22177754e727d4692 Mon Sep 17 00:00:00 2001 From: amdoku Date: Sat, 3 Oct 2020 20:54:49 +0200 Subject: [PATCH 5/8] build: turn up warning level When compiling all warnings will now be treated as an error, preventing potentially misbehaving code from making it onto master. --- llnode.gypi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/llnode.gypi b/llnode.gypi index e72bddfa..fa385846 100644 --- a/llnode.gypi +++ b/llnode.gypi @@ -41,6 +41,15 @@ "cflags": [ "-std=c++11", "-fPIC", ], + "cflags_cc": [ + "-Werror", + "-Wall", + "-Wextra", + "-Wendif-labels", + "-W", + "-Wno-unused-parameter", + "-Wundeclared-selector", + ], "xcode_settings": { "GCC_VERSION": "com.apple.compilers.llvm.clang.1_0", "GCC_WARN_ABOUT_MISSING_NEWLINE": "YES", # -Wnewline-eof @@ -51,7 +60,9 @@ "-g", ], "WARNING_CFLAGS": [ + "-Werror", "-Wall", + "-Wextra", "-Wendif-labels", "-W", "-Wno-unused-parameter", From 891890cd97a20428be88034dceb37cefa983bfd3 Mon Sep 17 00:00:00 2001 From: amdoku Date: Sat, 3 Oct 2020 21:11:44 +0200 Subject: [PATCH 6/8] test: Fix unit tests When executing tests with gdb-9.2 and lldb-10.0.1 the tests would fail. Relaxing the error assertion to only check for the warning itself, not the location fixes the test. --- test/plugin/inspect-test.js | 5 +++-- test/plugin/scan-test.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/plugin/inspect-test.js b/test/plugin/inspect-test.js index 592cf3f1..3e640fde 100644 --- a/test/plugin/inspect-test.js +++ b/test/plugin/inspect-test.js @@ -648,8 +648,9 @@ function verifyInvalidExpr(t, sess) { if (err) { return teardown(t, sess, err); } - t.ok( - /error: error: use of undeclared identifier 'invalid_expr'/.test(line), + + t.ok(/^error: error: /.test(line) + && / use of undeclared identifier 'invalid_expr'$/.test(line), 'invalid expression should return an error' ); teardown(t, sess); diff --git a/test/plugin/scan-test.js b/test/plugin/scan-test.js index 13b2cbd4..aa624876 100644 --- a/test/plugin/scan-test.js +++ b/test/plugin/scan-test.js @@ -26,8 +26,8 @@ function testFindrefsForInvalidExpr(t, sess, next) { sess.send('v8 findrefs invalid_expr'); sess.waitError(/error:/, (err, line) => { t.error(err); - t.ok( - /error: error: use of undeclared identifier 'invalid_expr'/.test(line), + t.ok(/^error: error: /.test(line) + && / use of undeclared identifier 'invalid_expr'$/.test(line), 'invalid expression should return an error' ); next(); From 1cc710595ca1a23a0e20e845a51f8befa2ccc1b9 Mon Sep 17 00:00:00 2001 From: amdoku Date: Sat, 3 Oct 2020 22:00:27 +0200 Subject: [PATCH 7/8] ci: Fix CI build error --- llnode.gypi | 1 - 1 file changed, 1 deletion(-) diff --git a/llnode.gypi b/llnode.gypi index fa385846..77e3bb96 100644 --- a/llnode.gypi +++ b/llnode.gypi @@ -48,7 +48,6 @@ "-Wendif-labels", "-W", "-Wno-unused-parameter", - "-Wundeclared-selector", ], "xcode_settings": { "GCC_VERSION": "com.apple.compilers.llvm.clang.1_0", From 9030cd70fefa8e0e5a4465b4df3da1601cbcb3fa Mon Sep 17 00:00:00 2001 From: amdoku Date: Sat, 3 Oct 2020 22:25:14 +0200 Subject: [PATCH 8/8] fixup! ci: Fix CI build error --- src/llscan.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/llscan.cc b/src/llscan.cc index 7e500c53..46a20ab4 100644 --- a/src/llscan.cc +++ b/src/llscan.cc @@ -547,7 +547,8 @@ bool FindReferencesCmd::DoExecute(SBDebugger d, char** cmd, * - Objects that refer to a particular string literal. * (lldb) findreferences -s "Hello World!" */ - case ScanOptions::ScanType::kBadOption: { + case ScanOptions::ScanType::kBadOption: + default: { result.SetError("Invalid search type"); result.SetStatus(eReturnStatusFailed); return false;