lldb_function_to_function_dbi: Fix a null dereference (#3189)

C++ allows unnamed arguments.
In the debug info, they are represented as DW_TAG_formal_parameter
w/o DW_AT_name.
variable.GetName() here returns NULL for them.

cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3187
This commit is contained in:
YAMAMOTO Takashi 2024-02-29 15:03:49 +09:00 committed by GitHub
parent bc4f8ab0a5
commit 503c9694c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -387,9 +387,10 @@ lldb_function_to_function_dbi(const AOTCompContext *comp_ctx,
LLVMMetadataRef ParamLocation = LLVMDIBuilderCreateDebugLocation(
comp_ctx->context, dec.GetLine(), dec.GetColumn(),
FunctionMetadata, NULL);
const char *varname = variable.GetName();
LLVMMetadataRef ParamVar = LLVMDIBuilderCreateParameterVariable(
DIB, FunctionMetadata, variable.GetName(),
strlen(variable.GetName()), function_arg_idx + 1 + 1,
DIB, FunctionMetadata, varname, varname ? strlen(varname) : 0,
function_arg_idx + 1 + 1,
File, // starts form 1, and 1 is exenv,
dec.GetLine(), ParamTypes[function_arg_idx + 1], true,
LLVMDIFlagZero);