This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] gdbserver fails on 32-bit ppc rfs running in a-64 bit 2.6 linux kernel
- From: "Amit S. Kale" <amitkale at linsyssoft dot com>
- To: GDB patches <gdb-patches at sources dot redhat dot com>
- Date: Mon, 14 Mar 2005 21:37:35 +0530
- Subject: [patch] gdbserver fails on 32-bit ppc rfs running in a-64 bit 2.6 linux kernel
- Organization: LinSysSoft Technologies Pvt Ltd
Hi,
I found that gdbserver fails on a 32-bit ppc rfs running in a 64-bit 2.6 linux
kernel. The thread id's fetched from thread-db library are above 0x7fffffff.
gdbserver has implicit assumptions that thread id's are "signed integers".
This is true when running under a 32-bit kernel, but not true here. Attached
patch fixes this problem by changing the "strtol" that scans the thread-id to
"strtoul" and by changing the "cont_thread > 0" comparison to "cont_thread !=
-1".
Is there any likelyhood of this assumption being made in some other places in
gdbserver or gdb?
Thanks.
-Amit
Index: src/gdb/gdbserver/linux-low.c
===================================================================
--- src.orig/gdb/gdbserver/linux-low.c 2005-03-10 19:31:24.000000000 +0530
+++ src/gdb/gdbserver/linux-low.c 2005-03-14 20:49:11.589413080 +0530
@@ -667,7 +667,7 @@
then we need to make sure we restart the other threads. We could
pick a thread at random or restart all; restarting all is less
arbitrary. */
- if (cont_thread > 0)
+ if (cont_thread != -1)
{
child = (struct thread_info *) find_inferior_id (&all_threads,
cont_thread);
@@ -1430,7 +1430,7 @@
{
extern unsigned long signal_pid;
- if (cont_thread > 0)
+ if (cont_thread != -1)
{
struct process_info *process;
Index: src/gdb/gdbserver/server.c
===================================================================
--- src.orig/gdb/gdbserver/server.c 2005-03-10 19:31:24.000000000 +0530
+++ src/gdb/gdbserver/server.c 2005-03-14 21:05:22.774770464 +0530
@@ -193,7 +193,7 @@
if (p[0] == 'S' || p[0] == 'C')
{
int sig;
- sig = strtol (p + 1, &q, 16);
+ sig = strtoul (p + 1, &q, 16);
if (p == q)
goto err;
p = q;
@@ -281,7 +281,7 @@
struct thread_resume resume_info[2];
int n = 0;
- if (step || sig || cont_thread > 0)
+ if (step || sig || cont_thread != -1)
{
resume_info[0].thread
= ((struct inferior_list_entry *) current_inferior)->id;
@@ -293,7 +293,7 @@
resume_info[n].thread = -1;
resume_info[n].step = 0;
resume_info[n].sig = 0;
- resume_info[n].leave_stopped = (cont_thread > 0);
+ resume_info[n].leave_stopped = (cont_thread != -1);
(*the_target->resume) (resume_info);
}