How to check if Hermes bytecode bundle contains debug info? #1129
-
When Is it possible to check in runtime in React Native or Hermes API if the loaded bundle/bundles have debug info present or not? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hmm, we haven't planned for this, but I think you could do it by calling t1.js: function foo() {}
print(JSON.stringify(HermesInternal.getFunctionLocation(foo))); Then I tried these commands:
See how in one case you get a virtualOffset and in the other line and column? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply, this looks very promising. But sadly it seems to help differ only between I'm looking for a way to differ between Based on the bytecode content I assume To be honest, I'm surprised that the error stack trace and test.js
Output
In practice RN app won't have the application code on line 1, so just based on the line number, it's possible to guess. |
Beta Was this translation helpful? Give feedback.
-
This all actually has logic behind it.
As you noted, if you want to differentiate between Unfortunately I have also become aware that at least some Hermes users, perhaps unintentionally, are using CodePush to deploy source code OTA, which makes the situation really messy. Source code will obviously make the app really slow, but might also screw the result of the above trick. |
Beta Was this translation helpful? Give feedback.
This all actually has logic behind it.
-g0
should never be used. It is there for completeness and testing. It emits no location information of any kind.-g1
, which is the default, emits only enough information to generate stack traces. This information is restricted only to locations where an exception can be thrown (this is done to minimize the size of the bundle). Naturally, with-g1
there is no information about locations of function declarations.-g1
produces the default behavior one expects from a JS engine - stack traces with locations.-g2
emits information for all locations. If you use-g2
,getFunctionLocation()
will return line and column. Of course, the bundle will be larger.-g3
…