Skip to content

Commit 7b15eb2

Browse files
author
Levente Orban
authored
Add the missing structures (#10)
- Add 3 more structure for the debugger - Add the header types - Add the COMPUTE_ITEM_COUNT() macro - Add the MAX_BUFFER_SIZE checker JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
1 parent 85eca53 commit 7b15eb2

File tree

1 file changed

+90
-13
lines changed

1 file changed

+90
-13
lines changed

jerry-core/debugger/jerry-debugger.h

Lines changed: 90 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,101 @@
1616
#ifndef JERRY_DEBUGGER_H
1717
#define JERRY_DEBUGGER_H
1818

19-
#define MAX_MESSAGE_SIZE 128
19+
#include "jmem-allocator.h"
20+
#include <stdint.h>
21+
22+
#define MAX_BUFFER_SIZE 128
23+
24+
/**
25+
* Limited resources available for the engine, so it is important to
26+
* check the maximum buffer size. It need to be between 64 and 256.
27+
*/
28+
#if MAX_BUFFER_SIZE < 64 || MAX_BUFFER_SIZE > 256
29+
#error "Please define the MAX_BUFFER_SIZE between 64 and 256."
30+
#endif /* MAX_BUFFER_SIZE < 64 || MAX_BUFFER_SIZE > 256 */
31+
32+
/**
33+
* Calculate how many soruce file name, function name and breakpoint
34+
* can send in one buffer without overflow.
35+
*/
36+
#define JERRY_DEBUGGER_MAX_SIZE(type) \
37+
((MAX_BUFFER_SIZE - sizeof (jerry_debugger_message_header_t)) / sizeof (type))
38+
39+
/**
40+
* Types for the package
41+
*
42+
* This helps the debugger to decide what type of the data come
43+
* from the JerryScript. If the buffer size is not enough for
44+
* the message the engine split it up into many pieces. The header
45+
* of the last piece has a type with an '_END' postfix.
46+
*/
47+
typedef enum
48+
{
49+
JERRY_DEBUGGER_BREAKPOINT_LIST, /**< there is more piece of the breakpoint list */
50+
JERRY_DEBUGGER_BREAKPOINT_LIST_END, /**< the last piece of the breakpoint list
51+
* or when one buffer send is enough for the engine */
52+
JERRY_DEBUGGER_FUNCTION_NAME, /**< there is more piece of the function name */
53+
JERRY_DEBUGGER_FUNCTION_NAME_END, /**< the last piece of the function name
54+
* or when one buffer send is enough for the engine */
55+
JERRY_DEBUGGER_SOURCE_FILE_NAME, /**< there is more piece of the source file name */
56+
JERRY_DEBUGGER_SOURCE_FILE_NAME_END, /**< if we send the last piece of the source file name
57+
* or when one buffer send is enough for the engine */
58+
JERRY_DEBUGGER_UNIQUE_START_BYTE_CODE_CPTR, /**< byte code starter compressed pointer */
59+
} jerry_debugger_header_type_t;
60+
61+
/**
62+
* Package header
63+
*/
64+
typedef struct
65+
{
66+
jerry_debugger_header_type_t type; /**< type of the message */
67+
uint8_t size; /**< size of the message */
68+
} jerry_debugger_message_header_t;
69+
70+
/**
71+
* Source file name
72+
*/
73+
typedef struct
74+
{
75+
jerry_debugger_message_header_t header; /**< header of the message */
76+
char file_name[JERRY_DEBUGGER_MAX_SIZE (char)]; /**< JavaScript source file name */
77+
} jerry_debugger_message_source_name_t;
2078

2179
/**
22-
* Package header
23-
*/
24-
typdef struct
80+
* Function name
81+
*/
82+
typedef struct
2583
{
26-
uint8_t type; /**< type of the message */
27-
uint8_t size; /**< size of the message */
28-
} jerry_debug_message_header_t;
84+
jerry_debugger_message_header_t header; /**< header of the function name struct */
85+
char function_name[JERRY_DEBUGGER_MAX_SIZE (char)]; /**< the message which contains the function name */
86+
} jerry_debugger_message_function_name_t;
2987

3088
/**
31-
* Source file name
32-
*/
33-
typdef struct
89+
* Byte code compressed pointer
90+
*/
91+
typedef struct
92+
{
93+
jerry_debugger_message_header_t header; /**< header of the struct */
94+
jmem_cpointer_t byte_code_cp; /**< the byte code compressed pointer */
95+
} jerry_debugger_byte_code_cptr_t;
96+
97+
/**
98+
* Breakpoint pairs
99+
*/
100+
typedef struct
101+
{
102+
uint32_t offset; /**< breakpoint line offset */
103+
uint32_t line; /**< breakpoint line index */
104+
} jerry_debugger_bp_pairs_t;
105+
106+
/**
107+
* Breakpoint list
108+
*/
109+
typedef struct
34110
{
35-
jerry_debug_message_header header; /**< header of the source file name struct */
36-
char file_name[1]; /**< the message */
37-
} jerry_debug_message_source_name_t;
111+
jerry_debugger_message_header_t header; /**< header of the struct */
112+
/** array of the breakpoint pairs */
113+
jerry_debugger_bp_pairs_t breakpoint_pairs[JERRY_DEBUGGER_MAX_SIZE (jerry_debugger_bp_pairs_t)];
114+
} jerry_debugger_breakpoint_list_t;
38115

39116
#endif /* JERRY_DEBUGGER_H */

0 commit comments

Comments
 (0)