blob: f1e97b7bcc1ada9dc34919f375898bc634c152ae [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
Elliott Hughes872d4ec2011-10-21 17:07:15 -070022#include "debugger.h"
23#include "jdwp/jdwp.h"
24#include "jdwp/jdwp_event.h"
Elliott Hughes872d4ec2011-10-21 17:07:15 -070025
26#include <pthread.h>
27#include <sys/uio.h>
28
29/*
30 * JDWP constants.
31 */
32#define kJDWPHeaderLen 11
33#define kJDWPFlagReply 0x80
34
35/* DDM support */
36#define kJDWPDdmCmdSet 199 /* 0xc7, or 'G'+128 */
37#define kJDWPDdmCmd 1
38
39namespace art {
40
41namespace JDWP {
42
43/*
44 * Transport-specific network status.
45 */
46struct JdwpNetState;
47struct JdwpState;
48
49/*
50 * Transport functions.
51 */
52struct JdwpTransport {
Elliott Hughes376a7a02011-10-24 18:35:55 -070053 bool (*startup)(JdwpState* state, const JdwpOptions* options);
Elliott Hughes872d4ec2011-10-21 17:07:15 -070054 bool (*accept)(JdwpState* state);
55 bool (*establish)(JdwpState* state);
56 void (*close)(JdwpState* state);
57 void (*shutdown)(JdwpState* state);
58 void (*free)(JdwpState* state);
59 bool (*isConnected)(JdwpState* state);
60 bool (*awaitingHandshake)(JdwpState* state);
61 bool (*processIncoming)(JdwpState* state);
62 bool (*sendRequest)(JdwpState* state, ExpandBuf* pReq);
Elliott Hughescccd84f2011-12-05 16:51:54 -080063 bool (*sendBufferedRequest)(JdwpState* state, const iovec* iov, int iov_count);
Elliott Hughes872d4ec2011-10-21 17:07:15 -070064};
65
66const JdwpTransport* SocketTransport();
67const JdwpTransport* AndroidAdbTransport();
68
Elliott Hughes872d4ec2011-10-21 17:07:15 -070069/*
70 * Base class for JdwpNetState
71 */
72class JdwpNetStateBase {
73public:
74 int clientSock; /* active connection to debugger */
75
76 JdwpNetStateBase();
77 ssize_t writePacket(ExpandBuf* pReply);
Elliott Hughescccd84f2011-12-05 16:51:54 -080078 ssize_t writeBufferedPacket(const iovec* iov, int iov_count);
Elliott Hughes872d4ec2011-10-21 17:07:15 -070079
80private:
81 Mutex socket_lock_;
82};
83
Elliott Hughes872d4ec2011-10-21 17:07:15 -070084} // namespace JDWP
85
86} // namespace art
87
88#endif // ART_JDWP_JDWPPRIV_H_