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 # This program 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 2 of the License, or
21 # (at your option) any later version.
23 # This program 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 this program; if not, write to the Free Software
30 # Foundation, Inc., 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 This program 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 2 of the License, or
52 (at your option) any later version.
54 This program 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 this program; if not, write to the Free Software
61 Foundation, Inc., 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);
296 print_spaces (n, file)
304 /* Ask user a y-or-n question and return 1 iff answer is yes.
305 Takes three args which are given to printf to print the question.
306 The first, a control string, should end in "? ".
307 It should not say how to answer, because we do that. */
310 query (ctlstr, arg1, arg2)
315 /* Automatically answer "yes" if input is not from a terminal. */
316 /***********if (!input_from_terminal_p ())
317 return 1; *************************/
321 printf (ctlstr, arg1, arg2);
322 printf ("(y or n) ");
324 answer = fgetc (stdin);
325 clearerr (stdin); /* in case of C-d */
327 while (fgetc (stdin) != '\n') clearerr (stdin);
334 printf ("Please answer y or n.\n");
338 /* Parse a C escape sequence. STRING_PTR points to a variable
339 containing a pointer to the string to parse. That pointer
340 is updated past the characters we use. The value of the
341 escape sequence is returned.
343 A negative value means the sequence \ newline was seen,
344 which is supposed to be equivalent to nothing at all.
346 If \ is followed by a null character, we return a negative
347 value and leave the string pointer pointing at the null character.
349 If \ is followed by 000, we return 0 and leave the string pointer
350 after the zeros. A value of 0 does not mean end of string. */
353 parse_escape (string_ptr)
356 register int c = *(*string_ptr)++;
381 c = *(*string_ptr)++;
383 c = parse_escape (string_ptr);
386 return (c & 0200) | (c & 037);
397 register int i = c - '0';
398 register int count = 0;
401 if ((c = *(*string_ptr)++) >= '0' && c <= '7')
420 printchar (ch, stream)
425 if (c < 040 || c >= 0177)
428 fprintf (stream, "\\n");
430 fprintf (stream, "\\b");
432 fprintf (stream, "\\t");
434 fprintf (stream, "\\f");
436 fprintf (stream, "\\r");
438 fprintf (stream, "\\e");
440 fprintf (stream, "\\a");
442 fprintf (stream, "\\%03o", c);
446 if (c == '\\' || c == '"' || c == '\'')
447 fputc ('\\', stream);
452 cat << \SHAR_EOF > remote_inflow.c
453 /* Low level interface to ptrace, for GDB when running under Unix.
454 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
461 #include "inferior.h"
462 /***************************
463 #include "initialize.h"
464 ****************************/
467 #include <sys/param.h>
469 #include <sys/user.h>
471 #include <sys/ioctl.h>
475 /***************Begin MY defs*********************/
477 char registers[REGISTER_BYTES];
479 /* Index within `registers' of the first byte of the space for
483 char buf2[MAX_REGISTER_RAW_SIZE];
484 /***************End MY defs*********************/
486 #ifdef NEW_SUN_PTRACE
487 #include <sys/ptrace.h>
488 #include <machine/reg.h>
491 extern char **environ;
493 extern int inferior_pid;
494 void error(), quit(), perror_with_name();
496 void supply_register(), write_register();
497 CORE_ADDR read_register();
499 /* Nonzero if we are debugging an attached outside process
500 rather than an inferior. */
503 /* Start an inferior process and returns its pid.
504 ALLARGS is a vector of program-name and args.
505 ENV is the environment vector to pass. */
508 create_inferior (allargs, env)
514 extern char *sys_errlist[];
517 /* exec is said to fail if the executable is open. */
518 /****************close_exec_file ();*****************/
522 perror_with_name ("vfork");
526 /* Run inferior in a separate process group. */
527 setpgrp (getpid (), getpid ());
529 /* Not needed on Sun, at least, and loses there
530 because it clobbers the superior. */
531 /*??? signal (SIGQUIT, SIG_DFL);
532 signal (SIGINT, SIG_DFL); */
537 execle ("/bin/sh", "sh", "-c", allargs, 0, env);
539 fprintf (stderr, "Cannot exec /bin/sh: %s.\n",
540 errno < sys_nerr ? sys_errlist[errno] : "unknown error");
547 /* Kill the inferior process. Make us have no inferior. */
551 if (inferior_pid == 0)
553 ptrace (8, inferior_pid, 0, 0);
555 /*************inferior_died ();****VK**************/
558 /* Resume execution of the inferior process.
559 If STEP is nonzero, single-step it.
560 If SIGNAL is nonzero, give it that signal. */
563 resume (step, signal,status)
572 ptrace (step ? 9 : 7, inferior_pid, 1, signal);
574 perror_with_name ("ptrace");
576 if(pid != inferior_pid)
577 perror_with_name ("wait");
581 printf("\nchild exited with retcode = %x \n",WRETCODE(w));
583 return((unsigned char) WRETCODE(w));
585 else if(!WIFSTOPPED(w))
587 printf("\nchild did terminated with signal = %x \n",WTERMSIG(w));
589 return((unsigned char) WTERMSIG(w));
593 printf("\nchild stopped with signal = %x \n",WSTOPSIG(w));
595 return((unsigned char) WSTOPSIG(w));
601 #ifdef NEW_SUN_PTRACE
604 fetch_inferior_registers ()
606 struct regs inferior_registers;
607 struct fp_status inferior_fp_registers;
608 extern char registers[];
610 ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers);
612 perror_with_name ("ptrace");
613 /**********debugging begin **********/
614 print_some_registers(&inferior_registers);
615 /**********debugging end **********/
616 ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers);
618 perror_with_name ("ptrace");
620 bcopy (&inferior_registers, registers, 16 * 4);
621 bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)],
622 sizeof inferior_fp_registers.fps_regs);
623 *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
624 *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
625 bcopy (&inferior_fp_registers.fps_control,
626 ®isters[REGISTER_BYTE (FPC_REGNUM)],
627 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
630 /* Store our register values back into the inferior.
631 If REGNO is -1, do this for all registers.
632 Otherwise, REGNO specifies which register (so we can save time). */
634 store_inferior_registers (regno)
637 struct regs inferior_registers;
638 struct fp_status inferior_fp_registers;
639 extern char registers[];
641 bcopy (registers, &inferior_registers, 16 * 4);
642 bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
643 sizeof inferior_fp_registers.fps_regs);
644 inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)];
645 inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)];
646 bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)],
647 &inferior_fp_registers.fps_control,
648 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
650 ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers);
652 perror_with_name ("ptrace");
653 ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers);
655 perror_with_name ("ptrace");
658 #endif /* not NEW_SUN_PTRACE */
661 /* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
662 in the NEW_SUN_PTRACE case.
663 It ought to be straightforward. But it appears that writing did
664 not write the data that I specified. I cannot understand where
665 it got the data that it actually did write. */
667 /* Copy LEN bytes from inferior's memory starting at MEMADDR
668 to debugger memory starting at MYADDR. */
670 read_inferior_memory (memaddr, myaddr, len)
676 /* Round starting address down to longword boundary. */
677 register CORE_ADDR addr = memaddr & - sizeof (int);
678 /* Round ending address up; get number of longwords that makes. */
680 = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
681 /* Allocate buffer of that many longwords. */
682 register int *buffer = (int *) alloca (count * sizeof (int));
684 /* Read all the longwords */
685 for (i = 0; i < count; i++, addr += sizeof (int))
687 buffer[i] = ptrace (1, inferior_pid, addr, 0);
690 /* Copy appropriate bytes out of the buffer. */
691 bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
694 /* Copy LEN bytes of data from debugger memory at MYADDR
695 to inferior's memory at MEMADDR.
696 On failure (cannot write the inferior)
697 returns the value of errno. */
700 write_inferior_memory (memaddr, myaddr, len)
706 /* Round starting address down to longword boundary. */
707 register CORE_ADDR addr = memaddr & - sizeof (int);
708 /* Round ending address up; get number of longwords that makes. */
710 = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
711 /* Allocate buffer of that many longwords. */
712 register int *buffer = (int *) alloca (count * sizeof (int));
715 /* Fill start and end extra bytes of buffer with existing memory data. */
717 buffer[0] = ptrace (1, inferior_pid, addr, 0);
722 = ptrace (1, inferior_pid,
723 addr + (count - 1) * sizeof (int), 0);
726 /* Copy data to be written over corresponding part of buffer */
728 bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
730 /* Write the entire buffer. */
732 for (i = 0; i < count; i++, addr += sizeof (int))
735 ptrace (4, inferior_pid, addr, buffer[i]);
744 try_writing_regs_command ()
750 if (inferior_pid == 0)
751 error ("There is no inferior process now.");
753 fetch_inferior_registers();
754 for (i = 0;i<18 ; i ++)
758 value = read_register(i);
759 write_register ( i, value);
762 printf (" Succeeded with register %d; value 0x%x (%d).\n",
766 printf (" Failed with register %d.\n", i);
780 /* Return the contents of register REGNO,
781 regarding it as an integer. */
784 read_register (regno)
787 /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */
788 return *(int *) ®isters[REGISTER_BYTE (regno)];
791 /* Store VALUE in the register number REGNO, regarded as an integer. */
794 write_register (regno, val)
797 /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */
798 *(int *) ®isters[REGISTER_BYTE (regno)] = val;
800 if (have_inferior_p ())
801 store_inferior_registers (regno);
808 return inferior_pid != 0;
811 print_some_registers(regs)
815 for (i = 0; i < 18; i++) {
816 printf("reg[%d] = %x\n", i, regs[i]);
821 cat << \SHAR_EOF > remote_server.c
822 /* Main code for remote server for GDB, the GNU Debugger.
823 Copyright (C) 1989 Free Software Foundation, Inc.
825 This file is part of GDB.
827 This program is free software; you can redistribute it and/or modify
828 it under the terms of the GNU General Public License as published by
829 the Free Software Foundation; either version 2 of the License, or
830 (at your option) any later version.
832 This program is distributed in the hope that it will be useful,
833 but WITHOUT ANY WARRANTY; without even the implied warranty of
834 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
835 GNU General Public License for more details.
837 You should have received a copy of the GNU General Public License
838 along with this program; if not, write to the Free Software
839 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
844 void read_inferior_memory(), fetch_inferior_registers();
845 unsigned char resume();
846 void kill_inferior();
847 void initialize(), try_writing_regs_command();
848 int create_inferior(), read_register();
850 extern char registers[];
852 extern char **environ;
854 /* Descriptor for I/O to remote machine. */
857 int remote_debugging;
865 void convert_ascii_to_int();
866 void convert_int_to_ascii();
867 void prepare_resume_reply();
868 void decode_m_packet();
869 void decode_M_packet();
873 int argc; char *argv[];
875 char ch,status, own_buf[2000], mem_buf[2000];
877 unsigned char signal;
878 unsigned int mem_addr, len;
881 printf("\nwill open serial link\n");
882 remote_open("/dev/ttya",0);
886 printf("Enter name of program to be run with command line args\n");
888 inferior_pid = create_inferior(own_buf,environ);
889 printf("\nProcess %s created; pid = %d\n",own_buf,inferior_pid);
893 inferior_pid = create_inferior(argv[1],environ);
894 printf("\nProcess %s created; pid = %d\n",argv[1],inferior_pid);
899 printf("\nPacket received is>:%s\n",own_buf);
903 case 'h': /**********This is only for tweaking the gdb+ program *******/
904 signal = resume(1,0,&status);
905 prepare_resume_reply(own_buf,status,signal);
907 /*************end tweak*************************************/
909 case 'g': fetch_inferior_registers();
910 convert_int_to_ascii(registers,own_buf,REGISTER_BYTES);
912 case 'G': convert_ascii_to_int(&own_buf[1],registers,REGISTER_BYTES);
913 if(store_inferior_registers(-1)==0)
918 case 'm': decode_m_packet(&own_buf[1],&mem_addr,&len);
919 read_inferior_memory(mem_addr,mem_buf,len);
920 convert_int_to_ascii(mem_buf,own_buf,len);
922 case 'M': decode_M_packet(&own_buf[1],&mem_addr,&len,mem_buf);
923 if(write_inferior_memory(mem_addr,mem_buf,len)==0)
928 case 'c': signal = resume(0,0,&status);
929 printf("\nSignal received is >: %0x \n",signal);
930 prepare_resume_reply(own_buf,status,signal);
932 case 's': signal = resume(1,0,&status);
933 prepare_resume_reply(own_buf,status,signal);
935 case 'k': kill_inferior();
936 sprintf(own_buf,"q");
938 printf("\nObtained kill request...terminating\n");
941 case 't': try_writing_regs_command();
944 default : printf("\nUnknown option chosen by master\n");
953 /** now get out of here**/
954 printf("\nFinished reading data from serial link - Bye!\n");
960 cat << \SHAR_EOF > remote_utils.c
961 /* Remote utility routines for the remote server for GDB, the GNU debugger.
962 Copyright (C) 1986, 1989 Free Software Foundation, Inc.
964 This file is part of GDB.
966 This program is free software; you can redistribute it and/or modify
967 it under the terms of the GNU General Public License as published by
968 the Free Software Foundation; either version 2 of the License, or
969 (at your option) any later version.
971 This program is distributed in the hope that it will be useful,
972 but WITHOUT ANY WARRANTY; without even the implied warranty of
973 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
974 GNU General Public License for more details.
976 You should have received a copy of the GNU General Public License
977 along with this program; if not, write to the Free Software
978 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
983 #include <sys/wait.h>
984 #include <sys/ioctl.h>
986 #include <sys/file.h>
989 extern int remote_desc;
990 extern int remote_debugging;
1000 void convert_ascii_to_int();
1001 void convert_int_to_ascii();
1002 void prepare_resume_reply();
1004 /* Open a connection to a remote debugger.
1005 NAME is the filename used for communication. */
1008 remote_open (name, from_tty)
1014 remote_debugging = 0;
1016 remote_desc = open (name, O_RDWR);
1017 if (remote_desc < 0)
1018 printf("\ncould not open remote device\n");
1020 ioctl (remote_desc, TIOCGETP, &sg);
1022 ioctl (remote_desc, TIOCSETP, &sg);
1025 printf ("Remote debugging using %s\n", name);
1026 remote_debugging = 1;
1029 /* Convert hex digit A to a number. */
1035 if (a >= '0' && a <= '9')
1037 else if (a >= 'a' && a <= 'f')
1038 return a - 'a' + 10;
1040 perror ("Reply contains invalid hex digit");
1043 /* Convert number NIB to a hex digit. */
1055 /* Send the command in BUF to the remote machine,
1056 and read the reply into BUF.
1057 Report an error if we get an error reply. */
1067 perror ("Remote failure reply: %s", buf);
1070 /* Send a packet to the remote machine, with error checking.
1071 The data of the packet is in BUF. */
1078 unsigned char csum = 0;
1081 int cnt = strlen (buf);
1085 fprintf (stderr, "Sending packet: %s\n", buf);
1087 /* Copy the packet into buffer BUF2, encapsulating it
1088 and giving it a checksum. */
1093 for (i = 0; i < cnt; i++)
1099 *p++ = tohex ((csum >> 4) & 0xf);
1100 *p++ = tohex (csum & 0xf);
1102 /* Send it over and over until we get a positive ack. */
1105 write (remote_desc, buf2, p - buf2);
1106 read (remote_desc, buf3, 1);
1107 } while (buf3[0] != '+');
1114 while (read (remote_desc, buf, 1) != 1) ;
1115 return buf[0] & 0x7f;
1118 /* Read a packet from the remote machine, with error checking,
1119 and store it in BUF. */
1126 unsigned char csum, c, c1, c2;
1132 while ((c = readchar()) != '$');
1145 c1 = fromhex (readchar ());
1146 c2 = fromhex (readchar ());
1147 if (csum == (c1 << 4) + c2)
1150 printf ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n",
1151 (c1 << 4) + c2, csum, buf);
1152 write (remote_desc, "-", 1);
1155 write (remote_desc, "+", 1);
1158 fprintf (stderr,"Packet received :%s\n", buf);
1182 convert_int_to_ascii(from,to,n)
1183 char *from, *to; int n;
1190 nib = ((ch & 0xf0) >> 4)& 0x0f;
1200 convert_ascii_to_int(from,to,n)
1201 char *from, *to; int n;
1206 nib1 = fromhex(*from++);
1207 nib2 = fromhex(*from++);
1208 *to++ = (((nib1 & 0x0f)<< 4)& 0xf0) | (nib2 & 0x0f);
1213 prepare_resume_reply(buf,status,signal)
1215 unsigned char signal;
1222 nib = ((signal & 0xf0) >> 4) ;
1223 *buf++ = tohex(nib);
1224 nib = signal & 0x0f;
1225 *buf++ = tohex(nib);
1230 decode_m_packet(from,mem_addr_ptr,len_ptr)
1232 unsigned int *mem_addr_ptr, *len_ptr;
1236 *mem_addr_ptr = *len_ptr = 0;
1237 /************debugging begin************/
1238 printf("\nIn decode_m_packet");
1239 /************debugging end************/
1241 while((ch = from[i++]) != ',')
1243 *mem_addr_ptr = *mem_addr_ptr << 4;
1244 *mem_addr_ptr |= fromhex(ch) & 0x0f;
1246 /************debugging begin************/
1247 printf("\nFinished mem_addr part");
1248 /************debugging end************/
1250 for(j=0; j < 4; j++)
1252 if((ch = from[i++]) == 0)
1254 *len_ptr = *len_ptr << 4;
1255 *len_ptr |= fromhex(ch) & 0x0f;
1257 /************debugging begin************/
1258 printf("\nFinished len_ptr part");
1259 /************debugging end************/
1263 decode_M_packet(from,mem_addr_ptr,len_ptr,to)
1265 unsigned int *mem_addr_ptr, *len_ptr;
1269 *mem_addr_ptr = *len_ptr = 0;
1270 /************debugging begin************/
1271 printf("\nIn decode_M_packet");
1272 /************debugging end************/
1274 while((ch = from[i++]) != ',')
1276 *mem_addr_ptr = *mem_addr_ptr << 4;
1277 *mem_addr_ptr |= fromhex(ch) & 0x0f;
1279 /************debugging begin************/
1280 printf("\nFinished mem_addr part: memaddr = %x",*mem_addr_ptr);
1281 /************debugging end************/
1283 while((ch = from[i++]) != ':')
1285 *len_ptr = *len_ptr << 4;
1286 *len_ptr |= fromhex(ch) & 0x0f;
1288 /************debugging begin************/
1289 printf("\nFinished len_ptr part: len = %d",*len_ptr);
1290 /************debugging end************/
1292 convert_ascii_to_int(&from[i++],to,*len_ptr);
1294 /************debugging begin************/
1295 printf("\nmembuf : %x",*(int *)to);
1296 /************debugging end************/
1300 # End of shell archive