From 8ba099d7e4e37bcc35c219695c1590295abbf60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Borb=C3=A9ly?= Date: Wed, 16 Aug 2017 09:36:20 +0200 Subject: [PATCH] Update the webpage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com --- 02.API-REFERENCE.md | 50 +++++++++++++++++++++++++++++++++++++++ 07.DEBUGGER.md | 57 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 101 insertions(+), 6 deletions(-) diff --git a/02.API-REFERENCE.md b/02.API-REFERENCE.md index 7d89354e9..d8e0e8d09 100644 --- a/02.API-REFERENCE.md +++ b/02.API-REFERENCE.md @@ -179,6 +179,26 @@ typedef struct } jerry_property_descriptor_t; ``` +## jerry_heap_stats_t + +**summary** + +Description of JerryScript heap memory stats. +It is for memory profiling. + +**Prototype** + +```c +typedef struct +{ + size_t version /**< the version of the stats struct */ + size_t size; /**< heap total size */ + size_t allocated_bytes; /**< currently allocated bytes */ + size_t peak_allocated_bytes; /**< peak allocated bytes */ + size_t reserved[4]; /**< padding for future extensions */ +} jerry_heap_stats_t; +``` + ## jerry_external_handler_t **Summary** @@ -533,6 +553,36 @@ main (void) - [jerry_cleanup](#jerry_cleanup) +## jerry_get_memory_stats + +**Summary** + +Get heap memory stats. + +**Prototype** + +```c +bool +jerry_get_memory_stats (jerry_heap_stats_t *out_stats_p); +``` + +- `out_stats_p` - out parameter, that provides the heap statistics. +- return value + - true, if run was successful + - false, otherwise. Usually it is because the MEM_STATS feature is not enabled. + +**Example** + +```c +jerry_heap_stats_t stats = {0}; +bool get_stats_ret = jerry_get_memory_stats (&stats); +``` + +**See also** + +- [jerry_init](#jerry_init) + + ## jerry_gc **Summary** diff --git a/07.DEBUGGER.md b/07.DEBUGGER.md index 6adcea377..4583e3140 100644 --- a/07.DEBUGGER.md +++ b/07.DEBUGGER.md @@ -35,18 +35,25 @@ can be used for transmitting debugger messages. ## Debugging JavaScript applications The debugger client must be connected to the server before the -JavaScript application runs. On-the-fly attachment is not supported -because the debugging information (e.g. line index of each possible -breakpoint location) is not preserved by JerryScript. The client is -expected to be run on a system with much more resources and it should -be capable of storing this information. JerryScript frees all debug -information after it is transmitted to the client to save memory. +JavaScript application runs. On-the-fly attachment is supported +for more than one file, right after of engine initialization +(this feature available with the python client). The debugging +information (e.g. line index of each possible -breakpoint location) +is not preserved by JerryScript. The client is expected to be run +on a system with much more resources and it should be capable of +storing this information. JerryScript frees all debug information +after it is transmitted to the client to save memory. The following argument makes JerryScript wait for a client connection: `--start-debug-server` +The following argument makes JerryScript wait for a client +source code: + +`--debugger-wait-source` + It is also recommended to increase the log level to see the *Waiting for client connection* message: @@ -204,3 +211,41 @@ jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint) jerry_debugger_stop_at_breakpoint (false); } ``` + +### jerry_debugger_wait_and_run_client_source + +**Summary** + +Stops the engine and puts that into a waiting loop. If the client send +a source code and the JerryScript receive that, then the function will +run the source with the initialized options, after that the engine will +wait for a new source until the client send a close signal. + +**Prototype** + +```c +jerry_debugger_wait_and_run_type_t +jerry_debugger_wait_and_run_client_source (jerry_value_t *return_value) +``` + +**Example** + +```c + jerry_init (JERRY_INIT_DEBUGGER); + + jerry_value_t run_result; + jerry_debugger_wait_and_run_type_t receive_status; + + do + { + receive_status = jerry_debugger_wait_and_run_client_source (&run_result); + + if (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED) + { + // Handle the fail (e.g. create an error). + } + + jerry_release_value (run_result); + } + while (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVED); +```