Skip to content

Conversation

@galpeter
Copy link
Contributor

@galpeter galpeter commented Jan 8, 2019

Changed the debugger-tcp.c file to include Windows specific
socket handling code.

Added appveyor configuration to build with and without debugger.

@galpeter galpeter added the debugger Related to the debugger label Jan 8, 2019
@galpeter
Copy link
Contributor Author

galpeter commented Jan 8, 2019

Currently on newer gcc there is a bit of problem:

jerry-ext/debugger/debugger-tcp.c: In function ‘jerryx_debugger_tcp_log_error’:
jerry-ext/debugger/debugger-tcp.c:103:3: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
   JERRYX_ERROR_MSG (format, strerror (err_val));

Currently checking on how this can be fixed.

@galpeter galpeter force-pushed the debugger_win branch 4 times, most recently from b797774 to 52dc2e6 Compare January 9, 2019 16:18
@galpeter galpeter force-pushed the debugger_win branch 2 times, most recently from 5a067a2 to f5921cd Compare January 10, 2019 12:34
@galpeter
Copy link
Contributor Author

I've updated the PR.

Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

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

Good patch, only minor things.

@galpeter
Copy link
Contributor Author

@rerobika I've updated the PR.

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.

How much % of the file changed? Is it worth to keep this in 1 file?

#include <arpa/inet.h>
#include <errno.h>

#if defined (WIN32)
Copy link
Member

Choose a reason for hiding this comment

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

Nitpicking: All over the PR this is used like #ifdef WIN32. Could we unify it?

@galpeter
Copy link
Contributor Author

@zherczeg the biggest change is the creation of the jerryx_debugger_tcp_configure_socket method which was extracted from the jerryx_debugger_tcp_create method and this new method is the same on all platform. Almost all of the original methods only have one or two minor modifications (aside from the previously mentioned one).

target_link_libraries(${JERRY_EXT_NAME} jerry-core)

if(USING_MSVC AND FEATURE_DEBUGGER)
target_link_libraries(${JERRY_EXT_NAME} ws2_32.lib)
Copy link
Member

@akosthekiss akosthekiss Jan 14, 2019

Choose a reason for hiding this comment

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

Let's state it upfront, I'm not completely familiar with cmake on windows (although I had to play with it a bit): but is the .lib suffix/extension needed for target_link_libraries? Isn't that function working with "library names" and appends/prepends whatever is mandated by the platform/os? (E.g., name "xxx" gets converted to libxxx.a, libxxx.so, xxx.lib, xxx.dll, etc. as needed?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, there is no need for the .lib extension.

*/
static void
jerryx_debugger_tcp_log_error (int err_val)
jerryx_debugger_tcp_log_error (const char *prefix, /**< message prefix */
Copy link
Member

Choose a reason for hiding this comment

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

minor: is the prefix really necessary? Are not all errors TCP-related so that it shouldn't be hardcoded? This is the TCP transport implementation after all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially I wanted to use the simple TCP error hard-coded prefix, but in this variant I've followed the original Error/TCP Error prefixes. I'm happy to change this to the "TCP Error" prefix.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Well, then, it's no big deal. I vote for a single prefix but whatever majority votes for should prevail.

}

int opt_value = 1;
if (bind (server_socket, (struct sockaddr *)&addr, sizeof (struct sockaddr)) != 0)
Copy link
Member

Choose a reason for hiding this comment

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

According to the docs of bind the 3rd arg should be the size of the 2nd arg. But addr is of type struct sockaddr_in, not struct sockaddr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh yeah. Currently it works as the sockaddr_in can be considered as a "subclass" of the sockaddr and they have the same size (at least on linux). But will change it to sizeof (struct sockaddr_in)

{
JERRYX_ERROR_MSG ("Error: %s\n", strerror (errno));
int error = jerryx_debugger_tcp_get_errno ();
jerryx_debugger_tcp_log_error ("Error", error);
Copy link
Member

Choose a reason for hiding this comment

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

These two lines can be merged. There is no need for a temp var.

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

Changed the debugger-tcp.c file to include Windows specific
socket handling code and mode user all components are compilable
for Windows.

Added appveyor configuration to build with and without debugger.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

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

LGTM (informal)

Copy link
Member

@akosthekiss akosthekiss left a comment

Choose a reason for hiding this comment

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

LGTM

@akosthekiss akosthekiss added jerry-port Related to the port API or the default port implementation jerry-ext Related to the jerry-ext library labels Jan 17, 2019
@akosthekiss akosthekiss merged commit 545c6c7 into jerryscript-project:master Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debugger Related to the debugger jerry-ext Related to the jerry-ext library 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.

4 participants