aboutsummaryrefslogtreecommitdiff
path: root/src/monkey/gdbmi_target_man.c
blob: bbb2b9807986a972459f140e8fe43d6b68ff6635 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**[txh]********************************************************************

  Copyright (c) 2004-2007 by Salvador E. Tropea.
  Covered by the GPL license.

  Module: Target manipulation.
  Comments:
  GDB/MI commands for the "Target Manipulation" section.  @<p>

@<pre>
-target-attach                  Yes (implemented using attach)
-target-compare-sections        N.A. (compare-sections)
-target-detach                  Yes
-target-download                Yes
-target-exec-status             N.A.
-target-list-available-targets  N.A. (help target)
-target-list-current-targets    N.A. (info file among other things)
-target-list-parameters         N.A.
-target-select                  Yes
@</pre>

***************************************************************************/

#include "gdbmi.h"

/* Low level versions. */

void mi_target_select(mi_h *h, const char *type, const char *params)
{
 mi_send(h,"-target-select %s %s\n",type,params);
}

/* Note: -target-attach isn't currently implemented :-( (gdb 6.1.1) */
void mi_target_attach(mi_h *h, pid_t pid)
{
 mi_send(h,"attach %d\n",pid);
}

void mi_target_detach(mi_h *h)
{
 mi_send(h,"-target-detach\n");
}

void mi_target_download(mi_h *h)
{
 mi_send(h,"-target-download\n");
}

/* High level versions. */

/**[txh]********************************************************************

  Description:
  Connect to a remote gdbserver using the specified methode.

  Command: -target-select
  Return: !=0 OK
  
***************************************************************************/

int gmi_target_select(mi_h *h, const char *type, const char *params)
{
 mi_target_select(h,type,params);
 if (!mi_res_simple_connected(h))
    return 0;
 mi_send_target_commands(h);
 return 1;
}

/**[txh]********************************************************************

  Description:
  Attach to an already running process.

  Command: -target-attach [using attach]
  Return: The frame of the current location, NULL on error.
  
***************************************************************************/

mi_frames *gmi_target_attach(mi_h *h, pid_t pid)
{
 mi_target_attach(h,pid);
 //return mi_res_simple_done(h);
 return mi_res_frame(h);
}

/**[txh]********************************************************************

  Description:
  Detach from an attached process.

  Command: -target-detach
  Return: !=0 OK
  
***************************************************************************/

int gmi_target_detach(mi_h *h)
{
 mi_target_detach(h);
 return mi_res_simple_done(h);
}

/**[txh]********************************************************************

  Description:
  Loads the executable onto the remote target.

  Command: -target-download
  Return: !=0 OK
  
***************************************************************************/

int gmi_target_download(mi_h *h)
{
 mi_target_download(h);
 // TODO: this response have some data
 return mi_res_simple_done(h);
}