aboutsummaryrefslogtreecommitdiff
path: root/sim/arm/main.c
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2000-02-05 07:30:26 +0000
committerJason Molenda <jmolenda@apple.com>2000-02-05 07:30:26 +0000
commitdfcd3bfb6f8a213007c20e60060b4e9ec9205205 (patch)
treec43f1f196f08266345d283414914033ecc50bd5e /sim/arm/main.c
parent32edc927faea39b1f7be4654f6ffa03f3e6b16ce (diff)
downloadgdb-dfcd3bfb6f8a213007c20e60060b4e9ec9205205.zip
gdb-dfcd3bfb6f8a213007c20e60060b4e9ec9205205.tar.gz
gdb-dfcd3bfb6f8a213007c20e60060b4e9ec9205205.tar.bz2
import gdb-2000-02-04 snapshot
Diffstat (limited to 'sim/arm/main.c')
-rw-r--r--sim/arm/main.c169
1 files changed, 90 insertions, 79 deletions
diff --git a/sim/arm/main.c b/sim/arm/main.c
index f012b28..c799290 100644
--- a/sim/arm/main.c
+++ b/sim/arm/main.c
@@ -37,22 +37,22 @@
/* Read and write routines down sockets and pipes */
-void MYread_chars(int sock, void *p, int n);
-unsigned char MYread_char(int sock);
-ARMword MYread_word(int sock);
-void MYread_FPword(int sock, char *putinhere);
+void MYread_chars (int sock, void *p, int n);
+unsigned char MYread_char (int sock);
+ARMword MYread_word (int sock);
+void MYread_FPword (int sock, char *putinhere);
-void MYwrite_word(int sock, ARMword i);
-void MYwrite_string(int sock, char *s);
-void MYwrite_FPword(int sock, char *fromhere);
-void MYwrite_char(int sock, unsigned char c);
+void MYwrite_word (int sock, ARMword i);
+void MYwrite_string (int sock, char *s);
+void MYwrite_FPword (int sock, char *fromhere);
+void MYwrite_char (int sock, unsigned char c);
-void passon(int source, int dest, int n);
+void passon (int source, int dest, int n);
/* Mother and child processes */
void parent (void);
-void kid(void);
+void kid (void);
/* The child process id. */
pid_t child;
@@ -86,98 +86,109 @@ unsigned int socketnumber;
/* Opens a socket to the debugger, and once opened spawns the */
/* ARMulator and sets up a couple of pipes. */
/**************************************************************/
-int main(int argc, char *argv[]) {
+int
+main (int argc, char *argv[])
+{
int i;
struct sockaddr_in devil, isa;
struct hostent *hp;
- if (argc == 1) {
- fprintf(stderr, "No socket number\n");
- return 1;
- }
+ if (argc == 1)
+ {
+ fprintf (stderr, "No socket number\n");
+ return 1;
+ }
- sscanf(argv[1], "%d", &socketnumber);
- if (!socketnumber || socketnumber > 0xffff) {
- fprintf(stderr, "Invalid socket number: %d\n", socketnumber);
- return 1;
- }
+ sscanf (argv[1], "%d", &socketnumber);
+ if (!socketnumber || socketnumber > 0xffff)
+ {
+ fprintf (stderr, "Invalid socket number: %d\n", socketnumber);
+ return 1;
+ }
- gethostname(localhost, MAXHOSTNAMELENGTH);
- hp = gethostbyname(localhost);
- if (!hp) {
- fprintf(stderr, "Cannot get local host info\n");
- return 1;
- }
+ gethostname (localhost, MAXHOSTNAMELENGTH);
+ hp = gethostbyname (localhost);
+ if (!hp)
+ {
+ fprintf (stderr, "Cannot get local host info\n");
+ return 1;
+ }
/* Open a socket */
- sockethandle = socket(hp->h_addrtype, SOCK_STREAM, 0);
- if (sockethandle < 0) {
- perror("socket");
- return 1;
- }
+ sockethandle = socket (hp->h_addrtype, SOCK_STREAM, 0);
+ if (sockethandle < 0)
+ {
+ perror ("socket");
+ return 1;
+ }
devil.sin_family = hp->h_addrtype;
- devil.sin_port = htons(socketnumber);
+ devil.sin_port = htons (socketnumber);
devil.sin_addr.s_addr = 0;
- for(i = 0; i < sizeof(devil.sin_zero); i++) devil.sin_zero[i] = '\000';
- memcpy(&devil.sin_addr, hp->h_addr_list[0], hp->h_length);
+ for (i = 0; i < sizeof (devil.sin_zero); i++)
+ devil.sin_zero[i] = '\000';
+ memcpy (&devil.sin_addr, hp->h_addr_list[0], hp->h_length);
- if (bind(sockethandle, &devil, sizeof(devil)) < 0) {
- perror("bind");
- return 1;
- }
+ if (bind (sockethandle, &devil, sizeof (devil)) < 0)
+ {
+ perror ("bind");
+ return 1;
+ }
/* May only accept one debugger at once */
- if (listen(sockethandle, 0)) {
- perror("listen");
- return 1;
- }
-
- fprintf(stderr, "Waiting for connection from debugger...");
-
- debugsock = accept(sockethandle, &isa, &i);
- if (debugsock < 0) {
- perror("accept");
- return 1;
- }
-
- fprintf(stderr, " done.\nConnection Established.\n");
-
- nfds = getdtablesize();
-
- if (pipe(mumkid)) {
- perror("pipe");
- return 1;
- }
- if (pipe(kidmum)) {
- perror("pipe");
- return 1;
- }
-
- if (pipe(DebuggerARMul)) {
- perror("pipe");
- return 1;
- }
-
+ if (listen (sockethandle, 0))
+ {
+ perror ("listen");
+ return 1;
+ }
+
+ fprintf (stderr, "Waiting for connection from debugger...");
+
+ debugsock = accept (sockethandle, &isa, &i);
+ if (debugsock < 0)
+ {
+ perror ("accept");
+ return 1;
+ }
+
+ fprintf (stderr, " done.\nConnection Established.\n");
+
+ nfds = getdtablesize ();
+
+ if (pipe (mumkid))
+ {
+ perror ("pipe");
+ return 1;
+ }
+ if (pipe (kidmum))
+ {
+ perror ("pipe");
+ return 1;
+ }
+
+ if (pipe (DebuggerARMul))
+ {
+ perror ("pipe");
+ return 1;
+ }
+
#ifdef DEBUG
- fprintf(stderr, "Created pipes ok\n");
+ fprintf (stderr, "Created pipes ok\n");
#endif
- child = fork();
+ child = fork ();
#ifdef DEBUG
- fprintf(stderr, "fork() ok\n");
+ fprintf (stderr, "fork() ok\n");
#endif
- if (child == 0) kid ();
- if (child != -1) parent ();
+ if (child == 0)
+ kid ();
+ if (child != -1)
+ parent ();
- perror("fork");
+ perror ("fork");
return 1;
}
-
-
-
-