blob: d2c35dd711f7bc63e7c114030277fdab2667221c [file] [log] [blame]
Elliott Hughes872d4ec2011-10-21 17:07:15 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16/*
17 * JDWP internal interfaces.
18 */
19#ifndef ART_JDWP_JDWPPRIV_H_
20#define ART_JDWP_JDWPPRIV_H_
21
22#define LOG_TAG "jdwp"
23
24#include "debugger.h"
25#include "jdwp/jdwp.h"
26#include "jdwp/jdwp_event.h"
Elliott Hughes872d4ec2011-10-21 17:07:15 -070027
28#include <pthread.h>
29#include <sys/uio.h>
30
31/*
32 * JDWP constants.
33 */
34#define kJDWPHeaderLen 11
35#define kJDWPFlagReply 0x80
36
37/* DDM support */
38#define kJDWPDdmCmdSet 199 /* 0xc7, or 'G'+128 */
39#define kJDWPDdmCmd 1
40
41namespace art {
42
43namespace JDWP {
44
45/*
46 * Transport-specific network status.
47 */
48struct JdwpNetState;
49struct JdwpState;
50
51/*
52 * Transport functions.
53 */
54struct JdwpTransport {
Elliott Hughes376a7a02011-10-24 18:35:55 -070055 bool (*startup)(JdwpState* state, const JdwpOptions* options);
Elliott Hughes872d4ec2011-10-21 17:07:15 -070056 bool (*accept)(JdwpState* state);
57 bool (*establish)(JdwpState* state);
58 void (*close)(JdwpState* state);
59 void (*shutdown)(JdwpState* state);
60 void (*free)(JdwpState* state);
61 bool (*isConnected)(JdwpState* state);
62 bool (*awaitingHandshake)(JdwpState* state);
63 bool (*processIncoming)(JdwpState* state);
64 bool (*sendRequest)(JdwpState* state, ExpandBuf* pReq);
Elliott Hughescccd84f2011-12-05 16:51:54 -080065 bool (*sendBufferedRequest)(JdwpState* state, const iovec* iov, int iov_count);
Elliott Hughes872d4ec2011-10-21 17:07:15 -070066};
67
68const JdwpTransport* SocketTransport();
69const JdwpTransport* AndroidAdbTransport();
70
Elliott Hughes872d4ec2011-10-21 17:07:15 -070071/*
72 * Base class for JdwpNetState
73 */
74class JdwpNetStateBase {
75public:
76 int clientSock; /* active connection to debugger */
77
78 JdwpNetStateBase();
79 ssize_t writePacket(ExpandBuf* pReply);
Elliott Hughescccd84f2011-12-05 16:51:54 -080080 ssize_t writeBufferedPacket(const iovec* iov, int iov_count);
Elliott Hughes872d4ec2011-10-21 17:07:15 -070081
82private:
83 Mutex socket_lock_;
84};
85
Elliott Hughes872d4ec2011-10-21 17:07:15 -070086} // namespace JDWP
87
88} // namespace art
89
90#endif // ART_JDWP_JDWPPRIV_H_