Explorar el Código

debug-engine: Reduce the default MAX_PACKET_SIZE (#1425)

YAMAMOTO Takashi hace 3 años
padre
commit
6b073af3b0
Se han modificado 1 ficheros con 20 adiciones y 1 borrados
  1. 20 1
      core/iwasm/libraries/debug-engine/handler.c

+ 20 - 1
core/iwasm/libraries/debug-engine/handler.c

@@ -10,7 +10,26 @@
 #include "utils.h"
 #include "wasm_runtime.h"
 
-#define MAX_PACKET_SIZE (0x20000)
+/*
+ * Note: A moderate MAX_PACKET_SIZE is ok because
+ * LLDB queries our buffer size (via qSupported PacketSize)
+ * and limits packet sizes accordingly.
+ */
+
+#if defined(DEBUG_MAX_PACKET_SIZE)
+#define MAX_PACKET_SIZE DEBUG_MAX_PACKET_SIZE
+#else
+#define MAX_PACKET_SIZE (4096)
+#endif
+
+/*
+ * Note: It's assumed that MAX_PACKET_SIZE is reasonably large.
+ * See GetWorkingDir, WasmCallStack, etc.
+ */
+#if MAX_PACKET_SIZE < PATH_MAX || MAX_PACKET_SIZE < (2048 + 1)
+#error MAX_PACKET_SIZE is too small
+#endif
+
 static char *tmpbuf;
 static korp_mutex tmpbuf_lock;