Skip to content

Commit

Permalink
src: improve Error message on LoadPtr
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mmarchini committed Mar 30, 2020
1 parent 1948512 commit 461e83a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions llnode.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"Debug": {
"defines": [ "DEBUG", "_DEBUG" ],
"cflags": [ "-g", "-O0", "-fwrapv" ],
"cflags_cc!": [
"-fno-rtti"
],
"xcode_settings": {
"GCC_OPTIMIZATION_LEVEL": "0"
},
Expand Down
8 changes: 7 additions & 1 deletion src/llv8-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ inline T LLV8::LoadValue(int64_t addr, Error& err) {
if (!res.Check()) {
// TODO(joyeecheung): use Error::Failure() to report information when
// there is less noise from here.
err = Error(true, "Invalid value");
#if DEBUG
#define _s typeid(T).name()
#else
#define _s "value"
#endif
err = Error(true, "The value %lx is not a valid %s", addr, _s);
#undef _s
return T();
}

Expand Down

0 comments on commit 461e83a

Please sign in to comment.