From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10811 invoked by alias); 9 May 2006 09:46:28 -0000 Received: (qmail 10802 invoked by uid 22791); 9 May 2006 09:46:27 -0000 X-Spam-Check-By: sourceware.org Received: from smtp2.wanadoo.fr (HELO smtp2.wanadoo.fr) (193.252.22.29) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 09 May 2006 09:46:25 +0000 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf0212.wanadoo.fr (SMTP Server) with ESMTP id 6E5B81C00211 for ; Tue, 9 May 2006 11:46:22 +0200 (CEST) Received: from w98.wanadoo.fr (AMarseille-252-1-59-153.w86-193.abo.wanadoo.fr [86.193.162.153]) by mwinf0212.wanadoo.fr (SMTP Server) with ESMTP id C47AB1C00214; Tue, 9 May 2006 11:46:20 +0200 (CEST) X-ME-UUID: 20060509094620804.C47AB1C00214@mwinf0212.wanadoo.fr Message-Id: <6.1.0.6.0.20060509114307.00a0e780@pop.wanadoo.fr> X-Sender: jr.peulve@pop.wanadoo.fr X-Mailer: QUALCOMM Windows Eudora Version 6.1.0.6 Date: Tue, 09 May 2006 11:58:00 -0000 To: Nathan Sidwell From: Jean-Rene Peulve Subject: Re: gdbserver for m68k-uclinux Cc: gdb@sources.redhat.com, Daniel Jacobowitz In-Reply-To: <445F5278.3000900@codesourcery.com> References: <445F5278.3000900@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1"; format=flowed Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00083.txt.bz2 Hi Nathan, Oups: I resend this because the previous email was html and got bounced by= =20 gdb@sources.redhat.com I have been forced to change your patch to make it works. 1) missing return in server.c 2) I also add an fprintf to stderr with the address of the text and data=20 section to allow the use of add-symbol_file command which requires these=20 address. The response to qOffsets being hidden by gdb, I then can get it from the= =20 target console or telnet. Jean-Ren=E9 Peulv=E9 Here are my revised patches based on yours: --- server.c.orig 2006-02-08 20:26:00.000000000 +0100 +++ server.c 2006-05-09 11:07:15.000000000 +0200 @@ -129,6 +129,23 @@ } } + if (the_target->read_offsets !=3D NULL + && strcmp ("qOffsets", own_buf) =3D=3D 0) + { + CORE_ADDR text, data; + + if (the_target->read_offsets (&text, &data)) { + sprintf (own_buf, "Text=3D%lX;Data=3D%lX;Bss=3D%lX", + (long)text, (long)data, (long)data); + return; + } + else + write_enn (own_buf); + + return; + } + + if (the_target->read_auxv !=3D NULL && strncmp ("qPart:auxv:read::", own_buf, 17) =3D=3D 0) { --- linux-low.c.orig 2006-05-09 11:21:12.000000000 +0200 +++ linux-low.c 2006-05-09 10:58:55.000000000 +0200 @@ -140,7 +140,11 @@ void *new_process; int pid; +#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__) + pid =3D vfork (); +#else pid =3D fork (); +#endif if (pid < 0) perror_with_name ("fork"); @@ -896,7 +900,7 @@ if (debug_threads && the_low_target.get_pc !=3D NULL) { fprintf (stderr, " "); - (long) (*the_low_target.get_pc) (); + (*the_low_target.get_pc) (); } /* If we have pending signals, consume one unless we are trying to rein= sert @@ -1550,6 +1554,52 @@ return 0; } +#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__) +#if defined(__mcoldfire__) +/* These should really be defined in the kernel's ptrace.h header. */ +#define PT_TEXT_ADDR 49*4 +#define PT_DATA_ADDR 50*4 +#define PT_TEXT_END_ADDR 51*4 +#endif + +/* Under uClinux, programs are loaded at non-zero offsets, which we need + to tell gdb about. */ + +static int +linux_read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p) +{ +#if defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) &&=20 defined(PT_TEXT_END_ADDR) + unsigned long text, text_end, data; + int pid =3D get_thread_process (current_inferior)->head.id; + + errno =3D 0; + + text =3D ptrace (PTRACE_PEEKUSER, pid, (long)PT_TEXT_ADDR, 0); + text_end =3D ptrace (PTRACE_PEEKUSER, pid, (long)PT_TEXT_END_ADDR, 0); + data =3D ptrace (PTRACE_PEEKUSER, pid, (long)PT_DATA_ADDR, 0); + + fprintf(stderr, "text=3D%lx data=3D%lx errno=3D%d\n", text, data, errno); + if (errno =3D=3D 0) + { + /* Both text and data offsets produced at compile-time (and so + used by gdb) are relative to the beginning of the program, + with the data segment immediately following the text segment. + However, the actual runtime layout in memory may put the data + somewhere else, so when we send gdb a data base-address, we + use the real data base address and subtract the compile-time + data base-address from it (which is just the length of the + text segment). BSS immediately follows data in both + cases. */ + *text_p =3D text; + *data_p =3D data - (text_end - text); + + return 1; + } +#endif + return 0; +} +#endif + static struct target_ops linux_target_ops =3D { linux_create_inferior, linux_attach, @@ -1569,6 +1619,9 @@ linux_remove_watchpoint, linux_stopped_by_watchpoint, linux_stopped_data_address, +#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_MMU__) + linux_read_offsets, +#endif }; static void