[uClinux-dev] gdbserver kills the shell?

Stuart Hughes stuarth at freescale.com
Wed Oct 5 10:59:44 EDT 2005


Here's a patch based on Miles Bader's.  I've removed the v850 sections 
to try to make it just a nommu patch.

Again, this is against vanilla gdb-6.0.

Regards, Stuart

Stuart Hughes wrote:
> Hi John,
> 
> I'm in the process of forward porting the patches for gdbserver that are 
> in uClinux-dist-test-20050906.tar.bz2 to gdb-6.0.  I've attached a patch 
> that works, but needs a bit of clean-up.  I also found the Miles Bader 
> patch gdbserver-v850.bin which looks like it may be more generic, so 
> I'll probably make adjustments.
> 
> Although this won't slot directly into uClinux-dist, hopefully this may 
> help you.
> 
> Regards, Stuart
> 
> John Williams wrote:
> 
>> David McCullough wrote:
>>
>>> I would have thought Miles patches would apply fairly cleanly to the new
>>> gdb/gdbserver source.
>>
>>
>>
>> Yep, I've done that and looks good at first glance.
>>
>> Dare I ask, what's the plan for the current uClinux-dist CVS?  My 
>> memory is that the current CVS is officially still a test-release.
>>
>> It works pretty well for microblaze right now, but if Gerg is still 
>> taking patches before the next real cut I've got some stuff here 
>> (uClinux-ifying the new gdbserver included).
>>
>> Greg?  :)
>>
>> Thx,
>>
>> John
>> _______________________________________________
>> uClinux-dev mailing list
>> uClinux-dev at uclinux.org
>> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
>> This message was resent by uclinux-dev at uclinux.org
>>
> 
> 
> ------------------------------------------------------------------------
> 
> diff --exclude CVS -uNr gdb-6.0/gdb/gdbserver/linux-low.c gdb-6.0.modified/gdb/gdbserver/linux-low.c
> --- gdb-6.0/gdb/gdbserver/linux-low.c	Sun Jun 29 05:03:04 2003
> +++ gdb-6.0.modified/gdb/gdbserver/linux-low.c	Wed Oct  5 14:15:56 2005
> @@ -69,6 +69,12 @@
>  static int use_regsets_p = 1;
>  #endif
>  
> +#if defined(EMBED) ||  defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__)
> +static unsigned int code_end;
> +static unsigned int code_start;
> +static unsigned int data_start;
> +static unsigned int bss_start;
> +#endif
>  extern int errno;
>  
>  int debug_threads = 0;
> @@ -139,7 +145,11 @@
>    void *new_process;
>    int pid;
>  
> +#if defined(EMBED) ||  defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__)
> +  pid = vfork ();
> +#else
>    pid = fork ();
> +#endif
>    if (pid < 0)
>      perror_with_name ("fork");
>  
> @@ -1293,3 +1303,38 @@
>    init_registers ();
>    linux_init_signals ();
>  }
> +
> +#if defined(EMBED) ||  defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__)
> +void
> +send_area(char *buf)
> +{
> +    /*
> +     * with the new compilers (gcc-2.95.2 this has changed and we need to
> +     * send back the start of code for everything
> +     *
> +     * Of course, the start of code is fairly interesting since there might be a
> +     * break inserted between code and data segments.  We've got to account for this
> +     * break by faking a start of data that is the length of the code segment below the
> +     * real begining of the data segment.
> +     */
> +    unsigned int x;
> +    x = data_start - (code_end - code_start);
> +    sprintf(buf,"Text=%x;Data=%x;Bss=%x;", code_start, x, x);
> +}
> +
> +void
> +show_area()
> +{
> +    code_start = ptrace (PTRACE_PEEKUSER, inferior_pid,
> +                 (PTRACE_ARG3_TYPE) 49*4, 0);
> +    data_start = ptrace (PTRACE_PEEKUSER, inferior_pid,
> +                 (PTRACE_ARG3_TYPE) 50*4, 0);
> +    bss_start = data_start;
> +    code_end = ptrace(PTRACE_PEEKUSER, inferior_pid,
> +                 (PTRACE_ARG3_TYPE) 51*4, 0);
> +
> +    fprintf(stderr,"code at %p - %p, data at %p\n", (void *)code_start, 
> +                                                    (void *)code_end,
> +                                                    (void *)data_start);
> +}
> +#endif
> diff --exclude CVS -uNr gdb-6.0/gdb/gdbserver/server.c gdb-6.0.modified/gdb/gdbserver/server.c
> --- gdb-6.0/gdb/gdbserver/server.c	Tue Jun 17 21:28:14 2003
> +++ gdb-6.0.modified/gdb/gdbserver/server.c	Wed Oct  5 14:00:55 2005
> @@ -184,6 +184,9 @@
>        signal = start_inferior (&argv[2], &status);
>  
>        /* We are now stopped at the first instruction of the target process */
> +#if defined(EMBED) ||  defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__)
> +      show_area();
> +#endif
>      }
>    else
>      {
> @@ -198,6 +201,7 @@
>  	}
>      }
>  
> +
>    while (1)
>      {
>        remote_open (argv[1]);
> @@ -212,7 +216,21 @@
>  	  switch (ch)
>  	    {
>  	    case 'q':
> +#if defined(EMBED) ||  defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__)
> +          switch (own_buf[1]) {
> +          case 'C':
> +                own_buf[0] = '\0';
> +            break;
> +          case 'O':
> +            send_area(own_buf);
> +                break;
> +          default:
> +                own_buf[0] = '\0';
> +            break;
> +          }
> +#else
>  	      handle_query (own_buf);
> +#endif
>  	      break;
>  	    case 'd':
>  	      remote_debug = !remote_debug;
> @@ -440,3 +458,8 @@
>  	}
>      }
>  }
> +
> +void _cleanup()
> +{
> +}
> +
> diff --exclude CVS -uNr gdb-6.0/gdb/gdbserver/server.h gdb-6.0.modified/gdb/gdbserver/server.h
> --- gdb-6.0/gdb/gdbserver/server.h	Sun Jun 29 05:03:04 2003
> +++ gdb-6.0.modified/gdb/gdbserver/server.h	Wed Oct  5 13:57:04 2005
> @@ -162,6 +162,12 @@
>  void fatal (const char *string,...) ATTR_NORETURN;
>  void warning (const char *string,...);
>  
> +#if defined(EMBED) ||  defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__)
> +/* Functions from low-linux.c */
> +void show_area(void);
> +void send_area(char *buf);
> +#endif
> +
>  /* Functions from the register cache definition.  */
>  
>  void init_registers (void);
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> uClinux-dev mailing list
> uClinux-dev at uclinux.org
> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> This message was resent by uclinux-dev at uclinux.org

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gdb-6.0-nommu-2.patch
URL: <http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20051005/f985a165/attachment.ksh>


More information about the uClinux-dev mailing list