Skip to content

Commit

Permalink
Debug analyze_code
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Oct 30, 2024
1 parent 2b79acd commit f47ce82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/api/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func AnalyzeCode(cache Cache, checksum []byte) (*types.AnalysisReport, error) {
cs := makeView(checksum)
defer runtime.KeepAlive(checksum)
errmsg := uninitializedUnmanagedVector()
fmt.Printf("AnalyzeCode: %p (%v, %v, %p) %p", cache.ptr, cs.is_nil, cs.len, cs.ptr, &errmsg)
report, err := C.analyze_code(cache.ptr, cs, &errmsg)
if err != nil {
return nil, errorWithMessage(err, errmsg)
Expand Down
9 changes: 8 additions & 1 deletion libwasmvm/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,15 @@ fn set_to_csv(set: BTreeSet<impl AsRef<str>>) -> String {
pub extern "C" fn analyze_code(
cache: *mut cache_t,
checksum: ByteSliceView,
error_msg: Option<&mut UnmanagedVector>,
mut error_msg: Option<&mut UnmanagedVector>,
) -> AnalysisReport {
println!(
"analyze_code: {cache:?} ({}, {}, {:?}) {:?}",
checksum.is_nil,
checksum.len,
checksum.ptr,
error_msg.as_mut().map(|e| *e as *mut UnmanagedVector)
);
let r = match to_cache(cache) {
Some(c) => catch_unwind(AssertUnwindSafe(move || do_analyze_code(c, checksum)))
.unwrap_or_else(|err| {
Expand Down
6 changes: 3 additions & 3 deletions libwasmvm/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::slice;
#[derive(Debug)]
pub struct ByteSliceView {
/// True if and only if the byte slice is nil in Go. If this is true, the other fields must be ignored.
is_nil: bool,
ptr: *const u8,
len: usize,
pub is_nil: bool,
pub ptr: *const u8,
pub len: usize,
}

impl ByteSliceView {
Expand Down

0 comments on commit f47ce82

Please sign in to comment.