Patch for warning in gdb/linux-thread.c
Andreas Jaeger
aj@suse.de
Thu Oct 28 01:31:00 GMT 1999
The current cvs version of gdb produces a number of harmless warnings
in linuxthreads. I've fixed the following warnings with the appended
patch.
../../cvs/gdb/gdb/linux-thread.c:165: warning: missing initializer
../../cvs/gdb/gdb/linux-thread.c:165: warning: (near initialization for `linuxthreads_sig_restart.print')
../../cvs/gdb/gdb/linux-thread.c:168: warning: missing initializer
../../cvs/gdb/gdb/linux-thread.c:168: warning: (near initialization for `linuxthreads_sig_cancel.print')
../../cvs/gdb/gdb/linux-thread.c:171: warning: missing initializer
../../cvs/gdb/gdb/linux-thread.c:171: warning: (near initialization for `linuxthreads_sig_debug.print')
../../cvs/gdb/gdb/linux-thread.c: In function `linuxthreads_find_trap':
../../cvs/gdb/gdb/linux-thread.c:338: warning: suggest explicit braces to avoid ambiguous `else'
../../cvs/gdb/gdb/linux-thread.c: In function `resume_thread':
../../cvs/gdb/gdb/linux-thread.c:653: warning: suggest explicit braces to avoid ambiguous `else'
../../cvs/gdb/gdb/linux-thread.c: In function `stop_thread':
../../cvs/gdb/gdb/linux-thread.c:681: warning: suggest explicit braces to avoid ambiguous `else'
../../cvs/gdb/gdb/linux-thread.c: In function `linuxthreads_wait':
../../cvs/gdb/gdb/linux-thread.c:1286: warning: suggest explicit braces to avoid ambiguous `else'
../../cvs/gdb/gdb/linux-thread.c:1366: warning: suggest explicit braces to avoid ambiguous `else'
Andreas
1999-10-28 Andreas Jaeger <aj@suse.de>
* linux-thread.c: Add missing initializers to avoid gcc warnings.
(resume_thread): Add braces as recommended by gcc -Wparentheses.
(stop_thread): Likewise.
(linuxthreads_wait): Likewise.
(linuxthreads_find_trap): Likewise.
--- gdb/linux-thread.c.~1~ Thu Sep 9 01:59:18 1999
+++ gdb/linux-thread.c Thu Oct 28 10:28:53 1999
@@ -161,13 +161,13 @@ struct linuxthreads_signal {
};
struct linuxthreads_signal linuxthreads_sig_restart = {
- "__pthread_sig_restart", 1, 0, 0, 0
+ "__pthread_sig_restart", 1, 0, 0, 0, 0
};
struct linuxthreads_signal linuxthreads_sig_cancel = {
- "__pthread_sig_cancel", 1, 0, 0, 0
+ "__pthread_sig_cancel", 1, 0, 0, 0, 0
};
struct linuxthreads_signal linuxthreads_sig_debug = {
- "__pthread_sig_debug", 0, 0, 0, 0
+ "__pthread_sig_debug", 0, 0, 0, 0, 0
};
/* A table of breakpoint locations, one per PID. */
@@ -336,10 +336,12 @@ linuxthreads_find_trap (pid, stop)
else if (WSTOPSIG(status) != SIGSTOP)
wstatus[last++] = status;
else if (stop)
- if (found_trap)
- break;
- else
- found_stop = 1;
+ {
+ if (found_trap)
+ break;
+ else
+ found_stop = 1;
+ }
}
/* Resend any other signals we noticed to the thread, to be received
@@ -651,10 +653,12 @@ resume_thread (pid)
if (pid != inferior_pid
&& in_thread_list (pid)
&& linuxthreads_thread_alive (pid))
- if (pid == linuxthreads_step_pid)
- child_resume (pid, 1, linuxthreads_step_signo);
- else
- child_resume (pid, 0, TARGET_SIGNAL_0);
+ {
+ if (pid == linuxthreads_step_pid)
+ child_resume (pid, 1, linuxthreads_step_signo);
+ else
+ child_resume (pid, 0, TARGET_SIGNAL_0);
+ }
}
/* Detach a thread */
@@ -679,21 +683,23 @@ stop_thread (pid)
int pid;
{
if (pid != inferior_pid)
- if (in_thread_list (pid))
- kill (pid, SIGSTOP);
- else if (ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0) == 0)
- {
- if (!linuxthreads_attach_pending)
- printf_unfiltered ("[New %s]\n", target_pid_to_str (pid));
- add_thread (pid);
- if (linuxthreads_sig_debug.signal)
- /* After a new thread in glibc 2.1 signals gdb its existence,
- it suspends itself and wait for linuxthreads_sig_restart,
- now we can wake up it. */
- kill (pid, linuxthreads_sig_restart.signal);
- }
- else
- perror_with_name ("ptrace in stop_thread");
+ {
+ if (in_thread_list (pid))
+ kill (pid, SIGSTOP);
+ else if (ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0) == 0)
+ {
+ if (!linuxthreads_attach_pending)
+ printf_unfiltered ("[New %s]\n", target_pid_to_str (pid));
+ add_thread (pid);
+ if (linuxthreads_sig_debug.signal)
+ /* After a new thread in glibc 2.1 signals gdb its existence,
+ it suspends itself and wait for linuxthreads_sig_restart,
+ now we can wake up it. */
+ kill (pid, linuxthreads_sig_restart.signal);
+ }
+ else
+ perror_with_name ("ptrace in stop_thread");
+ }
}
/* Wait for a thread */
@@ -1284,10 +1290,12 @@ linuxthreads_wait (pid, ourstatus)
if (rpid > 0)
break;
if (rpid < 0)
- if (errno == EINTR)
- continue;
- else if (save_errno != 0)
- break;
+ {
+ if (errno == EINTR)
+ continue;
+ else if (save_errno != 0)
+ break;
+ }
sigsuspend(&omask);
}
@@ -1364,10 +1372,12 @@ linuxthreads_wait (pid, ourstatus)
{
/* Skip SIGSTOP signals. */
if (!linuxthreads_pending_status (rpid))
- if (linuxthreads_step_pid == rpid)
- child_resume (rpid, 1, linuxthreads_step_signo);
- else
- child_resume (rpid, 0, TARGET_SIGNAL_0);
+ {
+ if (linuxthreads_step_pid == rpid)
+ child_resume (rpid, 1, linuxthreads_step_signo);
+ else
+ child_resume (rpid, 0, TARGET_SIGNAL_0);
+ }
continue;
}
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.rhein-neckar.de
More information about the Gdb
mailing list