Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ matrix:
- name: "Checks"
env:
- OPTS="--check-signed-off=travis --check-cppcheck --check-doxygen --check-vera --check-license --check-magic-strings --check-pylint"
install: pip install --user pylint==1.6.5
install:
- pip install --user pylint==1.6.5
- pip install --user pybluez
Copy link
Member

Choose a reason for hiding this comment

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

Why do code smell and style checks need the installation of additional system and python packages?

But if they are needed, the system dependencies should be added to addons.apt.packages.

addons:
apt:
packages: [doxygen, cppcheck, vera++]
packages: [doxygen, cppcheck, vera++, libbluetooth-dev, python-dev]

- name: "Linux/x86-64 Build & Correctness Tests"
env:
Expand Down
26 changes: 24 additions & 2 deletions docs/07.DEBUGGER.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This simple application demonstrates the communication protocol
between the client and server, and can be reused by integrated
development environments.

## Setting up the debugger server
## Setting up TCP/IP debugger server

The following arguments must be passed to `tools/build.py`:

Expand All @@ -21,7 +21,23 @@ JerryScript extension, which transmits messages over TCP/IP networks.
If necessary/implemented, any reliable stream or datagram based
protocol can be used for transmitting debugger messages.

## Debugging JavaScript applications
## Setting up Bluetooth debugger server

The following arguments must be passed to `tools/build.py`:

`--jerry-bt-debugger=on`

The transport layer of the communication protocol is pluggable.
At the moment, a WebSocket-based implementation is provided as a
Copy link
Member

Choose a reason for hiding this comment

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

Is this true? It seems to me that the BT stack uses RFCOMM, i.e., "serial port emulation".

JerryScript extension, which transmits messages over Bluetooth network.

The following library is needed to build JerryScript
- libbluetooth-dev

The following python commands needed to run jerry-client.py
- sudo apt-get install -q python-dev
- pip install --user pylint==1.6.5 pybluez

Copy link
Member

Choose a reason for hiding this comment

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

Is the second new line is necessary?


The debugger client must be connected to the server before the
JavaScript application runs. On-the-fly attachment is supported
Expand All @@ -43,6 +59,12 @@ source code:

`--debugger-wait-source`

The following argument makes JerryScript create a server with
the given type. There are two choices, tcp or bluetooth.
(default: tcp)

`--server-type bluetooth`

It is also recommended to increase the log level to see
the *Waiting for client connection* message:

Expand Down
10 changes: 8 additions & 2 deletions jerry-debugger/jerry_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
from cmd import Cmd
from pprint import pprint
import math
import socket
import sys
import logging
import time
import re
import jerry_client_ws

def write(string):
Expand Down Expand Up @@ -291,8 +291,14 @@ def main():
if __name__ == "__main__":
try:
main()
except socket.error as error_msg:
except IOError as error_msg:
ERRNO = error_msg.errno
if not ERRNO:
# if there is no ERRNO then try to get it from the error arguments
MATCH = re.search(r"(\d+)", error_msg.args[0])
if MATCH:
ERRNO = int(MATCH.group(1))

MSG = str(error_msg)
if ERRNO == 111:
sys.exit("Failed to connect to the JerryScript debugger.")
Expand Down
24 changes: 18 additions & 6 deletions jerry-debugger/jerry_client_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,24 @@ def get_text(self):


class JerryDebugger(object):
# pylint: disable=too-many-instance-attributes,too-many-statements,too-many-public-methods,no-self-use
# pylint: disable=too-many-instance-attributes,too-many-statements,too-many-public-methods,no-self-use,too-many-branches
def __init__(self, address):

temp = address.split(":")
if ":" not in address:
self.host = address
self.port = 5001 # use default port
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
elif len(temp) == 2:
self.host = temp[0]
self.port = int(temp[1])
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
elif len(temp) == 6:
import bluetooth
self.host = address
self.port = 1 # use default port
self.client_socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
else:
self.host, self.port = address.split(":")
self.port = int(self.port)
raise Exception("Wrong address type")

print("Connecting to: %s:%s" % (self.host, self.port))

Expand Down Expand Up @@ -303,7 +312,6 @@ def __init__(self, address):
self.nocolor = ''
self.src_offset = 0
self.src_offset_diff = 0
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.client_socket.connect((self.host, self.port))
self.non_interactive = False
self.current_out = b""
Expand Down Expand Up @@ -385,7 +393,11 @@ def __init__(self, address):
self.message_data = result[len_expected:]

def __del__(self):
self.client_socket.close()
try:
self.client_socket.close()
except AttributeError:
pass


def _exec_command(self, command_id):
self.send_command(command_id)
Expand Down
12 changes: 12 additions & 0 deletions jerry-ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ project (${JERRY_EXT_NAME} C)

# Optional features
set(FEATURE_INIT_FINI OFF CACHE BOOL "Enable init/fini arrays?")
set(FEATURE_BT_DEBUGGER OFF CACHE BOOL "Enable JerryScript bluetooth?")


# Status messages
message(STATUS "FEATURE_INIT_FINI " ${FEATURE_INIT_FINI})
message(STATUS "FEATURE_BT_DEBUGGER " ${FEATURE_BT_DEBUGGER})


# Include directories
set(INCLUDE_EXT_PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
Expand All @@ -32,6 +36,10 @@ if(FEATURE_INIT_FINI)
set(DEFINES_EXT ${DEFINES_EXT} ENABLE_INIT_FINI)
endif()

if(FEATURE_BT_DEBUGGER AND FEATURE_DEBUGGER)
set(DEFINES_EXT ${DEFINES_EXT} JERRY_BT_DEBUGGER)
endif()

# Source directories
file(GLOB SOURCE_EXT
arg/*.c
Expand All @@ -49,3 +57,7 @@ target_link_libraries(${JERRY_EXT_NAME} jerry-core)

install(TARGETS ${JERRY_EXT_NAME} DESTINATION lib)
install(DIRECTORY ${INCLUDE_EXT_PUBLIC}/ DESTINATION include)

if(FEATURE_BT_DEBUGGER)
target_link_libraries(${JERRY_EXT_NAME} -lbluetooth)
Copy link
Member

Choose a reason for hiding this comment

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

It should be mentioned somewhere that this extension is heavily Linux-only. -lbluetooth will not work on macOS (which uses the IOBluetooth framework) or on Windows (which uses I-don't-know-what).

endif()
Loading