Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* huge remote debug traffic with multi-thread program
@ 2005-02-16 16:24 Atsushi Nemoto
  2005-02-17  1:42 ` Daniel Jacobowitz
  0 siblings, 1 reply; 8+ messages in thread
From: Atsushi Nemoto @ 2005-02-16 16:24 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: Text/Plain, Size: 3379 bytes --]

When remote-debugging a multi-thread program on mips-linux, I see huge
remote traffic after interrupting the remote program.

My target environment is mips(el)-linux (Debian sarge) and current gdb
snapshot (20050216).

Here is my test program.

#include <pthread.h>
pthread_mutex_t pm;
static void *func(void *arg)
{
	while (1) {
		pthread_mutex_lock(&pm);
		pthread_mutex_unlock(&pm);
	}
}
int main(int argc, char *argv[])
{
	int i;
	pthread_t tid[2];
	pthread_mutex_init(&pm, NULL);
	for (i = 0; i < 2; i++)
		pthread_create(&tid[i], NULL, func, NULL);
	for (i = 0; i < 2; i++)
		pthread_join(tid[i], NULL);
}

When I typed Ctrl-C and 'c' (continue) on gdb, traffic between gdb and
gdbserver start eating network bandwidth and gdbserver eats whole CPU
power on the target.  Is this a normal behavior?

If I replace last 2 line in main() with following code (i.e. not
use pthread_join), the traffic disappear soon.

	while (1)
		sleep(100);

With gdb 6.3, the traffic disappear soon without this change.


With "set debug remote 1", I got following logs after the 'c' command.
(please refer hostlog-join.txt for complete log)

(gdb) c
Continuing.
Sending packet: $m404e18,4#33...Ack
Packet received: 03e00008
Sending packet: $m404e18,4#33...Ack
Packet received: 03e00008
Sending packet: $m404a78,4#35...Ack
Packet received: 8fbc0010
Sending packet: $M404a78,4:0005000d#08...Ack
Packet received: OK
Sending packet: $vCont;c#a8...Ack
Packet received: T0525:00404a78;1d:7f7ff998;thread:4002;
...
Sending packet: $vCont;c:4002#a8...Ack
Packet received: T0525:00404a7c;1d:7f7ff998;thread:4002;
...
Sending packet: $vCont;c#a8...Ack
Packet received: T0525:00404a78;1d:7f5ff998;thread:8003;
...
Sending packet: $vCont;c:8003#ad...Ack
Packet received: T0525:00404a7c;1d:7f5ff998;thread:8003;
...
Sending packet: $vCont;c#a8...Ack
Packet received: T0525:00404a78;1d:7f7ff998;thread:4002;
...
Sending packet: $vCont;c:4002#a8...Ack
Packet received: T0525:00404a7c;1d:7f7ff998;thread:4002;
...

0x00404a78 and 0x00404a7c are within __pthread_wait_for_restart_signal().

0x00404a70 <__pthread_wait_for_restart_signal+124>:     jalr    t9	# __pthread_sigsuspend()
0x00404a74 <__pthread_wait_for_restart_signal+128>:     nop
0x00404a78 <__pthread_wait_for_restart_signal+132>:     lw      gp,16(sp)
0x00404a7c <__pthread_wait_for_restart_signal+136>:     lw      v1,96(s0)
0x00404a80 <__pthread_wait_for_restart_signal+140>:     lw      v0,-32364(gp)
0x00404a84 <__pthread_wait_for_restart_signal+144>:     nop
0x00404a88 <__pthread_wait_for_restart_signal+148>:     lw      v0,0(v0)
0x00404a8c <__pthread_wait_for_restart_signal+152>:     nop
0x00404a90 <__pthread_wait_for_restart_signal+156>:     bne     v1,v0,0x404a68 <__pthread_wait_for_restart_signal+116>


Using sleep() instead of pthread_join(), I got any packets after
'$vCont' until I type Ctrl-C again.
(please refer hostlog-sleep.txt for complete log)

Attached is a complete logs for both side.  The test program is
statically linked.  This problem is same with dynamically linked
program.

hostlog-join.txt	-- gdb log with 'set debug remote 1' (pthread_join)
serverlog-join.txt	-- gdbserver log with debug_threads = 1 (pthread_join)
hostlog-sleep.txt	-- gdb log with 'set debug remote 1' (sleep)
serverlog-sleep.txt	-- gdbserver log with debug_threads = 1 (sleep)

Could someone look into this?

Thank you.
---
Atsushi Nemoto

[-- Attachment #2: log.tar.gz --]
[-- Type: Application/Octet-Stream, Size: 4483 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-03-17 18:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-16 16:24 huge remote debug traffic with multi-thread program Atsushi Nemoto
2005-02-17  1:42 ` Daniel Jacobowitz
2005-02-17  9:01   ` Atsushi Nemoto
2005-02-18 22:54     ` Atsushi Nemoto
2005-02-22 18:59       ` Atsushi Nemoto
2005-03-17  5:43         ` Atsushi Nemoto
2005-03-17 11:38           ` Bob Rossi
2005-03-17 18:21           ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox