Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm][debugger] Reuse debugger-agent on wasm debugger #52300

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7d8de9c
Trying to reuse debugger-agent on wasm debugger. This will remove a l…
thaystg May 5, 2021
8be82ed
Replace remove_breakpoint and clear_all_breakpoints with the ones on …
thaystg May 5, 2021
1fa738d
Stepping and callstack using debugger-agent.
thaystg May 6, 2021
f97cf27
Remove more code.
thaystg May 6, 2021
0242f6a
Get frame values using debugger-agent.
thaystg May 6, 2021
adae934
Working valuetypes and call function on valuetypes.
thaystg May 11, 2021
1f620dc
Failed: 316, Passed: 175
thaystg May 12, 2021
4bf5e0c
Failed: 307, Passed: 184, Skipped: 0, Total: 491
thaystg May 12, 2021
c853b1b
Failed: 280, Passed: 211
thaystg May 12, 2021
372157a
Failed: 277, Passed: 214
thaystg May 12, 2021
d837444
Implemented boxed value.
thaystg May 13, 2021
07ff48a
Implementing get properties on objects.
thaystg May 14, 2021
6585dce
Implementing callfunctionon object.
thaystg May 17, 2021
adbe8de
Implementing get pointer values.
thaystg May 17, 2021
7be985c
Fixing pointer values and implement call on function with pointers.
thaystg May 17, 2021
8f88612
Reimplement call function on, and implement set values.
thaystg May 19, 2021
478016d
Failed: 192, Passed: 299
thaystg May 19, 2021
50d657e
Fixing valuetype with null values.
thaystg May 20, 2021
212c081
Implemented Evaluate expressions, conditional breakpoints, all breakp…
thaystg May 21, 2021
7186b98
Fixing evaluate with value type.
thaystg May 21, 2021
26cf882
Trim part and add cache.
thaystg May 21, 2021
a8f98b5
Fixing evaluate expression.
thaystg May 21, 2021
4010546
GetPropertiesTests working.
thaystg May 25, 2021
fb323d0
Passing delegate tests.
thaystg May 25, 2021
380e6dd
Removing unused code.
thaystg May 25, 2021
0712ae1
Implementing exception handler.
thaystg May 26, 2021
d143ecf
Fixing cfo returning array.
thaystg May 26, 2021
0a4c964
Fix CallFunctionOn returning primitive types and null.
thaystg May 27, 2021
d90031b
Failed: 7, Passed: 482
thaystg May 28, 2021
c41ad02
Fixing some tests.
thaystg May 28, 2021
2581d1d
Removing a lot of code.
thaystg May 28, 2021
150aeac
0 ERRORS!
thaystg May 31, 2021
9155bba
Removing more code.
thaystg Jun 1, 2021
c4bf8fc
Merge remote-tracking branch 'upstream/main' into thays_remove_mini_w…
thaystg Jun 1, 2021
650b405
Fixing added tests.
thaystg Jun 1, 2021
62de11b
Return javascript callstack after managed callstack.
thaystg Jun 2, 2021
da783b6
Change what Ankit suggested.
thaystg Jun 2, 2021
8d0005f
Fixing suggestions.
thaystg Jun 2, 2021
67723dc
Fix error on wasm build.
thaystg Jun 2, 2021
00a459e
Apply suggestions from code review
thaystg Jun 11, 2021
d3abbf2
Changing what was suggested by @lewing.
thaystg Jun 11, 2021
c4c9fa3
Fix pointer tests.
thaystg Jun 11, 2021
fc8ec74
Refactoring CreateJObjectForVariableValue
thaystg Jun 14, 2021
62b15f8
Changing what @lewing suggested.
thaystg Jun 14, 2021
f797f9e
Apply suggestions from code review
thaystg Jun 17, 2021
5b2994d
Update src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs
thaystg Jun 17, 2021
d4f1d87
Update src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
thaystg Jun 17, 2021
6645cc5
Fixing @lewing changes.
thaystg Jun 17, 2021
a61f75e
Trying to fix CI.
thaystg Jun 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
340 changes: 194 additions & 146 deletions src/mono/mono/mini/debugger-agent.c

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions src/mono/mono/mini/debugger-agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,45 @@
#define __MONO_DEBUGGER_AGENT_H__

#include "mini.h"
#include "debugger-protocol.h"

#include <mono/utils/mono-stack-unwinding.h>

#define MONO_DBG_CALLBACKS_VERSION (4)
// 2. debug_log parameters changed from MonoString* to MonoStringHandle
// 3. debug_log parameters changed from MonoStringHandle back to MonoString*

typedef struct _InvokeData InvokeData;

struct _InvokeData
{
int id;
int flags;
guint8 *p;
guint8 *endp;
/* This is the context which needs to be restored after the invoke */
MonoContext ctx;
gboolean has_ctx;
/*
* If this is set, invoke this method with the arguments given by ARGS.
*/
MonoMethod *method;
gpointer *args;
guint32 suspend_count;
int nmethods;

InvokeData *last_invoke;
};

typedef struct {
const char *name;
void (*connect) (const char *address);
void (*close1) (void);
void (*close2) (void);
gboolean (*send) (void *buf, int len);
int (*recv) (void *buf, int len);
} DebuggerTransport;

struct _MonoDebuggerCallbacks {
int version;
void (*parse_options) (char *options);
Expand Down Expand Up @@ -46,4 +79,28 @@ mono_debugger_agent_stub_init (void);
MONO_API MONO_RT_EXTERNAL_ONLY gboolean
mono_debugger_agent_transport_handshake (void);

MONO_API void
mono_debugger_agent_register_transport (DebuggerTransport *trans);

MdbgProtErrorCode
mono_process_dbg_packet (int id, MdbgProtCommandSet command_set, int command, gboolean *no_reply, guint8 *p, guint8 *end, MdbgProtBuffer *buf);

void
mono_init_debugger_agent_for_wasm (int log_level);

void*
mono_dbg_create_breakpoint_events (GPtrArray *ss_reqs, GPtrArray *bp_reqs, MonoJitInfo *ji, MdbgProtEventKind kind);

void
mono_dbg_process_breakpoint_events (void *_evts, MonoMethod *method, MonoContext *ctx, int il_offset);

void
mono_wasm_save_thread_context (void);

DebuggerTlsData*
mono_wasm_get_tls (void);

MdbgProtErrorCode
mono_do_invoke_method (DebuggerTlsData *tls, MdbgProtBuffer *buf, InvokeData *invoke, guint8 *p, guint8 **endp);

#endif
7 changes: 0 additions & 7 deletions src/mono/mono/mini/debugger-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,6 @@ collect_domain_bp (gpointer key, gpointer value, gpointer user_data)
jit_mm_unlock (jit_mm);
}

void
mono_de_clear_all_breakpoints (void)
{
while (breakpoints->len)
mono_de_clear_breakpoint ((MonoBreakpoint*)g_ptr_array_index (breakpoints, 0));
}

/*
* mono_de_set_breakpoint:
*
Expand Down
7 changes: 6 additions & 1 deletion src/mono/mono/mini/debugger-engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ MonoBreakpoint* mono_de_set_breakpoint (MonoMethod *method, long il_offset, Even
void mono_de_collect_breakpoints_by_sp (SeqPoint *sp, MonoJitInfo *ji, GPtrArray *ss_reqs, GPtrArray *bp_reqs);
void mono_de_clear_breakpoints_for_domain (MonoDomain *domain);
void mono_de_add_pending_breakpoints (MonoMethod *method, MonoJitInfo *ji);
void mono_de_clear_all_breakpoints (void);
MonoBreakpoint * mono_de_get_breakpoint_by_id (int id);

//single stepping
Expand Down Expand Up @@ -545,3 +544,9 @@ void win32_debugger_log(FILE *stream, const gchar *format, ...);
#define PRINT_ERROR_MSG(...) g_printerr (__VA_ARGS__)
#define PRINT_MSG(...) g_print (__VA_ARGS__)
#endif

int
mono_ss_create_init_args (SingleStepReq *ss_req, SingleStepArgs *args);

void
mono_ss_args_destroy (SingleStepArgs *ss_args);
11 changes: 11 additions & 0 deletions src/mono/mono/mini/debugger-protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ m_dbgprot_decode_int (uint8_t *buf, uint8_t **endbuf, uint8_t *limit)
*endbuf = buf + 4;
g_assert (*endbuf <= limit);

#ifndef HOST_WASM
return (((int)buf [0]) << 24) | (((int)buf [1]) << 16) | (((int)buf [2]) << 8) | (((int)buf [3]) << 0);
#else
return (((int)buf [0]) << 0) | (((int)buf [1]) << 8) | (((int)buf [2]) << 16) | (((int)buf [3]) << 24);
#endif
}

int64_t
Expand Down Expand Up @@ -194,10 +198,17 @@ void
m_dbgprot_buffer_add_int (MdbgProtBuffer *buf, uint32_t val)
{
m_dbgprot_buffer_make_room (buf, 4);
#ifndef HOST_WASM
buf->p [0] = (val >> 24) & 0xff;
buf->p [1] = (val >> 16) & 0xff;
buf->p [2] = (val >> 8) & 0xff;
buf->p [3] = (val >> 0) & 0xff;
#else
buf->p [0] = (val >> 0) & 0xff;
buf->p [1] = (val >> 8) & 0xff;
buf->p [2] = (val >> 16) & 0xff;
buf->p [3] = (val >> 24) & 0xff;
#endif
buf->p += 4;
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/mini/debugger-protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ typedef enum {
MDBGPROT_CMD_VM_START_BUFFERING = 14,
MDBGPROT_CMD_VM_STOP_BUFFERING = 15,
MDBGPROT_CMD_VM_READ_MEMORY = 16,
MDBGPROT_CMD_VM_WRITE_MEMORY = 17
MDBGPROT_CMD_VM_WRITE_MEMORY = 17,
MDBGPROT_CMD_GET_ASSEMBLY_BY_NAME = 18
} MdbgProtCmdVM;

typedef enum {
Expand Down
Loading