depend and jdwp

Signed-off-by: zako <luckyzako@163.com>
This commit is contained in:
zako 2021-12-16 23:51:24 +08:00
parent f3eb5cf83c
commit 4fed3fe8db
7 changed files with 20 additions and 19 deletions

View File

@ -31,7 +31,6 @@ hdc_common_sources = [
"${HDC_PATH}/src/common/tcp.cpp",
"${HDC_PATH}/src/common/transfer.cpp",
"${HDC_PATH}/src/common/usb.cpp",
"${HDC_PATH}/src/common/system_depend.cpp",
]
config("hdc_config") {
@ -50,6 +49,7 @@ ohos_executable("hdcd") {
"src/daemon/jdwp.cpp",
"src/daemon/main.cpp",
"src/daemon/shell.cpp",
"src/daemon/system_depend.cpp",
]
sources += hdc_common_sources

View File

@ -74,7 +74,6 @@ using std::vector;
#include "tcp.h"
#include "usb.h"
#include "file_descriptor.h"
#include "system_depend.h"
// clang-format on

View File

@ -32,6 +32,7 @@
#include "daemon_usb.h"
#include "daemon_forward.h"
#include "shell.h"
#include "system_depend.h"
#endif
// clang-format on

View File

@ -117,7 +117,7 @@ void HdcJdwp::ReadStream(uv_stream_t *pipe, ssize_t nread, const uv_buf_t *buf)
} else { // JS:pid PkgName
#ifdef JS_JDWP_CONNECT
struct JsMsgHeader *jsMsg = (struct JsMsgHeader *)p;
if (jsMsg->msgLen == nread) {
if (jsMsg->msgLen == static_cast<uint32_t>(nread)) {
pid = jsMsg->pid;
string pkgName = string((char *)p + sizeof(JsMsgHeader), jsMsg->msgLen - sizeof(JsMsgHeader));
ctxJdwp->pkgName = pkgName;

View File

@ -32,6 +32,19 @@ public:
bool CheckPIDExist(uint32_t targetPID);
private:
static constexpr uint8_t JS_PKG_MX_SIZE = 135;
static constexpr uint8_t JS_PKG_MIN_SIZE = 15; // JsMsgHeader + "pkgName:"uint8_t[7~127]
#ifdef JS_JDWP_CONNECT
struct JsMsgHeader {
uint32_t msgLen;
uint32_t pid;
};
string GetProcessListExtendPkgName();
static constexpr uint32_t JPID_TRACK_LIST_SIZE = 1024 * 4;
#else
static constexpr uint32_t JPID_TRACK_LIST_SIZE = 1024;
#endif // JS_JDWP_CONNECT
struct _PollFd {
int fd;
short events;
@ -54,27 +67,15 @@ private:
uv_pipe_t pipe;
HdcJdwp *thisClass;
bool finish;
uint8_t dummy;
uv_tcp_t jvmTCP;
string pkgName;
#ifdef JS_JDWP_CONNECT
char buf[JS_PKG_MX_SIZE];
string pkgName;
#else
char buf[sizeof(uint32_t)];
#endif // JS_JDWP_CONNECT
uint8_t dummy;
uv_tcp_t jvmTCP;
};
#ifdef JS_JDWP_CONNECT
struct JsMsgHeader {
uint32_t msgLen;
uint32_t pid;
};
static constexpr uint8_t JS_PKG_MIN_SIZE = 15; // JsMsgHeader + "pkgName:"uint8_t[7~127]
static constexpr uint8_t JS_PKG_MX_SIZE = 135;
static constexpr uint32_t JPID_TRACK_LIST_SIZE = 1024 * 4;
string GetProcessListExtendPkgName();
#else
static constexpr uint32_t JPID_TRACK_LIST_SIZE = 1024;
#endif // JS_JDWP_CONNECT
using HCtxJdwp = struct ContextJdwp *;
bool JdwpListen();

View File

@ -14,7 +14,7 @@
*/
#ifndef HDC_SYSTEM_DEPEND_H
#define HDC_SYSTEM_DEPEND_H
#include "common.h"
#include "../common/base.h"
namespace Hdc {
namespace SystemDepend {