Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
2e75a17b
Commit
2e75a17b
authored
9 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
esp8266: Fix issue when current repl line was garbage-collected.
Reference it from root pointers section.
parent
b1dfdaf6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
esp8266/mpconfigport.h
+1
-0
1 addition, 0 deletions
esp8266/mpconfigport.h
lib/utils/pyexec.c
+21
-18
21 additions, 18 deletions
lib/utils/pyexec.c
with
22 additions
and
18 deletions
esp8266/mpconfigport.h
+
1
−
0
View file @
2e75a17b
...
@@ -126,6 +126,7 @@ extern const struct _mp_obj_module_t onewire_module;
...
@@ -126,6 +126,7 @@ extern const struct _mp_obj_module_t onewire_module;
#define MICROPY_PORT_ROOT_POINTERS \
#define MICROPY_PORT_ROOT_POINTERS \
const char *readline_hist[8]; \
const char *readline_hist[8]; \
vstr_t *repl_line; \
mp_obj_t mp_kbd_exception; \
mp_obj_t mp_kbd_exception; \
// We need to provide a declaration/definition of alloca()
// We need to provide a declaration/definition of alloca()
...
...
This diff is collapsed.
Click to expand it.
lib/utils/pyexec.c
+
21
−
18
View file @
2e75a17b
...
@@ -121,8 +121,11 @@ STATIC int parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_ki
...
@@ -121,8 +121,11 @@ STATIC int parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_ki
#if MICROPY_REPL_EVENT_DRIVEN
#if MICROPY_REPL_EVENT_DRIVEN
typedef
struct
_repl_t
{
typedef
struct
_repl_t
{
// XXX line holds a root pointer!
// This structure originally also held current REPL line,
vstr_t
line
;
// but it was moved to MP_STATE_VM(repl_line) as containing
// root pointer. Still keep structure in case more state
// will be added later.
//vstr_t line;
bool
cont_line
;
bool
cont_line
;
}
repl_t
;
}
repl_t
;
...
@@ -132,9 +135,9 @@ STATIC int pyexec_raw_repl_process_char(int c);
...
@@ -132,9 +135,9 @@ STATIC int pyexec_raw_repl_process_char(int c);
STATIC
int
pyexec_friendly_repl_process_char
(
int
c
);
STATIC
int
pyexec_friendly_repl_process_char
(
int
c
);
void
pyexec_event_repl_init
(
void
)
{
void
pyexec_event_repl_init
(
void
)
{
vstr_init
(
&
repl
.
line
,
32
);
MP_STATE_VM
(
repl
_
line
)
=
vstr_new_size
(
32
);
repl
.
cont_line
=
false
;
repl
.
cont_line
=
false
;
readline_init
(
&
repl
.
line
,
">>> "
);
readline_init
(
MP_STATE_VM
(
repl
_
line
)
,
">>> "
);
if
(
pyexec_mode_kind
==
PYEXEC_MODE_RAW_REPL
)
{
if
(
pyexec_mode_kind
==
PYEXEC_MODE_RAW_REPL
)
{
pyexec_raw_repl_process_char
(
CHAR_CTRL_A
);
pyexec_raw_repl_process_char
(
CHAR_CTRL_A
);
}
else
{
}
else
{
...
@@ -155,27 +158,27 @@ STATIC int pyexec_raw_repl_process_char(int c) {
...
@@ -155,27 +158,27 @@ STATIC int pyexec_raw_repl_process_char(int c) {
return
0
;
return
0
;
}
else
if
(
c
==
CHAR_CTRL_C
)
{
}
else
if
(
c
==
CHAR_CTRL_C
)
{
// clear line
// clear line
vstr_reset
(
&
repl
.
line
);
vstr_reset
(
MP_STATE_VM
(
repl
_
line
)
)
;
return
0
;
return
0
;
}
else
if
(
c
==
CHAR_CTRL_D
)
{
}
else
if
(
c
==
CHAR_CTRL_D
)
{
// input finished
// input finished
}
else
{
}
else
{
// let through any other raw 8-bit value
// let through any other raw 8-bit value
vstr_add_byte
(
&
repl
.
line
,
c
);
vstr_add_byte
(
MP_STATE_VM
(
repl
_
line
)
,
c
);
return
0
;
return
0
;
}
}
// indicate reception of command
// indicate reception of command
mp_hal_stdout_tx_str
(
"OK"
);
mp_hal_stdout_tx_str
(
"OK"
);
if
(
repl
.
line
.
len
==
0
)
{
if
(
MP_STATE_VM
(
repl
_
line
)
->
len
==
0
)
{
// exit for a soft reset
// exit for a soft reset
mp_hal_stdout_tx_str
(
"
\r\n
"
);
mp_hal_stdout_tx_str
(
"
\r\n
"
);
vstr_clear
(
&
repl
.
line
);
vstr_clear
(
MP_STATE_VM
(
repl
_
line
)
)
;
return
PYEXEC_FORCED_EXIT
;
return
PYEXEC_FORCED_EXIT
;
}
}
mp_lexer_t
*
lex
=
mp_lexer_new_from_str_len
(
MP_QSTR__lt_stdin_gt_
,
repl
.
line
.
buf
,
repl
.
line
.
len
,
0
);
mp_lexer_t
*
lex
=
mp_lexer_new_from_str_len
(
MP_QSTR__lt_stdin_gt_
,
MP_STATE_VM
(
repl
_
line
)
->
buf
,
MP_STATE_VM
(
repl
_
line
)
->
len
,
0
);
if
(
lex
==
NULL
)
{
if
(
lex
==
NULL
)
{
mp_hal_stdout_tx_str
(
"
\x04
MemoryError
\r\n\x04
"
);
mp_hal_stdout_tx_str
(
"
\x04
MemoryError
\r\n\x04
"
);
}
else
{
}
else
{
...
@@ -186,7 +189,7 @@ STATIC int pyexec_raw_repl_process_char(int c) {
...
@@ -186,7 +189,7 @@ STATIC int pyexec_raw_repl_process_char(int c) {
}
}
reset:
reset:
vstr_reset
(
&
repl
.
line
);
vstr_reset
(
MP_STATE_VM
(
repl
_
line
)
)
;
mp_hal_stdout_tx_str
(
">"
);
mp_hal_stdout_tx_str
(
">"
);
return
0
;
return
0
;
...
@@ -216,7 +219,7 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
...
@@ -216,7 +219,7 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
}
else
if
(
ret
==
CHAR_CTRL_D
)
{
}
else
if
(
ret
==
CHAR_CTRL_D
)
{
// exit for a soft reset
// exit for a soft reset
mp_hal_stdout_tx_str
(
"
\r\n
"
);
mp_hal_stdout_tx_str
(
"
\r\n
"
);
vstr_clear
(
&
repl
.
line
);
vstr_clear
(
MP_STATE_VM
(
repl
_
line
)
)
;
return
PYEXEC_FORCED_EXIT
;
return
PYEXEC_FORCED_EXIT
;
}
}
...
@@ -224,11 +227,11 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
...
@@ -224,11 +227,11 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
return
0
;
return
0
;
}
}
if
(
!
mp_repl_continue_with_input
(
vstr_null_terminated_str
(
&
repl
.
line
)))
{
if
(
!
mp_repl_continue_with_input
(
vstr_null_terminated_str
(
MP_STATE_VM
(
repl
_
line
)))
)
{
goto
exec
;
goto
exec
;
}
}
vstr_add_byte
(
&
repl
.
line
,
'\n'
);
vstr_add_byte
(
MP_STATE_VM
(
repl
_
line
)
,
'\n'
);
repl
.
cont_line
=
true
;
repl
.
cont_line
=
true
;
readline_note_newline
(
"... "
);
readline_note_newline
(
"... "
);
return
0
;
return
0
;
...
@@ -249,14 +252,14 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
...
@@ -249,14 +252,14 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
return
0
;
return
0
;
}
}
if
(
mp_repl_continue_with_input
(
vstr_null_terminated_str
(
&
repl
.
line
)))
{
if
(
mp_repl_continue_with_input
(
vstr_null_terminated_str
(
MP_STATE_VM
(
repl
_
line
)))
)
{
vstr_add_byte
(
&
repl
.
line
,
'\n'
);
vstr_add_byte
(
MP_STATE_VM
(
repl
_
line
)
,
'\n'
);
readline_note_newline
(
"... "
);
readline_note_newline
(
"... "
);
return
0
;
return
0
;
}
}
exec:
;
exec:
;
mp_lexer_t
*
lex
=
mp_lexer_new_from_str_len
(
MP_QSTR__lt_stdin_gt_
,
vstr_str
(
&
repl
.
line
),
vstr_len
(
&
repl
.
line
),
0
);
mp_lexer_t
*
lex
=
mp_lexer_new_from_str_len
(
MP_QSTR__lt_stdin_gt_
,
vstr_str
(
MP_STATE_VM
(
repl
_
line
)
)
,
vstr_len
(
MP_STATE_VM
(
repl
_
line
)
)
,
0
);
if
(
lex
==
NULL
)
{
if
(
lex
==
NULL
)
{
printf
(
"MemoryError
\n
"
);
printf
(
"MemoryError
\n
"
);
}
else
{
}
else
{
...
@@ -267,9 +270,9 @@ exec: ;
...
@@ -267,9 +270,9 @@ exec: ;
}
}
input_restart:
input_restart:
vstr_reset
(
&
repl
.
line
);
vstr_reset
(
MP_STATE_VM
(
repl
_
line
)
)
;
repl
.
cont_line
=
false
;
repl
.
cont_line
=
false
;
readline_init
(
&
repl
.
line
,
">>> "
);
readline_init
(
MP_STATE_VM
(
repl
_
line
)
,
">>> "
);
return
0
;
return
0
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment