Skip to content

Commit

Permalink
add strace
Browse files Browse the repository at this point in the history
  • Loading branch information
KikiSpace committed Oct 9, 2023
1 parent 74bc2eb commit c70c9e9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wamr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int WAMRInstance::invoke_fopen(std::string &path, uint32 option) {
return -1;
};
int WAMRInstance::invoke_frenumber(uint32 fd, uint32 to) {
auto name = "__wasi_fd_renumber";
auto name = "fd_renumber";
if (!(func = wasm_runtime_lookup_function(module_inst, name, nullptr))) {
LOGV(ERROR) << "The wasi fopen function is not found.";
auto target_module = get_module_instance()->e;
Expand Down
7 changes: 7 additions & 0 deletions src/wamr_wasi_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//
#include "wamr_wasi_context.h"
#include "wamr.h"
#include <string>
extern WAMRInstance *wamr;
void WAMRWASIContext::dump_impl(WASIContext *env) {
for (int i = 0; i < wamr->dir_.size(); i++) {
Expand All @@ -20,6 +21,12 @@ void WAMRWASIContext::dump_impl(WASIContext *env) {
}
void WAMRWASIContext::restore_impl(WASIContext *env) {
int r;
// std::string stdin_fd= "/dev/stdin";
// wamr->invoke_fopen(stdin_fd, 0);
// std::string stdout_fd= "/dev/stdout";
// wamr->invoke_fopen(stdout_fd, 0);
// std::string stderr_fd= "/dev/stderr";
// wamr->invoke_fopen(stderr_fd, 0);
for (auto [fd, res] : this->fd_map) {
// differ from path from file
LOGV(INFO) << "fd: " << fd << " path: " << std::get<0>(res) << " flags: " << std::get<1>(res)
Expand Down
2 changes: 2 additions & 0 deletions test/read-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ int main() {
size_t len2 = strlen(line2);

fwrite(line1, sizeof(char), len1, file3);
//ntwritten
// checkpoint: lib_wasi_wrapper fwrite system record


// volatile int c = 0;
Expand Down

0 comments on commit c70c9e9

Please sign in to comment.