Skip to content

Commit 461e83a

Browse files
committed
src: improve Error message on LoadPtr
Knowing why LoadPtr failed can be quite helpful when debugging llnode, but the current message doesn't give any additional information. Sharing the address llnode tried to load, as well as the supposed type for that address makes debugging easier. The type name is only shown on Debug builds. PR-URL: #351 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 1948512 commit 461e83a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llnode.gypi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
"Debug": {
2727
"defines": [ "DEBUG", "_DEBUG" ],
2828
"cflags": [ "-g", "-O0", "-fwrapv" ],
29+
"cflags_cc!": [
30+
"-fno-rtti"
31+
],
2932
"xcode_settings": {
3033
"GCC_OPTIMIZATION_LEVEL": "0"
3134
},

src/llv8-inl.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ inline T LLV8::LoadValue(int64_t addr, Error& err) {
6060
if (!res.Check()) {
6161
// TODO(joyeecheung): use Error::Failure() to report information when
6262
// there is less noise from here.
63-
err = Error(true, "Invalid value");
63+
#if DEBUG
64+
#define _s typeid(T).name()
65+
#else
66+
#define _s "value"
67+
#endif
68+
err = Error(true, "The value %lx is not a valid %s", addr, _s);
69+
#undef _s
6470
return T();
6571
}
6672

0 commit comments

Comments
 (0)