Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nala/dist/nala.c
Original file line number Diff line number Diff line change
Expand Up @@ -3360,7 +3360,7 @@ void nala_subprocess_result_free(struct nala_subprocess_result_t *self_p)
// #include "subprocess.h"


#define DEPTH_MAX 100
#define NALA_DEPTH_MAX 100

#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_CYAN "\x1b[36m"
Expand Down Expand Up @@ -3603,9 +3603,9 @@ char *nala_traceback_string(const char *prefix_p,
void *arg_p)
{
int depth;
void *addresses[DEPTH_MAX];
void *addresses[NALA_DEPTH_MAX];

depth = backtrace(&addresses[0], DEPTH_MAX);
depth = backtrace(&addresses[0], NALA_DEPTH_MAX);

return (nala_traceback_format(addresses,
depth,
Expand Down
14 changes: 14 additions & 0 deletions nala/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,20 @@ def parse(self):
self.typedefs_code + self.structs_code + self.func_signatures)
self.file_ast = self.cparser.parse(code)
func_offset = len(self.typedefs_code + self.structs_code)
# PATCH BEGIN
# The above offset calculation sometimes ends up giving a wrong start index.
# As a result the first function_declaration handed over to `rename_parameters`
# is of type 'Struct' which has no argument 'args'!
# Now we test if the element at index `func_offset` has the correct type, and if
# not the AST list is searched for the first 'c_ast.FuncDecl' starting from the
# calculated `func_offset`. The index of the first detected 'c_ast.FuncDecl' is
# then used as new `func_offset`!
if not isinstance(self.file_ast.ext[func_offset].type, c_ast.FuncDecl):
for i in range(func_offset, len(self.file_ast.ext)):
if isinstance(self.file_ast.ext[i].type, c_ast.FuncDecl):
func_offset = i
break
# PATCH END

for i, func_name in enumerate(self.func_names, func_offset):
if self.param_names is None:
Expand Down
Loading