Skip to content

Conversation

@robertsipka
Copy link
Contributor

Using jerry_parse_named_resource to parse script and construct an EcmaScript function.
The file name will also passed to this function which is used by the debugger to find
the source code.
Run the constructed EcmaScript function instead of using the simple jerry runner.

@robertsipka robertsipka added enhancement An improvement jerry-port Related to the port API or the default port implementation labels Feb 17, 2017
@robertsipka robertsipka force-pushed the stm32f4_debugger_support branch from a666e1e to b28347a Compare February 17, 2017 11:36
* Read source code into buffer.
*
* @return concatenated source files
* Returned value must be freed with jmem_heap_free_block if it's not NULL.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return missing

size_t *out_source_size_p)
static const uint8_t *
read_file (const char *file_name,
size_t *out_size_p)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are needed for these arguments.

@robertsipka robertsipka force-pushed the stm32f4_debugger_support branch from b28347a to db81b13 Compare February 17, 2017 14:11
Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few more changes.


fclose (file);
file = NULL;
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: failed to open file: %s\n", file_name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot open file

if (fseek_status != 0)
{
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "There's nothing to read\n");
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Failed to fseek fseek_status(%d)\n", fseek_status);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to seek (error: %d)

if (script_len < 0)
{
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Out of memory error\n");
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Failed to ftell script_len(%ld)\n", script_len);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to get the file size (error: %d)

rewind (file);

rewind (file);
uint8_t *buffer = jmem_heap_alloc_block (script_len);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variant cannot return with NULL. It is a good idea to use the other here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that I understand you correctly, but the jmem_heap_alloc_block can return with NULL if there is not enough memory. What do you mean 'other'?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void *jmem_heap_alloc_block (const size_t size);
void *jmem_heap_alloc_block_null_on_error (const size_t size);

The jmem_heap_alloc_block crashes on error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, I missed it, thanks! I've updated the PR.

@robertsipka robertsipka force-pushed the stm32f4_debugger_support branch 2 times, most recently from 0185228 to 39da457 Compare February 21, 2017 11:30
Copy link
Contributor

@LaszloLango LaszloLango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, after the comment fix

size_t *out_source_size_p)
static const uint8_t *
read_file (const char *file_name, /**< source code */
size_t *out_size_p) /**< number of bytes successfully read from source */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**< [out] number of bytes successfully read from source */

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Using jerry_parse_named_resource to parse script and construct an EcmaScript function.
The file name will also passed to this function which is used by the debugger to find
the source code.
Run the constructed EcmaScript function instead of using the simple jerry runner.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
@robertsipka robertsipka force-pushed the stm32f4_debugger_support branch from 39da457 to 38b0f87 Compare February 21, 2017 12:18
@robertsipka robertsipka merged commit 9043ec6 into jerryscript-project:master Feb 21, 2017
@robertsipka robertsipka deleted the stm32f4_debugger_support branch March 16, 2017 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An improvement jerry-port Related to the port API or the default port implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants