Skip to content

Commit

Permalink
Fix bugs in popen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Ex-Origin committed Apr 27, 2024
1 parent 11cb0ec commit d7e51e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ size_t get_address(int pid, char *search)
}
close(fd);
}
else
{
warning_printf("%s open failed.\n", buf);
}
return result;
}

Expand Down Expand Up @@ -106,8 +110,6 @@ int command_handler()
}
clientPort = ntohs(client_addr.sin6_port);

debug_printf("Receive %s:%d from command_sock\n", ip_buf, clientPort);

command = buf[0];
switch(command)
{
Expand All @@ -121,6 +123,7 @@ int command_handler()

break;
case COMMAND_GDBSERVER_ATTACH:
debug_printf("Receive %s:%d from command_sock to COMMAND_GDBSERVER_ATTACH\n", ip_buf, clientPort);
if(gdb_client_address.sin6_family)
{
if(arg_opt_p)
Expand Down Expand Up @@ -174,6 +177,7 @@ int command_handler()

break;
case COMMAND_STRACE_ATTACH:
debug_printf("Receive %s:%d from command_sock to COMMAND_STRACE_ATTACH\n", ip_buf, clientPort);
if(arg_opt_p)
{
pid = arg_pid;
Expand Down Expand Up @@ -212,8 +216,9 @@ int command_handler()

break;
case COMMAND_GET_ADDRESS:
debug_printf("Receive %s:%d from command_sock to COMMAND_GET_ADDRESS\n", ip_buf, clientPort);
addr = 0;
if(arg_opt_p)
if(arg_opt_o)
{
addr = get_address(popen_to_int(arg_popen), buf + 2);
}
Expand All @@ -235,6 +240,7 @@ int command_handler()
warning_printf("Receive COMMAND_GDB_LOGOUT from %s:%d\n", ip_buf, clientPort);
break;
case COMMAND_RUN_SERVICE:
debug_printf("Receive %s:%d from command_sock to COMMAND_RUN_SERVICE\n", ip_buf, clientPort);
start_service(0);

client_addr_size = sizeof(client_addr);
Expand Down
2 changes: 1 addition & 1 deletion src/debug-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define COMMAND_PORT 9545
#define GDBSERVER_PORT 9549

#define VERSION "1.3.2"
#define VERSION "1.3.3"

#define COMMAND_GDB_REGISTER 0x01
#define COMMAND_GDBSERVER_ATTACH 0x02
Expand Down

0 comments on commit d7e51e2

Please sign in to comment.