2 # This is a shell archive.
3 # Run the file through sh to extract its contents.
5 # Run the following text with /bin/sh to create:
11 # This archive created: Fri Jun 23 17:06:55 1989
12 cat << \SHAR_EOF > Remote_Makefile
13 # Makefile for the remote server for GDB, the GNU debugger.
14 # Copyright (C) 1986, 1989 Free Software Foundation, Inc.
16 # This file is part of GDB.
18 # GDB is free software; you can redistribute it and/or modify
19 # it under the terms of the GNU General Public License as published by
20 # the Free Software Foundation; either version 1, or (at your option)
23 # GDB is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 # GNU General Public License for more details.
28 # You should have received a copy of the GNU General Public License
29 # along with GDB; see the file COPYING. If not, write to
30 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
35 SERVER = remote_server.o\
41 $(CC) -g -o serve $(SERVER)
43 cat << \SHAR_EOF > remote_gutils.c
44 /* General utility routines for the remote server for GDB, the GNU debugger.
45 Copyright (C) 1986, 1989 Free Software Foundation, Inc.
47 This file is part of GDB.
49 GDB is free software; you can redistribute it and/or modify
50 it under the terms of the GNU General Public License as published by
51 the Free Software Foundation; either version 1, or (at your option)
54 GDB is distributed in the hope that it will be useful,
55 but WITHOUT ANY WARRANTY; without even the implied warranty of
56 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 GNU General Public License for more details.
59 You should have received a copy of the GNU General Public License
60 along with GDB; see the file COPYING. If not, write to
61 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
64 #include <sys/ioctl.h>
70 /* Chain of cleanup actions established with make_cleanup,
71 to be executed if an error happens. */
73 static struct cleanup *cleanup_chain;
75 /* Nonzero means a quit has been requested. */
79 /* Nonzero means quit immediately if Control-C is typed now,
80 rather than waiting until QUIT is executed. */
84 /* Add a new cleanup to the cleanup_chain,
85 and return the previous chain pointer
86 to be passed later to do_cleanups or discard_cleanups.
87 Args are FUNCTION to clean up with, and ARG to pass to it. */
90 make_cleanup (function, arg)
94 register struct cleanup *new
95 = (struct cleanup *) xmalloc (sizeof (struct cleanup));
96 register struct cleanup *old_chain = cleanup_chain;
98 new->next = cleanup_chain;
99 new->function = function;
106 /* Discard cleanups and do the actions they describe
107 until we get back to the point OLD_CHAIN in the cleanup_chain. */
110 do_cleanups (old_chain)
111 register struct cleanup *old_chain;
113 register struct cleanup *ptr;
114 while ((ptr = cleanup_chain) != old_chain)
116 (*ptr->function) (ptr->arg);
117 cleanup_chain = ptr->next;
122 /* Discard cleanups, not doing the actions they describe,
123 until we get back to the point OLD_CHAIN in the cleanup_chain. */
126 discard_cleanups (old_chain)
127 register struct cleanup *old_chain;
129 register struct cleanup *ptr;
130 while ((ptr = cleanup_chain) != old_chain)
132 cleanup_chain = ptr->next;
137 /* This function is useful for cleanups.
141 old_chain = make_cleanup (free_current_contents, &foo);
143 to arrange to free the object thus allocated. */
146 free_current_contents (location)
152 /* Generally useful subroutines used throughout the program. */
154 /* Like malloc but get error if no storage available. */
160 register char *val = (char *) malloc (size);
162 fatal ("virtual memory exhausted.", 0);
166 /* Like realloc but get error if no storage available. */
173 register char *val = (char *) realloc (ptr, size);
175 fatal ("virtual memory exhausted.", 0);
179 /* Print the system error message for errno, and also mention STRING
180 as the file name for which the error was encountered.
181 Then return to command level. */
184 perror_with_name (string)
188 extern char *sys_errlist[];
193 if (errno < sys_nerr)
194 err = sys_errlist[errno];
196 err = "unknown error";
198 combined = (char *) alloca (strlen (err) + strlen (string) + 3);
199 strcpy (combined, string);
200 strcat (combined, ": ");
201 strcat (combined, err);
203 error ("%s.", combined);
206 /* Print the system error message for ERRCODE, and also mention STRING
207 as the file name for which the error was encountered. */
210 print_sys_errmsg (string, errcode)
215 extern char *sys_errlist[];
219 if (errcode < sys_nerr)
220 err = sys_errlist[errcode];
222 err = "unknown error";
224 combined = (char *) alloca (strlen (err) + strlen (string) + 3);
225 strcpy (combined, string);
226 strcat (combined, ": ");
227 strcat (combined, err);
229 printf ("%s.\n", combined);
236 ioctl (fileno (stdout), TIOCFLUSH, 0);
240 /* Control C comes here */
250 /* Print an error message and return to command level.
251 STRING is the error message, used as a fprintf string,
252 and ARG is passed as an argument to it. */
255 error (string, arg1, arg2, arg3)
257 int arg1, arg2, arg3;
260 fprintf (stderr, string, arg1, arg2, arg3);
261 fprintf (stderr, "\n");
262 /************return_to_top_level ();************/
265 /* Print an error message and exit reporting failure.
266 This is for a error that we cannot continue from.
267 STRING and ARG are passed to fprintf. */
274 fprintf (stderr, "gdb: ");
275 fprintf (stderr, string, arg);
276 fprintf (stderr, "\n");
280 /* Make a copy of the string at PTR with SIZE characters
281 (and add a null character at the end in the copy).
282 Uses malloc to get the space. Returns the address of the copy. */
285 savestring (ptr, size)
289 register char *p = (char *) xmalloc (size + 1);
290 bcopy (ptr, p, size);
299 register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1;
300 register char *val = (char *) xmalloc (len);
308 print_spaces (n, file)
316 /* Ask user a y-or-n question and return 1 iff answer is yes.
317 Takes three args which are given to printf to print the question.
318 The first, a control string, should end in "? ".
319 It should not say how to answer, because we do that. */
322 query (ctlstr, arg1, arg2)
327 /* Automatically answer "yes" if input is not from a terminal. */
328 /***********if (!input_from_terminal_p ())
329 return 1; *************************/
333 printf (ctlstr, arg1, arg2);
334 printf ("(y or n) ");
336 answer = fgetc (stdin);
337 clearerr (stdin); /* in case of C-d */
339 while (fgetc (stdin) != '\n') clearerr (stdin);
346 printf ("Please answer y or n.\n");
350 /* Parse a C escape sequence. STRING_PTR points to a variable
351 containing a pointer to the string to parse. That pointer
352 is updated past the characters we use. The value of the
353 escape sequence is returned.
355 A negative value means the sequence \ newline was seen,
356 which is supposed to be equivalent to nothing at all.
358 If \ is followed by a null character, we return a negative
359 value and leave the string pointer pointing at the null character.
361 If \ is followed by 000, we return 0 and leave the string pointer
362 after the zeros. A value of 0 does not mean end of string. */
365 parse_escape (string_ptr)
368 register int c = *(*string_ptr)++;
393 c = *(*string_ptr)++;
395 c = parse_escape (string_ptr);
398 return (c & 0200) | (c & 037);
409 register int i = c - '0';
410 register int count = 0;
413 if ((c = *(*string_ptr)++) >= '0' && c <= '7')
432 printchar (ch, stream)
437 if (c < 040 || c >= 0177)
440 fprintf (stream, "\\n");
442 fprintf (stream, "\\b");
444 fprintf (stream, "\\t");
446 fprintf (stream, "\\f");
448 fprintf (stream, "\\r");
450 fprintf (stream, "\\e");
452 fprintf (stream, "\\a");
454 fprintf (stream, "\\%03o", c);
458 if (c == '\\' || c == '"' || c == '\'')
459 fputc ('\\', stream);
464 cat << \SHAR_EOF > remote_inflow.c
465 /* Low level interface to ptrace, for GDB when running under Unix.
466 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
473 #include "inferior.h"
474 /***************************
475 #include "initialize.h"
476 ****************************/
479 #include <sys/param.h>
481 #include <sys/user.h>
483 #include <sys/ioctl.h>
487 /***************Begin MY defs*********************/
489 char registers[REGISTER_BYTES];
491 /* Index within `registers' of the first byte of the space for
495 char buf2[MAX_REGISTER_RAW_SIZE];
496 /***************End MY defs*********************/
498 #ifdef NEW_SUN_PTRACE
499 #include <sys/ptrace.h>
500 #include <machine/reg.h>
503 extern char **environ;
505 extern int inferior_pid;
506 void error(), quit(), perror_with_name();
508 void supply_register(), write_register();
509 CORE_ADDR read_register();
511 /* Nonzero if we are debugging an attached outside process
512 rather than an inferior. */
515 /* Start an inferior process and returns its pid.
516 ALLARGS is a vector of program-name and args.
517 ENV is the environment vector to pass. */
520 create_inferior (allargs, env)
526 extern char *sys_errlist[];
529 /* exec is said to fail if the executable is open. */
530 /****************close_exec_file ();*****************/
534 perror_with_name ("vfork");
538 /* Run inferior in a separate process group. */
539 setpgrp (getpid (), getpid ());
541 /* Not needed on Sun, at least, and loses there
542 because it clobbers the superior. */
543 /*??? signal (SIGQUIT, SIG_DFL);
544 signal (SIGINT, SIG_DFL); */
549 execle ("/bin/sh", "sh", "-c", allargs, 0, env);
551 fprintf (stderr, "Cannot exec /bin/sh: %s.\n",
552 errno < sys_nerr ? sys_errlist[errno] : "unknown error");
559 /* Kill the inferior process. Make us have no inferior. */
563 if (inferior_pid == 0)
565 ptrace (8, inferior_pid, 0, 0);
567 /*************inferior_died ();****VK**************/
570 /* Resume execution of the inferior process.
571 If STEP is nonzero, single-step it.
572 If SIGNAL is nonzero, give it that signal. */
575 resume (step, signal,status)
584 ptrace (step ? 9 : 7, inferior_pid, 1, signal);
586 perror_with_name ("ptrace");
588 if(pid != inferior_pid)
589 perror_with_name ("wait");
593 printf("\nchild exited with retcode = %x \n",WRETCODE(w));
595 return((unsigned char) WRETCODE(w));
597 else if(!WIFSTOPPED(w))
599 printf("\nchild did terminated with signal = %x \n",WTERMSIG(w));
601 return((unsigned char) WTERMSIG(w));
605 printf("\nchild stopped with signal = %x \n",WSTOPSIG(w));
607 return((unsigned char) WSTOPSIG(w));
613 #ifdef NEW_SUN_PTRACE
616 fetch_inferior_registers ()
618 struct regs inferior_registers;
619 struct fp_status inferior_fp_registers;
620 extern char registers[];
622 ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers);
624 perror_with_name ("ptrace");
625 /**********debugging begin **********/
626 print_some_registers(&inferior_registers);
627 /**********debugging end **********/
628 ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers);
630 perror_with_name ("ptrace");
632 bcopy (&inferior_registers, registers, 16 * 4);
633 bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)],
634 sizeof inferior_fp_registers.fps_regs);
635 *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
636 *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
637 bcopy (&inferior_fp_registers.fps_control,
638 ®isters[REGISTER_BYTE (FPC_REGNUM)],
639 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
642 /* Store our register values back into the inferior.
643 If REGNO is -1, do this for all registers.
644 Otherwise, REGNO specifies which register (so we can save time). */
646 store_inferior_registers (regno)
649 struct regs inferior_registers;
650 struct fp_status inferior_fp_registers;
651 extern char registers[];
653 bcopy (registers, &inferior_registers, 16 * 4);
654 bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
655 sizeof inferior_fp_registers.fps_regs);
656 inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)];
657 inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)];
658 bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)],
659 &inferior_fp_registers.fps_control,
660 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
662 ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers);
664 perror_with_name ("ptrace");
665 ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers);
667 perror_with_name ("ptrace");
670 #endif /* not NEW_SUN_PTRACE */
673 /* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
674 in the NEW_SUN_PTRACE case.
675 It ought to be straightforward. But it appears that writing did
676 not write the data that I specified. I cannot understand where
677 it got the data that it actually did write. */
679 /* Copy LEN bytes from inferior's memory starting at MEMADDR
680 to debugger memory starting at MYADDR. */
682 read_inferior_memory (memaddr, myaddr, len)
688 /* Round starting address down to longword boundary. */
689 register CORE_ADDR addr = memaddr & - sizeof (int);
690 /* Round ending address up; get number of longwords that makes. */
692 = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
693 /* Allocate buffer of that many longwords. */
694 register int *buffer = (int *) alloca (count * sizeof (int));
696 /* Read all the longwords */
697 for (i = 0; i < count; i++, addr += sizeof (int))
699 buffer[i] = ptrace (1, inferior_pid, addr, 0);
702 /* Copy appropriate bytes out of the buffer. */
703 bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
706 /* Copy LEN bytes of data from debugger memory at MYADDR
707 to inferior's memory at MEMADDR.
708 On failure (cannot write the inferior)
709 returns the value of errno. */
712 write_inferior_memory (memaddr, myaddr, len)
718 /* Round starting address down to longword boundary. */
719 register CORE_ADDR addr = memaddr & - sizeof (int);
720 /* Round ending address up; get number of longwords that makes. */
722 = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
723 /* Allocate buffer of that many longwords. */
724 register int *buffer = (int *) alloca (count * sizeof (int));
727 /* Fill start and end extra bytes of buffer with existing memory data. */
729 buffer[0] = ptrace (1, inferior_pid, addr, 0);
734 = ptrace (1, inferior_pid,
735 addr + (count - 1) * sizeof (int), 0);
738 /* Copy data to be written over corresponding part of buffer */
740 bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
742 /* Write the entire buffer. */
744 for (i = 0; i < count; i++, addr += sizeof (int))
747 ptrace (4, inferior_pid, addr, buffer[i]);
756 try_writing_regs_command ()
762 if (inferior_pid == 0)
763 error ("There is no inferior process now.");
765 fetch_inferior_registers();
766 for (i = 0;i<18 ; i ++)
770 value = read_register(i);
771 write_register ( i, value);
774 printf (" Succeeded with register %d; value 0x%x (%d).\n",
778 printf (" Failed with register %d.\n", i);
792 /* Return the contents of register REGNO,
793 regarding it as an integer. */
796 read_register (regno)
799 /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */
800 return *(int *) ®isters[REGISTER_BYTE (regno)];
803 /* Store VALUE in the register number REGNO, regarded as an integer. */
806 write_register (regno, val)
809 /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */
810 *(int *) ®isters[REGISTER_BYTE (regno)] = val;
812 if (have_inferior_p ())
813 store_inferior_registers (regno);
820 return inferior_pid != 0;
823 print_some_registers(regs)
827 for (i = 0; i < 18; i++) {
828 printf("reg[%d] = %x\n", i, regs[i]);
833 cat << \SHAR_EOF > remote_server.c
834 /* Main code for remote server for GDB, the GNU Debugger.
835 Copyright (C) 1989 Free Software Foundation, Inc.
837 This file is part of GDB.
839 GDB is free software; you can redistribute it and/or modify
840 it under the terms of the GNU General Public License as published by
841 the Free Software Foundation; either version 1, or (at your option)
844 GDB is distributed in the hope that it will be useful,
845 but WITHOUT ANY WARRANTY; without even the implied warranty of
846 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
847 GNU General Public License for more details.
849 You should have received a copy of the GNU General Public License
850 along with GDB; see the file COPYING. If not, write to
851 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
856 void read_inferior_memory(), fetch_inferior_registers();
857 unsigned char resume();
858 void kill_inferior();
859 void initialize(), try_writing_regs_command();
860 int create_inferior(), read_register();
862 extern char registers[];
864 extern char **environ;
866 /* Descriptor for I/O to remote machine. */
869 int remote_debugging;
877 void convert_ascii_to_int();
878 void convert_int_to_ascii();
879 void prepare_resume_reply();
880 void decode_m_packet();
881 void decode_M_packet();
885 int argc; char *argv[];
887 char ch,status, own_buf[2000], mem_buf[2000];
889 unsigned char signal;
890 unsigned int mem_addr, len;
893 printf("\nwill open serial link\n");
894 remote_open("/dev/ttya",0);
898 printf("Enter name of program to be run with command line args\n");
900 inferior_pid = create_inferior(own_buf,environ);
901 printf("\nProcess %s created; pid = %d\n",own_buf,inferior_pid);
905 inferior_pid = create_inferior(argv[1],environ);
906 printf("\nProcess %s created; pid = %d\n",argv[1],inferior_pid);
911 printf("\nPacket received is>:%s\n",own_buf);
915 case 'h': /**********This is only for tweaking the gdb+ program *******/
916 signal = resume(1,0,&status);
917 prepare_resume_reply(own_buf,status,signal);
919 /*************end tweak*************************************/
921 case 'g': fetch_inferior_registers();
922 convert_int_to_ascii(registers,own_buf,REGISTER_BYTES);
924 case 'G': convert_ascii_to_int(&own_buf[1],registers,REGISTER_BYTES);
925 if(store_inferior_registers(-1)==0)
930 case 'm': decode_m_packet(&own_buf[1],&mem_addr,&len);
931 read_inferior_memory(mem_addr,mem_buf,len);
932 convert_int_to_ascii(mem_buf,own_buf,len);
934 case 'M': decode_M_packet(&own_buf[1],&mem_addr,&len,mem_buf);
935 if(write_inferior_memory(mem_addr,mem_buf,len)==0)
940 case 'c': signal = resume(0,0,&status);
941 printf("\nSignal received is >: %0x \n",signal);
942 prepare_resume_reply(own_buf,status,signal);
944 case 's': signal = resume(1,0,&status);
945 prepare_resume_reply(own_buf,status,signal);
947 case 'k': kill_inferior();
948 sprintf(own_buf,"q");
950 printf("\nObtained kill request...terminating\n");
953 case 't': try_writing_regs_command();
956 default : printf("\nUnknown option chosen by master\n");
965 /** now get out of here**/
966 printf("\nFinished reading data from serial link - Bye!\n");
972 cat << \SHAR_EOF > remote_utils.c
973 /* Remote utility routines for the remote server for GDB, the GNU debugger.
974 Copyright (C) 1986, 1989 Free Software Foundation, Inc.
976 This file is part of GDB.
978 GDB is free software; you can redistribute it and/or modify
979 it under the terms of the GNU General Public License as published by
980 the Free Software Foundation; either version 1, or (at your option)
983 GDB is distributed in the hope that it will be useful,
984 but WITHOUT ANY WARRANTY; without even the implied warranty of
985 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
986 GNU General Public License for more details.
988 You should have received a copy of the GNU General Public License
989 along with GDB; see the file COPYING. If not, write to
990 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
995 #include <sys/wait.h>
996 #include <sys/ioctl.h>
998 #include <sys/file.h>
1001 extern int remote_desc;
1002 extern int remote_debugging;
1003 extern int kiodebug;
1012 void convert_ascii_to_int();
1013 void convert_int_to_ascii();
1014 void prepare_resume_reply();
1016 /* Open a connection to a remote debugger.
1017 NAME is the filename used for communication. */
1020 remote_open (name, from_tty)
1026 remote_debugging = 0;
1028 remote_desc = open (name, O_RDWR);
1029 if (remote_desc < 0)
1030 printf("\ncould not open remote device\n");
1032 ioctl (remote_desc, TIOCGETP, &sg);
1034 ioctl (remote_desc, TIOCSETP, &sg);
1037 printf ("Remote debugging using %s\n", name);
1038 remote_debugging = 1;
1041 /* Convert hex digit A to a number. */
1047 if (a >= '0' && a <= '9')
1049 else if (a >= 'a' && a <= 'f')
1050 return a - 'a' + 10;
1052 perror ("Reply contains invalid hex digit");
1055 /* Convert number NIB to a hex digit. */
1067 /* Send the command in BUF to the remote machine,
1068 and read the reply into BUF.
1069 Report an error if we get an error reply. */
1079 perror ("Remote failure reply: %s", buf);
1082 /* Send a packet to the remote machine, with error checking.
1083 The data of the packet is in BUF. */
1090 unsigned char csum = 0;
1093 int cnt = strlen (buf);
1097 fprintf (stderr, "Sending packet: %s\n", buf);
1099 /* Copy the packet into buffer BUF2, encapsulating it
1100 and giving it a checksum. */
1105 for (i = 0; i < cnt; i++)
1111 *p++ = tohex ((csum >> 4) & 0xf);
1112 *p++ = tohex (csum & 0xf);
1114 /* Send it over and over until we get a positive ack. */
1117 write (remote_desc, buf2, p - buf2);
1118 read (remote_desc, buf3, 1);
1119 } while (buf3[0] != '+');
1126 while (read (remote_desc, buf, 1) != 1) ;
1127 return buf[0] & 0x7f;
1130 /* Read a packet from the remote machine, with error checking,
1131 and store it in BUF. */
1138 unsigned char csum, c, c1, c2;
1144 while ((c = readchar()) != '$');
1157 c1 = fromhex (readchar ());
1158 c2 = fromhex (readchar ());
1159 if (csum == (c1 << 4) + c2)
1162 printf ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n",
1163 (c1 << 4) + c2, csum, buf);
1164 write (remote_desc, "-", 1);
1167 write (remote_desc, "+", 1);
1170 fprintf (stderr,"Packet received :%s\n", buf);
1194 convert_int_to_ascii(from,to,n)
1195 char *from, *to; int n;
1202 nib = ((ch & 0xf0) >> 4)& 0x0f;
1212 convert_ascii_to_int(from,to,n)
1213 char *from, *to; int n;
1218 nib1 = fromhex(*from++);
1219 nib2 = fromhex(*from++);
1220 *to++ = (((nib1 & 0x0f)<< 4)& 0xf0) | (nib2 & 0x0f);
1225 prepare_resume_reply(buf,status,signal)
1227 unsigned char signal;
1234 nib = ((signal & 0xf0) >> 4) ;
1235 *buf++ = tohex(nib);
1236 nib = signal & 0x0f;
1237 *buf++ = tohex(nib);
1242 decode_m_packet(from,mem_addr_ptr,len_ptr)
1244 unsigned int *mem_addr_ptr, *len_ptr;
1248 *mem_addr_ptr = *len_ptr = 0;
1249 /************debugging begin************/
1250 printf("\nIn decode_m_packet");
1251 /************debugging end************/
1253 while((ch = from[i++]) != ',')
1255 *mem_addr_ptr = *mem_addr_ptr << 4;
1256 *mem_addr_ptr |= fromhex(ch) & 0x0f;
1258 /************debugging begin************/
1259 printf("\nFinished mem_addr part");
1260 /************debugging end************/
1262 for(j=0; j < 4; j++)
1264 if((ch = from[i++]) == 0)
1266 *len_ptr = *len_ptr << 4;
1267 *len_ptr |= fromhex(ch) & 0x0f;
1269 /************debugging begin************/
1270 printf("\nFinished len_ptr part");
1271 /************debugging end************/
1275 decode_M_packet(from,mem_addr_ptr,len_ptr,to)
1277 unsigned int *mem_addr_ptr, *len_ptr;
1281 *mem_addr_ptr = *len_ptr = 0;
1282 /************debugging begin************/
1283 printf("\nIn decode_M_packet");
1284 /************debugging end************/
1286 while((ch = from[i++]) != ',')
1288 *mem_addr_ptr = *mem_addr_ptr << 4;
1289 *mem_addr_ptr |= fromhex(ch) & 0x0f;
1291 /************debugging begin************/
1292 printf("\nFinished mem_addr part: memaddr = %x",*mem_addr_ptr);
1293 /************debugging end************/
1295 while((ch = from[i++]) != ':')
1297 *len_ptr = *len_ptr << 4;
1298 *len_ptr |= fromhex(ch) & 0x0f;
1300 /************debugging begin************/
1301 printf("\nFinished len_ptr part: len = %d",*len_ptr);
1302 /************debugging end************/
1304 convert_ascii_to_int(&from[i++],to,*len_ptr);
1306 /************debugging begin************/
1307 printf("\nmembuf : %x",*(int *)to);
1308 /************debugging end************/
1312 # End of shell archive