Skip to content

Commit c6b8e78

Browse files
committed
One more fixup
Signed-off-by: Davide Bettio <davide@uninstall.it>
1 parent 4fb5931 commit c6b8e78

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/libAtomVM/stacktrace.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
*/
2020

2121
#include "stacktrace.h"
22+
23+
#include "bif.h"
24+
#include "nifs.h"
2225
#include "defaultatoms.h"
2326
#include "globalcontext.h"
2427
#include "memory.h"
@@ -327,6 +330,16 @@ static term find_path_created(const void *key, struct ModulePathPair *module_pat
327330
return term_invalid_term();
328331
}
329332

333+
static bool is_bif_or_nif(term module_atom, term function_atom, int arity, const GlobalContext *glb)
334+
{
335+
atom_index_t module_atom_index = term_to_atom_index(module_atom);
336+
atom_index_t function_atom_index = term_to_atom_index(function_atom);
337+
char mfa[MAX_MFA_NAME_LEN];
338+
atom_table_write_mfa(glb->atom_table, mfa, sizeof(mfa), module_atom_index, function_atom_index, arity);
339+
340+
return (bif_registry_get_handler(mfa) != NULL) || (nifs_get(mfa) != NULL);
341+
}
342+
330343
term stacktrace_build(Context *ctx, term *stack_info, uint32_t live)
331344
{
332345
GlobalContext *glb = ctx->global;
@@ -436,7 +449,7 @@ term stacktrace_build(Context *ctx, term *stack_info, uint32_t live)
436449
term_put_tuple_element(frame_i, 1, raw_function);
437450
term_put_tuple_element(frame_i, 2, raw_arity);
438451

439-
if (module_name == raw_module) {
452+
if ((module_name == raw_module) && !is_bif_or_nif(raw_module, raw_function, raw_arity, glb)) {
440453
term_put_tuple_element(frame_i, 3, aux_data);
441454
} else {
442455
// mismatch means that error likely happened somewhere else, like a NIF, hence:

0 commit comments

Comments
 (0)