[CentOS] Problem in gdb

Tue Feb 16 05:32:43 UTC 2010
Balaji <balajisundar at midascomm.com>

Dear All,

We are running RHEL4 Update 4 AS IA-64 on a HP rx6600.

We are running programs compiled in RHEL4 Update 4 AS in i386 
architecture using the emul library(Intel IA-32 Execution Layer )

[admin at corviewsecondary ~]$ service ia32el status
Intel IA-32 Execution Layer in use

When we attempt to run a program using /usr/bin/gdb we are not able to 
hit the break point set.

[admin at corviewsecondary ~]$ file /usr/bin/gdb
/usr/bin/gdb: ELF 64-bit LSB executable, IA-64, version 1 (SYSV), for 
GNU/Linux 2.4.0, dynamically linked (uses shared libs), stripped

[admin at corviewsecondary ~]$ /usr/bin/gdb ./loopTest
GNU gdb Red Hat Linux (6.3.0.0-1.132.EL4rh)
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 "ia64-redhat-linux-gnu"...Using host 
libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) b main
warning: Can't fetch instructions for slot numbers greater than 2.
Using slot 0 instead
Breakpoint 1 at 0x8048384: file loopTest.c, line 6.
(gdb) r

But the breakpoint does not get hit.

We tried using the /emul/ia32-linux/usr/bin/gdb. But the program does 
not run.

[admin at corviewsecondary ~]$ file /emul/ia32-linux/usr/bin/gdb
/emul/ia32-linux/usr/bin/gdb: ELF 32-bit LSB executable, Intel 80386, 
version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared 
libs), stripped

[admin at corviewsecondary ~]$ /emul/ia32-linux/usr/bin/gdb loopTest
GNU gdb Red Hat Linux (6.3.0.0-1.132.EL4rh)
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 "/emul/ia32-linux/lib/tls/libthread_db.so.1".

(gdb) b main
Breakpoint 1 at 0x8048384: file loopTest.c, line 6.
(gdb) r
Starting program: /home/admin/loopTest
Killed


We need the following details
1. How to run a i386 compiled program in IA64 bit environment using gdb 
and be able to hit break points?

2.How do we catch a running process in gdb and apply a breakpoint in our 
setup.


The code of C program in question is given below
#include <stdio.h>
int count=0;
void printString();
int main()
{
    printf("unlock\n");
    while(1) {
//do nothing
printString();
//break;
    }
    return 0;
}

void printString() {
    count++;
    printf("count = %d\n",count);
    return;
}

The above c code compiled in i386 environment and the IA64 bit server in 
which we are running this program are attached.

Thanks in Advance,

-S.Balaji