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

About gdb remote debug on intel x86(gdb Red Hat Linux (5.1.90CVS-5))



 About gdb remote debug on intel x86(gdb Red Hat Linux (5.1.90CVS-5))
Hello!
I have defined the supporting low-level routines:getDebugChar, putDebugChar,
 exceptionHandler.
#####################################################
#include "asm/segment.h"
#define _set_gate(gate_addr,type,dpl,addr) \
do { \
 int __d0, __d1; \
  __asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
	"movw %4,%%dx\n\t" \
	"movl %%eax,%0\n\t" \
	"movl %%edx,%1" \
	:"=m" (*((long *) (gate_addr))), \
	 "=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \
	:"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
	 "3" ((char *) (addr)),"2" (__KERNEL_CS << 16)); \
} while (0)
extern void exceptionHandler(int n,void *ept_func)           <===exceptionHandler
{
	 int __d0,__d1;
	 long *idt;
	 __asm__ __volatile__("sidt %0"
		:"=m"(*((long*)idt)));
	 _set_gate(idt+2*n,14,0,ept_func);
	 return;
}
#########################################################
#include "asm/io.h"
#include "unistd.h"

static int Isinit=0;
void serialinit()
{ 
	outb(0x80,0x3fb);
    outb(0x0c,0x3f8);
    outb(0x0,0x3f9);
	outb(0x0b,0x3fb);
	outb(0x0,0x3fc);
	outb(0x0,0x3f9);
	Isinit=1;
	return;
}

extern int getDebugChar()   <====getDebugChar
{
	int ch=0,flag=0;
	char test;
	ioperm(0x3f8,8,1);
	if(!Isinit) serialinit();
	while (flag!=1)
	{
		test=inb(0x3fd);
		if((test&0x01)==0x01)flag=1;
	}
	ch=inb(0x3f8);
	return ch;
}

extern void putDebugChar(char ch)  <====putDebugChar
{
	int flag=0;
	char test;
	ioperm(0x3f8,8,1);
	if(!Isinit)
		serialinit();
	while (flag!=1)
	{
		test=inb(0x3fd);
		if((test&0x20)==0x20) flag=1;
	}
	//outb(0x0,0x3f8);
    outb(ch,0x3f8);
	return;
}
#########################################################
I compile and link together  my program and the supporting subroutines.
I have a serial connection between target machine and the gdb host,
I can identify the serial port on the host through test.but I download my program to 
 target machine and start it,then the screen display "Trace/beakpoint trap".
 When I start gdb on the host, and try to connect to the target,the screen display:

GNU gdb Red Hat Linux (5.1.90CVS-5)
Copyright 2002 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".
(gdb) file a.out
Reading symbols from a.out...done.
(gdb) set remotebaud 9600
(gdb) target remote /dev/ttyS0
Remote debugging using /dev/ttyS0
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Couldn't establish connection to remote target
Malformed response to offset query, timeout
(gdb)

the question:can you help me find my mistakes in what I do above?





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