void task2(task* pdata) { int start = 0; int end; int delay; INT8U err; int arrival = 3; OSTCBCur->Period = pdata->period; OSTCBCur->Exec = pdata->exec; OSTCBCur->ExecTime = pdata->exec; OSTCBCur->Start = 0; OSTCBCur->Deadline = pdata->period + arrival; OSTCBCur->Org_Deadline = pdata->period + arrival; OSTimeDly(arrival); while (1) { printf("\t%d\tTask_2\n",OSTimeGet()); mywait(OSTCBCur->Exec); // CPU time printf("\t%d\tTask_2 get R2\t",OSTimeGet()); OSMutexPend(R2, 0, &err); mywait(3); // R2 printf("\t%d\tTask_2 release R2",OSTimeGet()); OSMutexPost(R2); end = OSTimeGet(); delay = OSTCBCur->Deadline-end; // let it delay 1 timetick to avoid running the while loop OSTCBCur->Resp = end-start; start += pdata->period; OSTCBCur->Deadline += OSTCBCur->Period; OSTCBCur->Org_Deadline = OSTCBCur->Deadline; OSTimeDly(delay); } }
static int start_inferior (char *argv[], char *statusptr) { #ifdef SIGTTOU signal (SIGTTOU, SIG_DFL); signal (SIGTTIN, SIG_DFL); #endif signal_pid = create_inferior (argv[0], argv); fprintf (stderr, "Process %s created; pid = %ld\n", argv[0], signal_pid); fflush (stderr); #ifdef SIGTTOU signal (SIGTTOU, SIG_IGN); signal (SIGTTIN, SIG_IGN); terminal_fd = fileno (stderr); old_foreground_pgrp = tcgetpgrp (terminal_fd); tcsetpgrp (terminal_fd, signal_pid); atexit (restore_old_foreground_pgrp); #endif /* Wait till we are at 1st instruction in program, return signal number. */ return mywait (statusptr, 0); }
main() { char name[64]; int cmd; int pid; while(1){ pid = getpid(); printf("==============================================\n"); printf("Das ist prozess %d im Umode segment=%x\n", pid, getcs()); show_menu(); printf("Command ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : getpid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : mywait(); break; case 6 : myexit(); break; case 7 : ufork(); break; case 8 : myexec("/bin/u1"); break; case 9 : sin(); break; case 10: sout(); break; default: invalid(name); break; } } }
void mainControlLoop() { int started = 0; while(1) { if(role==UNDEFINED) { printf("%s: My role is undefined\n",moduleName); } if(role==CENTER) { mywait(10000); printf("%s: Current Time: %f - will now ping wheels \n",moduleName ,atronApi_getTime()); pingNeighbors(); } if(role==LEFT) { if(!started) { char centerMsg[] = {ROLESET, CENTER}; atronApi_sendMessage(centerMsg, 2, centerChannel); atronApi_rotateContinuous(1); started = 1; } } if(role==RIGHT) { if(!started) { char centerMsg[] = {ROLESET, CENTER}; atronApi_sendMessage(centerMsg, 2, centerChannel); atronApi_rotateContinuous(-1); started = 1; } } atronApi_yield(); } }
void controller_start() { atronApi_getName(moduleName); printf("%s: Controller started\n", moduleName); mywait(1000); selectRole(); mainControlLoop(); }
static int start_inferior (char *argv[], char *statusptr) { #ifdef SIGTTOU signal (SIGTTOU, SIG_DFL); signal (SIGTTIN, SIG_DFL); #endif signal_pid = create_inferior (argv[0], argv); /* FIXME: we don't actually know at this point that the create actually succeeded. We won't know that until we wait. */ printf_filtered ("Process %s created; pid = %ld\n", argv[0], signal_pid); #ifdef SIGTTOU signal (SIGTTOU, SIG_IGN); signal (SIGTTIN, SIG_IGN); terminal_fd = fileno (stderr); old_foreground_pgrp = tcgetpgrp (terminal_fd); tcsetpgrp (terminal_fd, signal_pid); atexit (restore_old_foreground_pgrp); #endif /* Wait till we are at 1st instruction in program, return signal number (assuming success). */ return mywait (statusptr, 0); }
static int attach_inferior (int pid, char *statusptr, int *sigptr) { /* myattach should return -1 if attaching is unsupported, 0 if it succeeded, and call error() otherwise. */ if (myattach (pid) != 0) return -1; printf_filtered ("Attached; pid = %d\n", pid); /* FIXME - It may be that we should get the SIGNAL_PID from the attach function, so that it can be the main thread instead of whichever we were told to attach to. */ signal_pid = pid; *sigptr = mywait (statusptr, 0); /* GDB knows to ignore the first SIGSTOP after attaching to a running process using the "attach" command, but this is different; it's just using "target remote". Pretend it's just starting up. */ if (*statusptr == 'T' && *sigptr == TARGET_SIGNAL_STOP) *sigptr = TARGET_SIGNAL_TRAP; return 0; }
void myresume (char *own_buf, int step, int *signalp, char *statusp) { struct thread_resume resume_info[2]; int n = 0; int sig = *signalp; set_desired_inferior (0); if (step || sig || (cont_thread != 0 && cont_thread != -1)) { resume_info[0].thread = ((struct inferior_list_entry *) current_inferior)->id; resume_info[0].step = step; resume_info[0].sig = sig; resume_info[0].leave_stopped = 0; n++; } resume_info[n].thread = -1; resume_info[n].step = 0; resume_info[n].sig = 0; resume_info[n].leave_stopped = (cont_thread != 0 && cont_thread != -1); enable_async_io (); (*the_target->resume) (resume_info); *signalp = mywait (statusp, 1); prepare_resume_reply (own_buf, *statusp, *signalp); disable_async_io (); }
main() { char name[64]; int cmd; /* resetVideo();*/ while(1){ pid = get_pid(); printf("==============================================\n"); printf("I am task %d in Umode at segment=%x\n", pid, getcs()); show_menu(); printf("Command ? "); mgets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : get_pid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : mywait(); break; case 6 : myexit(); break; case 7 : ufork(); break; case 8 : myexec("/u2"); break; case 9 : sin(); break; case 10 : sout(); break; default: invalid(name); break; } } }
static unsigned char start_inferior (char *argv[], char *statusptr) { inferior_pid = create_inferior (argv[0], argv); fprintf (stderr, "Process %s created; pid = %d\n", argv[0], inferior_pid); /* Wait till we are at 1st instruction in program, return signal number. */ return mywait (statusptr); }
void ThreadDispatcher::_replyLast(void* val) { _replyingTo = _last._id; _result = val; while (_last.need_reply) { LOGDN("replying to id=%d", _last._id); #ifndef OX_NO_MT //pthread_cond_signal(&_cond); pthread_cond_broadcast(&_cond); #endif mywait(&_cond, &_mutex); } }
void target_stop_and_wait (ptid_t ptid) { struct target_waitstatus status; int was_non_stop = non_stop; struct thread_resume resume_info; resume_info.thread = ptid; resume_info.kind = resume_stop; resume_info.sig = GDB_SIGNAL_0; (*the_target->resume) (&resume_info, 1); non_stop = 1; mywait (ptid, &status, 0, 0); non_stop = was_non_stop; }
void ThreadDispatcher::_waitReply(int id) { do { LOGDN("ThreadMessages::waiting reply... _replyingTo=%d myid=%d", _replyingTo, id); #ifndef OX_NO_MT pthread_cond_signal(&_cond); #endif mywait(&_cond, &_mutex); } while (_replyingTo != id); _last.need_reply = false; #ifndef OX_NO_MT pthread_cond_signal(&_cond); #endif }
static unsigned char start_inferior (char *argv[], char *statusptr) { signal (SIGTTOU, SIG_DFL); signal (SIGTTIN, SIG_DFL); signal_pid = create_inferior (argv[0], argv); fprintf (stderr, "Process %s created; pid = %d\n", argv[0], signal_pid); signal (SIGTTOU, SIG_IGN); signal (SIGTTIN, SIG_IGN); tcsetpgrp (fileno (stderr), signal_pid); /* Wait till we are at 1st instruction in program, return signal number. */ return mywait (statusptr, 0); }
void ThreadMessages::get(message &ev) { MutexPthreadLock lock(_mutex); LOGDN("ThreadMessages::get"); _replyLast(0); while (_events.empty()) { LOGDN("ThreadMessages::get pthread_cond_wait"); mywait(&_cond, &_mutex); } ev = _events.front(); _events.erase(_events.begin()); _last = ev; LOGDN("ThreadMessages::get received msgid=%d id=%d", _last.msgid, _last._id); }
static int attach_inferior (int pid, char *statusptr, unsigned char *sigptr) { /* myattach should return -1 if attaching is unsupported, 0 if it succeeded, and call error() otherwise. */ if (myattach (pid) != 0) return -1; fprintf (stderr, "Attached; pid = %d\n", pid); /* FIXME - It may be that we should get the SIGNAL_PID from the attach function, so that it can be the main thread instead of whichever we were told to attach to. */ signal_pid = pid; *sigptr = mywait (statusptr, 0); return 0; }
void *ThreadMessages::send(int msgid, void *arg1, void *arg2) { message ev; ev.msgid = msgid; ev.arg1 = arg1; ev.arg2 = arg2; MutexPthreadLock lock(_mutex); ev._id = ++_id; _waitReplyID = ev._id; _events.push_back(ev); LOGDN("ThreadMessages::send msgid=%d pthread_cond_signal.. _waitReplyID=%d", msgid, _waitReplyID); pthread_cond_signal(&_cond); if (_last._replied) { LOGDN("ThreadMessages::send msgid=%d already replied", msgid); } while (!_last._replied) { LOGDN("ThreadMessages::send msgid=%d waiting reply...", msgid); mywait(&_cond, &_mutex); } LOGDN("ThreadMessages::send msgid=%d done", msgid); _waitReplyID = 0; _last._replied = false; return _last._result; }
int main (int argc, char *argv[]) { char ch, status, *own_buf, mem_buf[2000]; int i = 0; unsigned char signal; unsigned int len; CORE_ADDR mem_addr; int bad_attach; int pid; char *arg_end; if (setjmp (toplevel)) { fprintf (stderr, "Exiting\n"); exit (1); } bad_attach = 0; pid = 0; attached = 0; if (argc >= 3 && strcmp (argv[2], "--attach") == 0) { if (argc == 4 && argv[3] != '\0' && (pid = strtoul (argv[3], &arg_end, 10)) != 0 && *arg_end == '\0') { ; } else bad_attach = 1; } if (argc < 3 || bad_attach) gdbserver_usage(); initialize_low (); own_buf = malloc (PBUFSIZ); if (pid == 0) { /* Wait till we are at first instruction in program. */ signal = start_inferior (&argv[2], &status); /* We are now stopped at the first instruction of the target process */ } else { switch (attach_inferior (pid, &status, &signal)) { case -1: error ("Attaching not supported on this target"); break; default: attached = 1; break; } } while (1) { remote_open (argv[1]); restart: setjmp (toplevel); while (getpkt (own_buf) > 0) { unsigned char sig; i = 0; ch = own_buf[i++]; switch (ch) { case 'q': handle_query (own_buf); break; case 'd': remote_debug = !remote_debug; break; case 'D': fprintf (stderr, "Detaching from inferior\n"); detach_inferior (); write_ok (own_buf); putpkt (own_buf); remote_close (); /* If we are attached, then we can exit. Otherwise, we need to hang around doing nothing, until the child is gone. */ if (!attached) { int status, ret; do { ret = waitpid (signal_pid, &status, 0); if (WIFEXITED (status) || WIFSIGNALED (status)) break; } while (ret != -1 || errno != ECHILD); } exit (0); case '!': if (attached == 0) { extended_protocol = 1; prepare_resume_reply (own_buf, status, signal); } else { /* We can not use the extended protocol if we are attached, because we can not restart the running program. So return unrecognized. */ own_buf[0] = '\0'; } break; case '?': prepare_resume_reply (own_buf, status, signal); break; case 'H': switch (own_buf[1]) { case 'g': general_thread = strtol (&own_buf[2], NULL, 16); write_ok (own_buf); set_desired_inferior (1); break; case 'c': cont_thread = strtol (&own_buf[2], NULL, 16); write_ok (own_buf); break; case 's': step_thread = strtol (&own_buf[2], NULL, 16); write_ok (own_buf); break; default: /* Silently ignore it so that gdb can extend the protocol without compatibility headaches. */ own_buf[0] = '\0'; break; } break; case 'g': set_desired_inferior (1); registers_to_string (own_buf); break; case 'G': set_desired_inferior (1); registers_from_string (&own_buf[1]); write_ok (own_buf); break; case 'm': decode_m_packet (&own_buf[1], &mem_addr, &len); if (read_inferior_memory (mem_addr, mem_buf, len) == 0) convert_int_to_ascii (mem_buf, own_buf, len); else write_enn (own_buf); break; case 'M': decode_M_packet (&own_buf[1], &mem_addr, &len, mem_buf); if (write_inferior_memory (mem_addr, mem_buf, len) == 0) write_ok (own_buf); else write_enn (own_buf); break; case 'C': convert_ascii_to_int (own_buf + 1, &sig, 1); if (target_signal_to_host_p (sig)) signal = target_signal_to_host (sig); else signal = 0; set_desired_inferior (0); myresume (0, signal); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 'S': convert_ascii_to_int (own_buf + 1, &sig, 1); if (target_signal_to_host_p (sig)) signal = target_signal_to_host (sig); else signal = 0; set_desired_inferior (0); myresume (1, signal); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 'c': set_desired_inferior (0); myresume (0, 0); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 's': set_desired_inferior (0); myresume (1, 0); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 'k': fprintf (stderr, "Killing inferior\n"); kill_inferior (); /* When using the extended protocol, we start up a new debugging session. The traditional protocol will exit instead. */ if (extended_protocol) { write_ok (own_buf); fprintf (stderr, "GDBserver restarting\n"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { exit (0); break; } case 'T': if (mythread_alive (strtol (&own_buf[1], NULL, 16))) write_ok (own_buf); else write_enn (own_buf); break; case 'R': /* Restarting the inferior is only supported in the extended protocol. */ if (extended_protocol) { kill_inferior (); write_ok (own_buf); fprintf (stderr, "GDBserver restarting\n"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { /* It is a request we don't understand. Respond with an empty packet so that gdb knows that we don't support this request. */ own_buf[0] = '\0'; break; } case 'v': /* Extended (long) request. */ handle_v_requests (own_buf, &status, &signal); break; default: /* It is a request we don't understand. Respond with an empty packet so that gdb knows that we don't support this request. */ own_buf[0] = '\0'; break; } putpkt (own_buf); if (status == 'W') fprintf (stderr, "\nChild exited with status %d\n", signal); if (status == 'X') fprintf (stderr, "\nChild terminated with signal = 0x%x\n", signal); if (status == 'W' || status == 'X') { if (extended_protocol) { fprintf (stderr, "Killing inferior\n"); kill_inferior (); write_ok (own_buf); fprintf (stderr, "GDBserver restarting\n"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { fprintf (stderr, "GDBserver exiting\n"); exit (0); } } } /* We come here when getpkt fails. For the extended remote protocol we exit (and this is the only way we gracefully exit!). For the traditional remote protocol close the connection, and re-open it at the top of the loop. */ if (extended_protocol) { remote_close (); exit (0); } else { fprintf (stderr, "Remote side has terminated connection. " "GDBserver will reopen the connection.\n"); remote_close (); } } }
/* Parse vCont packets. */ void handle_v_cont (char *own_buf, char *status, unsigned char *signal) { char *p, *q; int n = 0, i = 0; struct thread_resume *resume_info, default_action; /* Count the number of semicolons in the packet. There should be one for every action. */ p = &own_buf[5]; while (p) { n++; p++; p = strchr (p, ';'); } /* Allocate room for one extra action, for the default remain-stopped behavior; if no default action is in the list, we'll need the extra slot. */ resume_info = malloc ((n + 1) * sizeof (resume_info[0])); default_action.thread = -1; default_action.leave_stopped = 1; default_action.step = 0; default_action.sig = 0; p = &own_buf[5]; i = 0; while (*p) { p++; resume_info[i].leave_stopped = 0; if (p[0] == 's' || p[0] == 'S') resume_info[i].step = 1; else if (p[0] == 'c' || p[0] == 'C') resume_info[i].step = 0; else goto err; if (p[0] == 'S' || p[0] == 'C') { int sig; sig = strtol (p + 1, &q, 16); if (p == q) goto err; p = q; if (!target_signal_to_host_p (sig)) goto err; resume_info[i].sig = target_signal_to_host (sig); } else { resume_info[i].sig = 0; p = p + 1; } if (p[0] == 0) { resume_info[i].thread = -1; default_action = resume_info[i]; /* Note: we don't increment i here, we'll overwrite this entry the next time through. */ } else if (p[0] == ':') { resume_info[i].thread = strtol (p + 1, &q, 16); if (p == q) goto err; p = q; if (p[0] != ';' && p[0] != 0) goto err; i++; } } resume_info[i] = default_action; /* Still used in occasional places in the backend. */ if (n == 1 && resume_info[0].thread != -1) cont_thread = resume_info[0].thread; else cont_thread = -1; set_desired_inferior (0); (*the_target->resume) (resume_info); free (resume_info); *signal = mywait (status, 1); prepare_resume_reply (own_buf, *status, *signal); return; err: /* No other way to report an error... */ strcpy (own_buf, ""); free (resume_info); return; }
/* usage: testlatency numprocs spawnfn iters P/B */ int main(int argc, char **argv) { uint64_t networkpid; int64_t begin, end, total; int polling = 1; int k; int iters = 0; TEST_STARTUP(argc, argv, networkpid, eb, ep, 1, 2, "iters (Poll/Block)"); /* setup handlers */ AM_Safe(AM_SetHandler(ep, PING_REQ_HANDLER, ping_request_handler)); AM_Safe(AM_SetHandler(ep, PING_REP_HANDLER, ping_reply_handler)); setupUtilHandlers(ep, eb); /* get SPMD info */ myproc = AMX_SPMDMyProc(); numprocs = AMX_SPMDNumProcs(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 1; if (argc > 2) { switch(argv[2][0]) { case 'p': case 'P': polling = 1; break; case 'b': case 'B': polling = 0; break; default: printf("polling must be 'P' or 'B'..\n"); AMX_SPMDExit(1); } } outputTimerStats(); AM_Safe(AMX_SPMDBarrier()); if (myproc == 0) printf("Running %i iterations of latency test...\n", iters); if (myproc == 0 && numprocs > 1) numleft = (numprocs-1)*iters; AM_Safe(AMX_SPMDBarrier()); begin = getCurrentTimeMicrosec(); if (myproc == 0 && numprocs > 1) { mywait(polling); } else { /* everybody sends packets to 0 */ int expect = (numprocs > 1 ? 1 : 2); for (k=0;k < iters; k++) { numleft = expect; #if VERBOSE printf("%i: sending request...", myproc); fflush(stdout); #endif AM_Safe(AM_Request0(ep, 0, PING_REQ_HANDLER)); mywait(polling); } } end = getCurrentTimeMicrosec(); total = end - begin; if (myproc != 0 || numprocs == 1) printf("Slave %i: %i microseconds total, throughput: %i requests/sec (%.3f us / request)\n", myproc, (int)total, (int)(((float)1000000)*iters/((int)total)), ((double)total)/iters); else printf("Slave 0 done.\n"); fflush(stdout); /* dump stats */ AM_Safe(AMX_SPMDBarrier()); printGlobalStats(); AM_Safe(AMX_SPMDBarrier()); /* exit */ AM_Safe(AMX_SPMDExit(0)); return 0; }
int agent_run_command (int pid, const char *cmd, int len) { int fd; int tid = agent_get_helper_thread_id (); ptid_t ptid = ptid_build (pid, tid, 0); #ifdef GDBSERVER int ret = write_inferior_memory (ipa_sym_addrs.addr_cmd_buf, (const unsigned char *) cmd, len); #else int ret = target_write_memory (ipa_sym_addrs.addr_cmd_buf, cmd, len); #endif if (ret != 0) { warning (_("unable to write")); return -1; } DEBUG_AGENT ("agent: resumed helper thread\n"); /* Resume helper thread. */ #ifdef GDBSERVER { struct thread_resume resume_info; resume_info.thread = ptid; resume_info.kind = resume_continue; resume_info.sig = GDB_SIGNAL_0; (*the_target->resume) (&resume_info, 1); } #else target_resume (ptid, 0, GDB_SIGNAL_0); #endif fd = gdb_connect_sync_socket (pid); if (fd >= 0) { char buf[1] = ""; int ret; DEBUG_AGENT ("agent: signalling helper thread\n"); do { ret = write (fd, buf, 1); } while (ret == -1 && errno == EINTR); DEBUG_AGENT ("agent: waiting for helper thread's response\n"); do { ret = read (fd, buf, 1); } while (ret == -1 && errno == EINTR); close (fd); DEBUG_AGENT ("agent: helper thread's response received\n"); } else return -1; /* Need to read response with the inferior stopped. */ if (!ptid_equal (ptid, null_ptid)) { struct target_waitstatus status; int was_non_stop = non_stop; /* Stop thread PTID. */ DEBUG_AGENT ("agent: stop helper thread\n"); #ifdef GDBSERVER { struct thread_resume resume_info; resume_info.thread = ptid; resume_info.kind = resume_stop; resume_info.sig = GDB_SIGNAL_0; (*the_target->resume) (&resume_info, 1); } non_stop = 1; mywait (ptid, &status, 0, 0); #else non_stop = 1; target_stop (ptid); memset (&status, 0, sizeof (status)); target_wait (ptid, &status, 0); #endif non_stop = was_non_stop; } if (fd >= 0) { #ifdef GDBSERVER if (read_inferior_memory (ipa_sym_addrs.addr_cmd_buf, (unsigned char *) cmd, IPA_CMD_BUF_SIZE)) #else if (target_read_memory (ipa_sym_addrs.addr_cmd_buf, (gdb_byte *) cmd, IPA_CMD_BUF_SIZE)) #endif { warning (_("Error reading command response")); return -1; } } return 0; }
void main(int argc, char *argv[]) { char ofile[100], incfile[20], *p; int nout, nproc, status, i, c, of; thechar = '7'; /* of 9 */ thestring = "alpha"; memset(debug, 0, sizeof(debug)); cinit(); outfile = 0; include[ninclude++] = "."; ARGBEGIN { default: c = ARGC(); if(c >= 0 || c < sizeof(debug)) debug[c] = 1; break; case 'o': outfile = ARGF(); break; case 'D': p = ARGF(); if(p) Dlist[nDlist++] = p; break; case 'I': p = ARGF(); if(p) include[ninclude++] = p; break; } ARGEND if(*argv == 0) { print("usage: %ca [-options] file.s\n", thechar); errorexit(); } nproc = 3; if(p = getenv("NPROC")) nproc = atol(p); if(argc > 1) { c = 0; nout = 0; for(;;) { while(nout < nproc && argc > 0) { i = fork(); if(i < 0) { i = mywait(&status); if(i < 0) errorexit(); if(status) c++; nout--; continue; } if(i == 0) { print("%s:\n", *argv); goto child; } nout++; argc--; argv++; } i = mywait(&status); if(i < 0) { if(c) errorexit(); exits(0); } if(status) c++; nout--; } } child: strecpy(ofile, ofile+sizeof ofile, *argv); if(p = strrchr(ofile, '/')) { include[0] = ofile; *p++ = 0; } else p = ofile; if(outfile == 0) { outfile = p; if(p = strrchr(outfile, '.')) if(p[1] == 's' && p[2] == 0) p[0] = 0; p = strrchr(outfile, 0); p[0] = '.'; p[1] = thechar; p[2] = 0; } if(0) { strcpy(incfile, "/usr/%include"); p = strrchr(incfile, '%'); if(p) *p = thechar; } else { strcpy(incfile, "/"); strcat(incfile, thestring); strcat(incfile, "/include"); } include[ninclude++] = incfile; if(p = getenv("INCLUDE")) include[ninclude-1] = p; /* */ of = mycreat(outfile, 0664); if(of < 0) { yyerror("%ca: cannot create %s", thechar, outfile); errorexit(); } Binit(&obuf, of, OWRITE); pass = 1; pinit(*argv); for(i=0; i<nDlist; i++) dodefine(Dlist[i]); yyparse(); if(nerrors) { cclean(); errorexit(); } pass = 2; outhist(); pinit(*argv); for(i=0; i<nDlist; i++) dodefine(Dlist[i]); yyparse(); cclean(); if(nerrors) errorexit(); exits(0); }
int main (int argc, char *argv[]) { char ch, status, *own_buf; unsigned char *mem_buf; int i = 0; int signal; unsigned int len; CORE_ADDR mem_addr; int bad_attach; int pid; char *arg_end; if (argc >= 2 && strcmp (argv[1], "--version") == 0) { gdbserver_version (); exit (0); } if (argc >= 2 && strcmp (argv[1], "--help") == 0) { gdbserver_usage (); exit (0); } if (setjmp (toplevel)) { fprintf (stderr, "Exiting\n"); exit (1); } bad_attach = 0; pid = 0; attached = 0; if (argc >= 3 && strcmp (argv[2], "--attach") == 0) { if (argc == 4 && argv[3] != '\0' && (pid = strtoul (argv[3], &arg_end, 10)) != 0 && *arg_end == '\0') { ; } else bad_attach = 1; } if (argc < 3 || bad_attach) { gdbserver_usage (); exit (1); } initialize_low (); own_buf = malloc (PBUFSIZ); mem_buf = malloc (PBUFSIZ); if (pid == 0) { /* Wait till we are at first instruction in program. */ signal = start_inferior (&argv[2], &status); /* start_inferior() returns an integer, but the wait * function returns an unsigned char. in the case of * of an error, the wait returns -1 which means 255. */ if (status == 'W' || status == 'X') { fprintf (stderr, "Aborting server; child exited with %i\n", signal); exit (signal); } /* We are now stopped at the first instruction of the target process */ } else { switch (attach_inferior (pid, &status, &signal)) { case -1: error ("Attaching not supported on this target"); break; default: attached = 1; break; } } while (1) { remote_open (argv[1]); restart: setjmp (toplevel); while (1) { unsigned char sig; int packet_len; int new_packet_len = -1; packet_len = getpkt (own_buf); if (packet_len <= 0) break; i = 0; ch = own_buf[i++]; switch (ch) { case 'q': handle_query (own_buf, &new_packet_len); break; case 'd': remote_debug = !remote_debug; break; #ifndef USE_WIN32API /* Skip "detach" support on mingw32, since we don't have waitpid. */ case 'D': fprintf (stderr, "Detaching from inferior\n"); detach_inferior (); write_ok (own_buf); putpkt (own_buf); remote_close (); /* If we are attached, then we can exit. Otherwise, we need to hang around doing nothing, until the child is gone. */ if (!attached) { int status, ret; do { ret = waitpid (signal_pid, &status, 0); if (WIFEXITED (status) || WIFSIGNALED (status)) break; } while (ret != -1 || errno != ECHILD); } exit (0); #endif case '!': if (attached == 0) { extended_protocol = 1; prepare_resume_reply (own_buf, status, signal); } else { /* We can not use the extended protocol if we are attached, because we can not restart the running program. So return unrecognized. */ own_buf[0] = '\0'; } break; case '?': prepare_resume_reply (own_buf, status, signal); break; case 'H': if (own_buf[1] == 'c' || own_buf[1] == 'g' || own_buf[1] == 's') { unsigned long gdb_id, thread_id; gdb_id = strtoul (&own_buf[2], NULL, 16); thread_id = gdb_id_to_thread_id (gdb_id); if (thread_id == 0) { write_enn (own_buf); break; } if (own_buf[1] == 'g') { general_thread = thread_id; set_desired_inferior (1); } else if (own_buf[1] == 'c') cont_thread = thread_id; else if (own_buf[1] == 's') step_thread = thread_id; write_ok (own_buf); } else { /* Silently ignore it so that gdb can extend the protocol without compatibility headaches. */ own_buf[0] = '\0'; } break; case 'g': set_desired_inferior (1); registers_to_string (own_buf); break; case 'G': set_desired_inferior (1); registers_from_string (&own_buf[1]); write_ok (own_buf); break; case 'm': decode_m_packet (&own_buf[1], &mem_addr, &len); if (read_inferior_memory (mem_addr, mem_buf, len) == 0) convert_int_to_ascii (mem_buf, own_buf, len); else write_enn (own_buf); break; case 'M': decode_M_packet (&own_buf[1], &mem_addr, &len, mem_buf); if (write_inferior_memory (mem_addr, mem_buf, len) == 0) write_ok (own_buf); else write_enn (own_buf); break; case 'X': if (decode_X_packet (&own_buf[1], packet_len - 1, &mem_addr, &len, mem_buf) < 0 || write_inferior_memory (mem_addr, mem_buf, len) != 0) write_enn (own_buf); else write_ok (own_buf); break; case 'C': convert_ascii_to_int (own_buf + 1, &sig, 1); if (target_signal_to_host_p (sig)) signal = target_signal_to_host (sig); else signal = 0; set_desired_inferior (0); myresume (0, signal); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 'S': convert_ascii_to_int (own_buf + 1, &sig, 1); if (target_signal_to_host_p (sig)) signal = target_signal_to_host (sig); else signal = 0; set_desired_inferior (0); myresume (1, signal); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 'c': set_desired_inferior (0); myresume (0, 0); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 's': set_desired_inferior (0); myresume (1, 0); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 'Z': { char *lenptr; char *dataptr; CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16); int len = strtol (lenptr + 1, &dataptr, 16); char type = own_buf[1]; if (the_target->insert_watchpoint == NULL || (type < '2' || type > '4')) { /* No watchpoint support or not a watchpoint command; unrecognized either way. */ own_buf[0] = '\0'; } else { int res; res = (*the_target->insert_watchpoint) (type, addr, len); if (res == 0) write_ok (own_buf); else if (res == 1) /* Unsupported. */ own_buf[0] = '\0'; else write_enn (own_buf); } break; } case 'z': { char *lenptr; char *dataptr; CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16); int len = strtol (lenptr + 1, &dataptr, 16); char type = own_buf[1]; if (the_target->remove_watchpoint == NULL || (type < '2' || type > '4')) { /* No watchpoint support or not a watchpoint command; unrecognized either way. */ own_buf[0] = '\0'; } else { int res; res = (*the_target->remove_watchpoint) (type, addr, len); if (res == 0) write_ok (own_buf); else if (res == 1) /* Unsupported. */ own_buf[0] = '\0'; else write_enn (own_buf); } break; } case 'k': fprintf (stderr, "Killing inferior\n"); kill_inferior (); /* When using the extended protocol, we start up a new debugging session. The traditional protocol will exit instead. */ if (extended_protocol) { write_ok (own_buf); fprintf (stderr, "GDBserver restarting\n"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { exit (0); break; } case 'T': { unsigned long gdb_id, thread_id; gdb_id = strtoul (&own_buf[1], NULL, 16); thread_id = gdb_id_to_thread_id (gdb_id); if (thread_id == 0) { write_enn (own_buf); break; } if (mythread_alive (thread_id)) write_ok (own_buf); else write_enn (own_buf); } break; case 'R': /* Restarting the inferior is only supported in the extended protocol. */ if (extended_protocol) { kill_inferior (); write_ok (own_buf); fprintf (stderr, "GDBserver restarting\n"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { /* It is a request we don't understand. Respond with an empty packet so that gdb knows that we don't support this request. */ own_buf[0] = '\0'; break; } case 'v': /* Extended (long) request. */ handle_v_requests (own_buf, &status, &signal); break; default: /* It is a request we don't understand. Respond with an empty packet so that gdb knows that we don't support this request. */ own_buf[0] = '\0'; break; } if (new_packet_len != -1) putpkt_binary (own_buf, new_packet_len); else putpkt (own_buf); if (status == 'W') fprintf (stderr, "\nChild exited with status %d\n", signal); if (status == 'X') fprintf (stderr, "\nChild terminated with signal = 0x%x (%s)\n", target_signal_to_host (signal), target_signal_to_name (signal)); if (status == 'W' || status == 'X') { if (extended_protocol) { fprintf (stderr, "Killing inferior\n"); kill_inferior (); write_ok (own_buf); fprintf (stderr, "GDBserver restarting\n"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { fprintf (stderr, "GDBserver exiting\n"); exit (0); } } } /* We come here when getpkt fails. For the extended remote protocol we exit (and this is the only way we gracefully exit!). For the traditional remote protocol close the connection, and re-open it at the top of the loop. */ if (extended_protocol) { remote_close (); exit (0); } else { fprintf (stderr, "Remote side has terminated connection. " "GDBserver will reopen the connection.\n"); remote_close (); } } }
int main (int argc, char *argv[]) { char ch, status, own_buf[PBUFSIZ], mem_buf[2000]; int i = 0; unsigned char signal; unsigned int len; CORE_ADDR mem_addr; if (setjmp (toplevel)) { fprintf (stderr, "Exiting\n"); exit (1); } if (argc < 3) error ("Usage: gdbserver tty prog [args ...]"); initialize_low (); /* Wait till we are at first instruction in program. */ signal = start_inferior (&argv[2], &status); /* We are now stopped at the first instruction of the target process */ while (1) { remote_open (argv[1]); restart: setjmp (toplevel); while (getpkt (own_buf) > 0) { unsigned char sig; i = 0; ch = own_buf[i++]; switch (ch) { case 'd': remote_debug = !remote_debug; break; case '!': extended_protocol = 1; prepare_resume_reply (own_buf, status, signal); break; case '?': prepare_resume_reply (own_buf, status, signal); break; case 'H': switch (own_buf[1]) { case 'g': general_thread = strtol (&own_buf[2], NULL, 16); write_ok (own_buf); fetch_inferior_registers (0); break; case 'c': cont_thread = strtol (&own_buf[2], NULL, 16); write_ok (own_buf); break; default: /* Silently ignore it so that gdb can extend the protocol without compatibility headaches. */ own_buf[0] = '\0'; break; } break; case 'g': convert_int_to_ascii (registers, own_buf, REGISTER_BYTES); break; case 'G': convert_ascii_to_int (&own_buf[1], registers, REGISTER_BYTES); store_inferior_registers (-1); write_ok (own_buf); break; case 'm': decode_m_packet (&own_buf[1], &mem_addr, &len); read_inferior_memory (mem_addr, mem_buf, len); convert_int_to_ascii (mem_buf, own_buf, len); break; case 'M': decode_M_packet (&own_buf[1], &mem_addr, &len, mem_buf); if (write_inferior_memory (mem_addr, mem_buf, len) == 0) write_ok (own_buf); else write_enn (own_buf); break; case 'C': convert_ascii_to_int (own_buf + 1, &sig, 1); myresume (0, sig); signal = mywait (&status); prepare_resume_reply (own_buf, status, signal); break; case 'S': convert_ascii_to_int (own_buf + 1, &sig, 1); myresume (1, sig); signal = mywait (&status); prepare_resume_reply (own_buf, status, signal); break; case 'c': myresume (0, 0); signal = mywait (&status); prepare_resume_reply (own_buf, status, signal); break; case 's': myresume (1, 0); signal = mywait (&status); prepare_resume_reply (own_buf, status, signal); break; case 'k': fprintf (stderr, "Killing inferior\n"); kill_inferior (); /* When using the extended protocol, we start up a new debugging session. The traditional protocol will exit instead. */ if (extended_protocol) { write_ok (own_buf); fprintf (stderr, "GDBserver restarting\n"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { exit (0); break; } case 'T': if (mythread_alive (strtol (&own_buf[1], NULL, 16))) write_ok (own_buf); else write_enn (own_buf); break; case 'R': /* Restarting the inferior is only supported in the extended protocol. */ if (extended_protocol) { kill_inferior (); write_ok (own_buf); fprintf (stderr, "GDBserver restarting\n"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { /* It is a request we don't understand. Respond with an empty packet so that gdb knows that we don't support this request. */ own_buf[0] = '\0'; break; } default: /* It is a request we don't understand. Respond with an empty packet so that gdb knows that we don't support this request. */ own_buf[0] = '\0'; break; } putpkt (own_buf); if (status == 'W') fprintf (stderr, "\nChild exited with status %d\n", sig); if (status == 'X') fprintf (stderr, "\nChild terminated with signal = 0x%x\n", sig); if (status == 'W' || status == 'X') { if (extended_protocol) { fprintf (stderr, "Killing inferior\n"); kill_inferior (); write_ok (own_buf); fprintf (stderr, "GDBserver restarting\n"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { fprintf (stderr, "GDBserver exiting\n"); exit (0); } } } /* We come here when getpkt fails. For the extended remote protocol we exit (and this is the only way we gracefully exit!). For the traditional remote protocol close the connection, and re-open it at the top of the loop. */ if (extended_protocol) { remote_close (); exit (0); } else { fprintf (stderr, "Remote side has terminated connection. GDBserver will reopen the connection.\n"); remote_close (); } } }
void main(int argc, char *argv[]) { char *p; int nout, nproc, status, i, c; thechar = '2'; thestring = "68020"; memset(debug, 0, sizeof(debug)); cinit(); outfile = 0; include[ninclude++] = "."; ARGBEGIN { default: c = ARGC(); if(c >= 0 || c < sizeof(debug)) debug[c] = 1; break; case 'o': outfile = ARGF(); break; case 'D': p = ARGF(); if(p) Dlist[nDlist++] = p; break; case 'I': p = ARGF(); setinclude(p); break; } ARGEND if(*argv == 0) { print("usage: %ca [-options] file.s\n", thechar); errorexit(); } if(argc > 1 && systemtype(Windows)){ print("can't assemble multiple files on windows\n"); errorexit(); } if(argc > 1 && !systemtype(Windows)) { nproc = 1; if(p = getenv("NPROC")) nproc = atol(p); /* */ c = 0; nout = 0; for(;;) { while(nout < nproc && argc > 0) { i = myfork(); if(i < 0) { i = mywait(&status); if(i < 0) errorexit(); if(status) c++; nout--; continue; } if(i == 0) { print("%s:\n", *argv); if(assemble(*argv)) errorexit(); exits(0); } nout++; argc--; argv++; } i = mywait(&status); if(i < 0) { if(c) errorexit(); exits(0); } if(status) c++; nout--; } } if(assemble(argv[0])) errorexit(); exits(0); }
static int start_inferior (char **argv, char *statusptr) { char **new_argv = argv; attached = 0; if (wrapper_argv != NULL) { int i, count = 1; for (i = 0; wrapper_argv[i] != NULL; i++) count++; for (i = 0; argv[i] != NULL; i++) count++; new_argv = alloca (sizeof (char *) * count); count = 0; for (i = 0; wrapper_argv[i] != NULL; i++) new_argv[count++] = wrapper_argv[i]; for (i = 0; argv[i] != NULL; i++) new_argv[count++] = argv[i]; new_argv[count] = NULL; } #ifdef SIGTTOU signal (SIGTTOU, SIG_DFL); signal (SIGTTIN, SIG_DFL); #endif signal_pid = create_inferior (new_argv[0], new_argv); /* FIXME: we don't actually know at this point that the create actually succeeded. We won't know that until we wait. */ fprintf (stderr, "Process %s created; pid = %ld\n", argv[0], signal_pid); fflush (stderr); #ifdef SIGTTOU signal (SIGTTOU, SIG_IGN); signal (SIGTTIN, SIG_IGN); terminal_fd = fileno (stderr); old_foreground_pgrp = tcgetpgrp (terminal_fd); tcsetpgrp (terminal_fd, signal_pid); atexit (restore_old_foreground_pgrp); #endif if (wrapper_argv != NULL) { struct thread_resume resume_info; int sig; resume_info.thread = -1; resume_info.step = 0; resume_info.sig = 0; resume_info.leave_stopped = 0; sig = mywait (statusptr, 0); if (*statusptr != 'T') return sig; do { (*the_target->resume) (&resume_info); sig = mywait (statusptr, 0); if (*statusptr != 'T') return sig; } while (sig != TARGET_SIGNAL_TRAP); return sig; } /* Wait till we are at 1st instruction in program, return signal number (assuming success). */ return mywait (statusptr, 0); }
int main (int argc, char *argv[]) { char ch, status, *own_buf; unsigned char *mem_buf; int i = 0; int signal; unsigned int len; CORE_ADDR mem_addr; int bad_attach; int pid; char *arg_end; my_stdout = stdout; my_stderr = stderr; myname = argv[0]; if (argc >= 2 && strcmp (argv[1], "--version") == 0) { gdbserver_version (); exit (0); } if (argc >= 2 && strcmp (argv[1], "--help") == 0) { gdbserver_usage (); exit (0); } if (setjmp (toplevel)) { warning ("Exiting"); exit (1); } bad_attach = 0; pid = 0; attached = 0; if (argc >= 3 && strcmp (argv[2], "--attach") == 0) { if (argc == 4 && argv[3][0] != '\0' && (pid = strtoul (argv[3], &arg_end, 10)) != 0 && *arg_end == '\0') { ; } else bad_attach = 1; } if (argc < 3 || bad_attach) { gdbserver_usage (); exit (1); } if (strcmp (argv[1], "pipe") == 0) { my_stdout = my_stderr = stderr; } initialize_low (); own_buf = malloc (PBUFSIZ + 1); mem_buf = malloc (PBUFSIZ); if (pid == 0) { /* Wait till we are at first instruction in program. */ signal = start_inferior (&argv[2], &status); /* We are now (hopefully) stopped at the first instruction of the target process. This assumes that the target process was successfully created. */ /* Don't report shared library events on the initial connection, even if some libraries are preloaded. */ dlls_changed = 0; } else { switch (attach_inferior (pid, &status, &signal)) { case -1: error ("Attaching not supported on this target"); break; default: attached = 1; break; } } if (setjmp (toplevel)) { warning ("Killing inferior"); kill_inferior (); exit (1); } if (status == 'W' || status == 'X') { warning ("No inferior, GDBserver exiting."); exit (1); } while (1) { remote_open (argv[1]); restart: if (setjmp (toplevel)) { if (remote_debug) printf_filtered ("gdbserver: error returned to main loop\n"); write_enn (own_buf); putpkt (own_buf); } while (1) { unsigned char sig; int packet_len; int new_packet_len = -1; packet_len = getpkt (own_buf, PBUFSIZ); if (packet_len <= 0) break; i = 0; ch = own_buf[i++]; switch (ch) { case 'q': handle_query (own_buf, packet_len, &new_packet_len); break; case 'Q': handle_general_set (own_buf); break; case 'D': warning ("Detaching from inferior"); if (detach_inferior () != 0) { write_enn (own_buf); putpkt (own_buf); } else { write_ok (own_buf); putpkt (own_buf); remote_close (); /* If we are attached, then we can exit. Otherwise, we need to hang around doing nothing, until the child is gone. */ if (!attached) join_inferior (); exit (0); } case '!': if (attached == 0) { extended_protocol = 1; prepare_resume_reply (own_buf, status, signal); } else { /* We can not use the extended protocol if we are attached, because we can not restart the running program. So return unrecognized. */ own_buf[0] = '\0'; } break; case '?': prepare_resume_reply (own_buf, status, signal); break; case 'H': if (own_buf[1] == 'c' || own_buf[1] == 'g' || own_buf[1] == 's') { unsigned long gdb_id, thread_id; gdb_id = strtoul (&own_buf[2], NULL, 16); thread_id = gdb_id_to_thread_id (gdb_id); if (thread_id == 0) { write_enn (own_buf); break; } if (own_buf[1] == 'g') { general_thread = thread_id; set_desired_inferior (1); } else if (own_buf[1] == 'c') cont_thread = thread_id; else if (own_buf[1] == 's') step_thread = thread_id; write_ok (own_buf); } else { /* Silently ignore it so that gdb can extend the protocol without compatibility headaches. */ own_buf[0] = '\0'; } break; case 'g': set_desired_inferior (1); registers_to_string (own_buf); break; case 'G': set_desired_inferior (1); registers_from_string (&own_buf[1]); write_ok (own_buf); break; case 'm': decode_m_packet (&own_buf[1], &mem_addr, &len); if (read_inferior_memory (mem_addr, mem_buf, len) == 0) convert_int_to_ascii (mem_buf, own_buf, len); else write_enn (own_buf); break; case 'M': decode_M_packet (&own_buf[1], &mem_addr, &len, mem_buf); if (write_inferior_memory (mem_addr, mem_buf, len) == 0) write_ok (own_buf); else write_enn (own_buf); break; case 'X': if (decode_X_packet (&own_buf[1], packet_len - 1, &mem_addr, &len, mem_buf) < 0 || write_inferior_memory (mem_addr, mem_buf, len) != 0) write_enn (own_buf); else write_ok (own_buf); break; case 'C': convert_ascii_to_int (own_buf + 1, &sig, 1); if (target_signal_to_host_p (sig)) signal = target_signal_to_host (sig); else signal = 0; set_desired_inferior (0); myresume (0, signal); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 'S': convert_ascii_to_int (own_buf + 1, &sig, 1); if (target_signal_to_host_p (sig)) signal = target_signal_to_host (sig); else signal = 0; set_desired_inferior (0); myresume (1, signal); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 'c': set_desired_inferior (0); myresume (0, 0); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 's': set_desired_inferior (0); myresume (1, 0); signal = mywait (&status, 1); prepare_resume_reply (own_buf, status, signal); break; case 'z': case 'Z': { char *lenptr; char *dataptr; CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16); int len = strtol (lenptr + 1, &dataptr, 16); char type = own_buf[1]; if (the_target->insert_watchpoint == NULL || the_target->remove_watchpoint == NULL || (type < '0' || type > '4')) { /* No watchpoint support or not a watchpoint command; unrecognized either way. */ own_buf[0] = '\0'; } else { int res; if (ch == 'z') res = (*the_target->remove_watchpoint) (type, addr, len); else res = (*the_target->insert_watchpoint) (type, addr, len); if (res == 0) write_ok (own_buf); else if (res == 1) /* Unsupported. */ own_buf[0] = '\0'; else write_enn (own_buf); } break; } case 'k': warning ("Killing inferior"); kill_inferior (); /* When using the extended protocol, we start up a new debugging session. The traditional protocol will exit instead. */ if (extended_protocol) { write_ok (own_buf); warning ("GDBserver restarting"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { exit (0); break; } case 'T': { unsigned long gdb_id, thread_id; gdb_id = strtoul (&own_buf[1], NULL, 16); thread_id = gdb_id_to_thread_id (gdb_id); if (thread_id == 0) { write_enn (own_buf); break; } if (mythread_alive (thread_id)) write_ok (own_buf); else write_enn (own_buf); } break; case 'R': /* Restarting the inferior is only supported in the extended protocol. */ if (extended_protocol) { kill_inferior (); write_ok (own_buf); warning ("GDBserver restarting"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { /* It is a request we don't understand. Respond with an empty packet so that gdb knows that we don't support this request. */ own_buf[0] = '\0'; break; } case 'v': /* Extended (long) request. */ handle_v_requests (own_buf, &status, &signal); break; default: /* It is a request we don't understand. Respond with an empty packet so that gdb knows that we don't support this request. */ own_buf[0] = '\0'; break; } if (new_packet_len != -1) putpkt_binary (own_buf, new_packet_len); else putpkt (own_buf); if (status == 'W') warning ("\nChild exited with status %d", signal); if (status == 'X') warning ("\nChild terminated with signal = 0x%x (%s)", target_signal_to_host (signal), target_signal_to_name (signal)); if (status == 'W' || status == 'X') { if (extended_protocol) { warning ("Killing inferior"); kill_inferior (); write_ok (own_buf); warning ("GDBserver restarting"); /* Wait till we are at 1st instruction in prog. */ signal = start_inferior (&argv[2], &status); goto restart; break; } else { warning ("GDBserver exiting"); exit (0); } } } /* We come here when getpkt fails. For the extended remote protocol we exit (and this is the only way we gracefully exit!). For the traditional remote protocol close the connection, and re-open it at the top of the loop. */ if (extended_protocol) { remote_close (); exit (0); } else { warning ("Remote side has terminated connection. " "GDBserver will reopen the connection."); remote_close (); } } }