This is the mail archive of the gdb@sourceware.org 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]

Re: gdbserver signals interfere with {next,step{,i}}


Daniel Jacobowitz wrote:
On Mon, Mar 05, 2007 at 03:05:34PM -0500, Jon Ringle wrote:
Hello,

I have an application that uses SIGUSR1 to receive timer interrupts. I've done 'handle SIGUSR1 nostop noprint' to avoid gdb from stopping on SIGUSR1.
I've found that when debugging this application using gdbserver, that I can't use next, nexti, step, or stepi. When I use one of these commands, the application usually just continues without stopping at the next line/instruction.


If I use a native gdb on the target the problem does not occur.
If I disable my app from generating the SIGUSR1 and use gdbserver, the problem also goes away.

I haven't seen this problem before. Can you make a small test case which demonstrates the problem, maybe?

Attached is a test case. <cid:part1.03040401.03010207@ringle.org>
What target are you using?

My target is armeb-linux.

Thanks,

Jon

#include <stdio.h>
#include <pthread.h>
#include <signal.h>

static void signal_handler (int signo);
static timer_t   timer_id       = -1;
#define ERROR (-1)

int i = 0;
void signal_handler(int signo)
{
	// Perform a use-less task
	i++;
}

void init_signals (void)
{
	struct sigaction  sig_act;
	struct sigevent   evp;
    	struct itimerspec   ttime;
    
	/* initialize sig_act */
	sig_act.sa_handler = (void*)signal_handler;
	sig_act.sa_flags   = 0;
	sigemptyset(&sig_act.sa_mask);

	sigaction(SIGUSR1, &sig_act, 0);
	
	evp.sigev_value.sival_int = 0;
	evp.sigev_signo = SIGUSR1;
        timer_create (CLOCK_REALTIME, &evp, &timer_id);

	ttime.it_value.tv_sec     = 0;          /* 0  S */
	ttime.it_value.tv_nsec    = 20000000;   /* 20mS */
	ttime.it_interval.tv_sec  = 0;          /* 0  S */
	ttime.it_interval.tv_nsec = 20000000;   /* 20mS */
	
	/* fire off the periodic timer - relative mode = 0 */
	timer_settime(timer_id, 0, &ttime, NULL);
}

static int get_input(char *buffer, int size)
{
	char    c;
	int     status, counter, dummy;
	
	counter= 0;
	c      = 0;
	status = 0;
	
	while (c != '\r')
	{
		dummy = getc(stdin);
		c = (char)dummy;
		
		if ((dummy != EOF) && (dummy != 0)) {
			if ( isprint(c) && (counter < size-1) )  {
				buffer[counter++] = c;
			} else if ((c == '\r') || (c == '\n')) {
				/* return user's str length - while loop will terminate */
				status = counter;
				
				c = '\r';
			} else  {
				; /* Ignore any other characters */
			}
			
		} else {
			memset (buffer, 0, size);
			
			counter = 0;
			if (dummy == 0)
				printf ("\nreceived NULL!\n");
			
			else
				printf ("\n\nGot EOF!\n");
			sleep(10);
			c      = '\r';
			status = ERROR;
		}
	}
	buffer[counter] = 0;
	return status;
}

void* thread(void* dummy)
{
	init_signals();

	while (1)
		;
	return NULL;
}

int main(int argc, char* argv[])
{
	pthread_t tid;
	pthread_create(&tid, NULL, &thread, NULL);
	while (1)
	{
		char buffer[200];
		printf ("Prompt %d> ", i);
		get_input(buffer, sizeof(buffer));

		// Give ourselves something to next...
		printf("Got "); // <<<<<<<<<<<<< Put breakpoint here 
		printf("'%s'", buffer);
		printf("\n");
	}
	pthread_join(tid,NULL);
	return 0;
}
	    

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