This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

threads/1875: parse error while setting thread specific breakpoint


>Number:         1875
>Category:       threads
>Synopsis:       parse error while setting thread specific breakpoint
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 22 02:08:00 UTC 2005
>Closed-Date:
>Last-Modified:
>Originator:     spraveen@ittc.ku.edu
>Release:        GNU gdb Red Hat Linux (6.0post-0.20040223.19rh)
>Organization:
>Environment:
"uname -a" OUTPUT:
Linux system 2.6.8-1.521 #4 Thu Feb 17 23:33:04 CST 2005 i686 i686 i386 GNU/Linux

"gcc --version" Output:
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

"gdb" output:
testbed62 [8] % gdb
GNU gdb Red Hat Linux (6.0post-0.20040223.19rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu".

"rpm -q glibc" Output:
glibc-2.3.3-27

"getconf GNU_LIBPTHREAD_VERSION" Output:
NPTL 0.61
>Description:
I tried to insert thread specific breakpoints in the following format

break *0x<address> thread <threadno> if <condition>

and I get the following parse error

A parse error in expression, near `thread 2'.

While I am able to set breakpoints that include other SAL specification like <source file:line no> and symbol name, this particular case gives me the error.

I looked at the code and it assumes whatever that follows after the address is a C expression. It tries to parse it and fails. Other SAL specification types do not make this assumption and look for "thread" keyword before parsing the rest of the string.

The gdb info page says that it accepts all types of SAL specification while setting a thread specific breakpoint. So I assume that either the documentation is incorrect, or the functionality is not achieved.

I took a simple pthread program as below:

#include <stdio.h>
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/unistd.h>

_syscall0(pid_t,gettid)

#define NUM_THREADS 4

void *count() {
	int i;
	int cur_thr_id = 0;
	
	cur_thr_id = gettid();
	
	for (i=0; i < 10; i++) {
		printf("\ni in Thread %d: %d", cur_thr_id, i);
	}
	
	return NULL;
}

int main() {
	
	pthread_t pt[NUM_THREADS];
	
	int i;	
	
 	// create threads now
	for(i=0; i<NUM_THREADS; i++) {
		pthread_create(&pt[i], NULL, count, NULL);
	}
	
	// Wait for the threads to exit
	for(i=0; i<NUM_THREADS; i++) {
		pthread_join(pt[i], NULL);
	}
	
	printf("\nHello World\n");

	return 1;
}

I am attaching a sample debug session:

testbed62 [50] % gdb test
GNU gdb Red Hat Linux (6.0post-0.20040223.19rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) b main
Breakpoint 1 at 0x80484d8: file pthread_test.c, line 31.
(gdb) r
Starting program: /projects/BERT/spraveen/test_programs/pthread_test/bug/test 
Error while mapping shared library sections:
: Success.
Error while reading shared library symbols:
: No such file or directory.
[Thread debugging using libthread_db enabled]
[New Thread 1073834272 (LWP 26981)]
Error while reading shared library symbols:
: No such file or directory.
Error while reading shared library symbols:
: No such file or directory.
[Switching to Thread 1073834272 (LWP 26981)]

Breakpoint 1, main () at pthread_test.c:31
31              for(i=0; i<NUM_THREADS; i++) {
(gdb) b pthread_test.c:36
Breakpoint 2 at 0x804850c: file pthread_test.c, line 36.
(gdb) c
Continuing.
[New Thread 1082227632 (LWP 27038)]

[New Thread 1090620336 (LWP 27039)]
i in Thread 27038: 0
[New Thread 1099017136 (LWP 27040)]
i in Thread 27038: 1
[New Thread 1107409840 (LWP 27041)]

Breakpoint 2, main () at pthread_test.c:36
36              for(i=0; i<NUM_THREADS; i++) {
(gdb) info threads
  5 Thread 1107409840 (LWP 27041)  0x007b815c in clone () from /lib/tls/libc.so.6
  4 Thread 1099017136 (LWP 27040)  0xffffe410 in ?? ()
  3 Thread 1090620336 (LWP 27039)  0xffffe410 in ?? ()
  2 Thread 1082227632 (LWP 27038)  0xffffe410 in ?? ()
* 1 Thread 1073834272 (LWP 26981)  main () at pthread_test.c:36
(gdb) b *0x007b815c thread 4
A parse error in expression, near `thread 4'.
(gdb) q
The program is running.  Exit anyway? (y or n) y

Please send me an email if you need more information about this problem.

Thanks for very much for your attention and patience.

Regards,
Praveen
>How-To-Repeat:
This problem occurs whenever you try to set a thread specific breakpoint in the following format.

break *0x<address> thread <threadno>

Please see the description for a sample program and a debug session
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]