Skip to content

Commit 9e861bc

Browse files
committed
Add review changes
1 parent 4f3a47c commit 9e861bc

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

lldb/bindings/lua/lua-typemaps.swig

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,21 @@ LLDB_NUMBER_TYPEMAP(enum SWIGTYPE);
121121
$1 = (char *)malloc($2);
122122
}
123123

124-
// Remove the default type check for this match.
125-
// because if the match function has an overload and a typemap,
126-
// it will typecheck against the original function instead of the
127-
// typemap.
124+
// Disable default type checking for this method to avoid SWIG dispatch issues.
125+
//
126+
// Problem: SBThread::GetStopDescription has two overloads:
127+
// 1. GetStopDescription(char* dst_or_null, size_t dst_len)
128+
// 2. GetStopDescription(lldb::SBStream& stream)
129+
//
130+
// SWIG generates a dispatch function to select the correct overload based on argument types.
131+
// see https://www.swig.org/Doc4.0/SWIGDocumentation.html#Typemaps_overloading.
132+
// However, this dispatcher doesn't consider typemaps that transform function signatures.
133+
//
134+
// In lua, our typemap converts GetStopDescription(char*, size_t) to GetStopDescription(int).
135+
// The dispatcher still checks against the original (char*, size_t) signature instead of
136+
// the transformed (int) signature, causing type matching to fail.
137+
// This only affects SBThread::GetStopDescription since the type check also matches
138+
// the argument name, which is unique to this function.
128139
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) (char *dst_or_null, size_t dst_len) ""
129140

130141
%typemap(argout) (char *dst_or_null, size_t dst_len) {

lldb/bindings/python/python-typemaps.swig

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,21 @@ AND call SWIG_fail at the same time, because it will result in a double free.
225225
$1 = (char *)malloc($2);
226226
}
227227

228-
// Remove the default type check for this match.
229-
// because if the match function has an overload and a typemap,
230-
// it will typecheck against the original function instead of the
231-
// typemap.
228+
// Disable default type checking for this method to avoid SWIG dispatch issues.
229+
//
230+
// Problem: SBThread::GetStopDescription has two overloads:
231+
// 1. GetStopDescription(char* dst_or_null, size_t dst_len)
232+
// 2. GetStopDescription(lldb::SBStream& stream)
233+
//
234+
// SWIG generates a dispatch function to select the correct overload based on argument types.
235+
// see https://www.swig.org/Doc4.0/SWIGDocumentation.html#Typemaps_overloading.
236+
// However, this dispatcher doesn't consider typemaps that transform function signatures.
237+
//
238+
// In Python, our typemap converts GetStopDescription(char*, size_t) to GetStopDescription(int).
239+
// The dispatcher still checks against the original (char*, size_t) signature instead of
240+
// the transformed (int) signature, causing type matching to fail.
241+
// This only affects SBThread::GetStopDescription since the type check also matches
242+
// the argument name, which is unique to this function.
232243
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) (char *dst_or_null, size_t dst_len) ""
233244

234245
%typemap(argout) (char *dst_or_null, size_t dst_len) {

lldb/tools/lldb-rpc-gen/RPCCommon.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {
118118
"_ZN4lldb8SBTarget15GetInstructionsEyPKvm",
119119
"_ZN4lldb8SBTarget25GetInstructionsWithFlavorEyPKcPKvm",
120120
"_ZN4lldb8SBThread18GetStopDescriptionEPcm",
121-
"_ZNK4lldb8SBThread18GetStopDescriptionERNS_8SBStreamE",
122121
// The below mangled names are used for dummy methods in shell tests
123122
// that test the emitters' output. If you're adding any new mangled names
124123
// from the actual SB API to this list please add them above.

0 commit comments

Comments
 (0)