1/*
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 * Dalvik Debug Monitor
18 */
19#ifndef DALVIK_DDM_H_
20#define DALVIK_DDM_H_
21
22/*
23 * Handle a packet full of DDM goodness.
24 *
25 * Returns "true" if we have anything to say in return; in which case,
26 * "*pReplyBuf" and "*pReplyLen" will also be set.
27 */
28bool dvmDdmHandlePacket(const u1* buf, int dataLen, u1** pReplyBuf,
29    int* pReplyLen);
30
31/*
32 * Deal with the DDM server connecting and disconnecting.
33 */
34void dvmDdmConnected(void);
35void dvmDdmDisconnected(void);
36
37/*
38 * Turn thread notification on or off.
39 */
40void dvmDdmSetThreadNotification(bool enable);
41
42/*
43 * If thread start/stop notification is enabled, call this when threads
44 * are created or die.
45 */
46void dvmDdmSendThreadNotification(Thread* thread, bool started);
47
48/*
49 * If thread start/stop notification is enabled, call this when the
50 * thread name changes.
51 */
52void dvmDdmSendThreadNameChange(int threadId, StringObject* newName);
53
54/*
55 * Generate a byte[] full of thread stats for a THST packet.
56 */
57ArrayObject* dvmDdmGenerateThreadStats(void);
58
59/*
60 * Let the heap know that the HPIF when value has changed.
61 *
62 * @return true iff the when value is supported by the VM.
63 */
64bool dvmDdmHandleHpifChunk(int when);
65
66/*
67 * Let the heap know that the HPSG or NHSG what/when values have changed.
68 *
69 * @param native false for an HPSG chunk, true for an NHSG chunk
70 *
71 * @return true iff the what/when values are supported by the VM.
72 */
73bool dvmDdmHandleHpsgNhsgChunk(int when, int what, bool native);
74
75/*
76 * Get an array of StackTraceElement objects for the specified thread.
77 */
78ArrayObject* dvmDdmGetStackTraceById(u4 threadId);
79
80/*
81 * Gather up recent allocation data and return it in a byte[].
82 *
83 * Returns NULL on failure with an exception raised.
84 */
85ArrayObject* dvmDdmGetRecentAllocations(void);
86
87#endif  // DALVIK_DDM_H_
88