|
19 | 19 | */ |
20 | 20 |
|
21 | 21 | #include "stacktrace.h" |
| 22 | + |
| 23 | +#include "bif.h" |
| 24 | +#include "nifs.h" |
22 | 25 | #include "defaultatoms.h" |
23 | 26 | #include "globalcontext.h" |
24 | 27 | #include "memory.h" |
@@ -327,6 +330,16 @@ static term find_path_created(const void *key, struct ModulePathPair *module_pat |
327 | 330 | return term_invalid_term(); |
328 | 331 | } |
329 | 332 |
|
| 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 | + |
330 | 343 | term stacktrace_build(Context *ctx, term *stack_info, uint32_t live) |
331 | 344 | { |
332 | 345 | GlobalContext *glb = ctx->global; |
@@ -436,7 +449,7 @@ term stacktrace_build(Context *ctx, term *stack_info, uint32_t live) |
436 | 449 | term_put_tuple_element(frame_i, 1, raw_function); |
437 | 450 | term_put_tuple_element(frame_i, 2, raw_arity); |
438 | 451 |
|
439 | | - if (module_name == raw_module) { |
| 452 | + if ((module_name == raw_module) && !is_bif_or_nif(raw_module, raw_function, raw_arity, glb)) { |
440 | 453 | term_put_tuple_element(frame_i, 3, aux_data); |
441 | 454 | } else { |
442 | 455 | // mismatch means that error likely happened somewhere else, like a NIF, hence: |
|
0 commit comments