summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Coutand2012-04-24 10:47:33 (EDT)
committer Eugene Tarassov2012-04-25 11:01:35 (EDT)
commit877a0e5288e82afba356fbfa089da6a9e30fe77c (patch)
treee611fe6d4760797ac02f0d923a9164e4eb82ce97
parent16a9c044ef5f3ff650dc8b29e4c63a3d7cbb96ee (diff)
downloadorg.eclipse.tcf.agent-877a0e5288e82afba356fbfa089da6a9e30fe77c.zip
org.eclipse.tcf.agent-877a0e5288e82afba356fbfa089da6a9e30fe77c.tar.gz
org.eclipse.tcf.agent-877a0e5288e82afba356fbfa089da6a9e30fe77c.tar.bz2
Add handling of invalid context in the getCapabilities command.
-rw-r--r--agent/tcf/services/breakpoints.c164
1 files changed, 85 insertions, 79 deletions
diff --git a/agent/tcf/services/breakpoints.c b/agent/tcf/services/breakpoints.c
index 2657b4a..f02b317 100644
--- a/agent/tcf/services/breakpoints.c
+++ b/agent/tcf/services/breakpoints.c
@@ -2160,103 +2160,109 @@ static void command_get_capabilities(char * token, Channel * c) {
char id[256];
Context * ctx;
OutputStream * out = &c->out;
+ int err = 0;
json_read_string(&c->inp, id, sizeof(id));
if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX);
if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);
ctx = id2ctx(id);
+ if ((strlen(id)>0) && !ctx) err = ERR_INV_CONTEXT;
write_stringz(out, "R");
write_stringz(out, token);
- write_errno(out, 0);
-
- write_stream(out, '{');
- json_write_string(out, "ID");
- write_stream(out, ':');
- json_write_string(out, id);
- write_stream(out, ',');
- json_write_string(out, "BreakpointType");
- write_stream(out, ':');
- json_write_boolean(out, 1);
- write_stream(out, ',');
- json_write_string(out, "Location");
- write_stream(out, ':');
- json_write_boolean(out, 1);
- write_stream(out, ',');
- json_write_string(out, "FileLine");
- write_stream(out, ':');
- json_write_boolean(out, ENABLE_LineNumbers);
- write_stream(out, ',');
- json_write_string(out, "FileMapping");
- write_stream(out, ':');
- json_write_boolean(out, SERVICE_PathMap);
- write_stream(out, ',');
- json_write_string(out, "IgnoreCount");
- write_stream(out, ':');
- json_write_boolean(out, 1);
- write_stream(out, ',');
- json_write_string(out, "Condition");
- write_stream(out, ':');
- json_write_boolean(out, 1);
- if (ctx != NULL) {
- int md = CTX_BP_ACCESS_INSTRUCTION;
- md |= context_get_supported_bp_access_types(ctx);
- md &= ~CTX_BP_ACCESS_VIRTUAL;
+ write_errno(out, err);
+ if (err) {
+ write_stringz(&c->out, "null");
+ }
+ else {
+ write_stream(out, '{');
+ json_write_string(out, "ID");
+ write_stream(out, ':');
+ json_write_string(out, id);
+ write_stream(out, ',');
+ json_write_string(out, "BreakpointType");
+ write_stream(out, ':');
+ json_write_boolean(out, 1);
+ write_stream(out, ',');
+ json_write_string(out, "Location");
+ write_stream(out, ':');
+ json_write_boolean(out, 1);
+ write_stream(out, ',');
+ json_write_string(out, "FileLine");
+ write_stream(out, ':');
+ json_write_boolean(out, ENABLE_LineNumbers);
+ write_stream(out, ',');
+ json_write_string(out, "FileMapping");
+ write_stream(out, ':');
+ json_write_boolean(out, SERVICE_PathMap);
+ write_stream(out, ',');
+ json_write_string(out, "IgnoreCount");
+ write_stream(out, ':');
+ json_write_boolean(out, 1);
+ write_stream(out, ',');
+ json_write_string(out, "Condition");
+ write_stream(out, ':');
+ json_write_boolean(out, 1);
+ if (ctx != NULL) {
+ int md = CTX_BP_ACCESS_INSTRUCTION;
+ md |= context_get_supported_bp_access_types(ctx);
+ md &= ~CTX_BP_ACCESS_VIRTUAL;
+ write_stream(out, ',');
+ json_write_string(out, "AccessMode");
+ write_stream(out, ':');
+ json_write_long(out, md);
+ }
+ write_stream(out, ',');
+ json_write_string(out, "ContextIds");
+ write_stream(out, ':');
+ json_write_boolean(out, 1);
write_stream(out, ',');
- json_write_string(out, "AccessMode");
+ json_write_string(out, "ContextNames");
write_stream(out, ':');
- json_write_long(out, md);
- }
- write_stream(out, ',');
- json_write_string(out, "ContextIds");
- write_stream(out, ':');
- json_write_boolean(out, 1);
- write_stream(out, ',');
- json_write_string(out, "ContextNames");
- write_stream(out, ':');
- json_write_boolean(out, 1);
+ json_write_boolean(out, 1);
#if SERVICE_ContextQuery
- write_stream(out, ',');
- json_write_string(out, "ContextQuery");
- write_stream(out, ':');
- json_write_boolean(out, 1);
+ write_stream(out, ',');
+ json_write_string(out, "ContextQuery");
+ write_stream(out, ':');
+ json_write_boolean(out, 1);
#endif
- write_stream(out, ',');
- json_write_string(out, "StopGroup");
- write_stream(out, ':');
- json_write_boolean(out, 1);
- write_stream(out, ',');
- json_write_string(out, "ClientData");
- write_stream(out, ':');
- json_write_boolean(out, 1);
- write_stream(out, ',');
- json_write_string(out, "Temporary");
- write_stream(out, ':');
- json_write_boolean(out, 1);
+ write_stream(out, ',');
+ json_write_string(out, "StopGroup");
+ write_stream(out, ':');
+ json_write_boolean(out, 1);
+ write_stream(out, ',');
+ json_write_string(out, "ClientData");
+ write_stream(out, ':');
+ json_write_boolean(out, 1);
+ write_stream(out, ',');
+ json_write_string(out, "Temporary");
+ write_stream(out, ':');
+ json_write_boolean(out, 1);
#if ENABLE_ContextBreakpointCapabilities
- {
- /* Back-end context breakpoint capabilities */
- int cnt = 0;
- const char ** names = NULL;
- const char ** values = NULL;
- if (context_get_breakpoint_capabilities(ctx, &names, &values, &cnt) == 0) {
- while (cnt > 0) {
- if (*values != NULL) {
- write_stream(out, ',');
- json_write_string(out, *names);
- write_stream(out, ':');
- write_string(out, *values);
+ {
+ /* Back-end context breakpoint capabilities */
+ int cnt = 0;
+ const char ** names = NULL;
+ const char ** values = NULL;
+ if (context_get_breakpoint_capabilities(ctx, &names, &values, &cnt) == 0) {
+ while (cnt > 0) {
+ if (*values != NULL) {
+ write_stream(out, ',');
+ json_write_string(out, *names);
+ write_stream(out, ':');
+ write_string(out, *values);
+ }
+ names++;
+ values++;
+ cnt--;
}
- names++;
- values++;
- cnt--;
}
}
- }
#endif
- write_stream(out, '}');
- write_stream(out, 0);
+ write_stream(out, '}');
+ write_stream(out, 0);
+ }
write_stream(out, MARKER_EOM);
}