Skip to content

Commit 996bcbf

Browse files
authored
Patch upstream stackWalker.cpp not to fail on unaligned access (#218)
1 parent 691bd74 commit 996bcbf

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

ddprof-lib/build.gradle

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,34 @@ def patchStackFrame = tasks.register("patchStackFrame") {
215215
}
216216
}
217217

218+
def patchStackWalker = tasks.register("patchStackWalker") {
219+
description = 'Patch stackWalker.cpp after copying'
220+
configure {
221+
dependsOn copyUpstreamFiles
222+
}
223+
doLast {
224+
def file = file("${projectDir}/src/main/cpp-external/stackWalker.cpp")
225+
if (!file.exists()) throw new GradleException("File not found: ${file}")
226+
227+
def content = file.getText('UTF-8')
228+
def original = content
229+
230+
// Add no_sanitize to walkVM
231+
content = content.replaceAll(
232+
/(int\s+StackWalker::walkVM\s*\()/,
233+
'__attribute__((no_sanitize("address"))) int StackWalker::walkVM('
234+
)
235+
236+
if (content != original) {
237+
file.write(content, 'UTF-8')
238+
println "Patched stackWalker.cpp"
239+
}
240+
}
241+
}
242+
218243
def initSubrepoTask = tasks.register('initSubrepo') {
219244
configure {
220-
dependsOn copyUpstreamFiles, patchStackFrame
245+
dependsOn copyUpstreamFiles, patchStackFrame, patchStackWalker
221246
}
222247
}
223248

0 commit comments

Comments
 (0)