public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* gdbserver +  pthreads on arm
@ 2005-04-21 21:04 Dave Bacher
  0 siblings, 0 replies; only message in thread
From: Dave Bacher @ 2005-04-21 21:04 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 2923 bytes --]

Hello,
I'm having problems debugging a multithreaded program running on an
embedded system using gdbserver to a i386-linux host. Setting a
breakpoint for a thread other than the main thread causes gdb to stop at
a point where it can not provide any useful information -- i.e., it can
not read the stack frames and can not continue to execute the program.  

On the host:
$ gdb/gdb --version
GNU gdb 6.3
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 "--host=i686-pc-linux-gnu
--target=armv5l-linux".

gdb/gdb ~/Code/MyCode/arm-tests/gdb-thread-test 
GNU gdb 6.3
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 "--host=i686-pc-linux-gnu
--target=armv5l-linux"...
(gdb) target remote 192.168.1.135:4888
Remote debugging using 192.168.1.135:4888
0x40002980 in ?? ()
(gdb) break mainLoop
Breakpoint 1 at 0xabcc: file gdb-thread-test.cpp, line 20.
(gdb) handle nostop SIG32
Signal        Stop      Print   Pass to program Description
SIG32         Yes       Yes     Yes             Real-time event 32
(gdb) c
Continuing.

Program received signal SIG32, Real-time event 32.
Cannot remove breakpoints because program is no longer writable.
It might be running in another process.
Further execution is probably impossible.
Cannot access memory at address 0x400ef82c
(gdb) where
Cannot access memory at address 0x400ef82c
(gdb) quit
The program is running.  Exit anyway? (y or n) y

On the target:
$ ./gdbserver :4888 gdb-thread-test
Process gdb-thread-test created; pid = 236
Listening on port 4888
Remote debugging from host 192.168.1.45
ptrace: bogus breakpoint trap
Killing inferior

The host (i386-linux) gdb was compiled with a different gcc version than
the gdbserver for arm-linux. Should I build a new toolchain for the
arm-linux target?

$ gcc --version
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright (C) 2002 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.

$ arm-linux-gcc --version
2.95.3

The host is running RedHat Linux with a 2.4.20 kernel. The target is
running a linux 2.4.19 kernel from the Familiar linux distribution.

Thanks for any advice,

David Bacher
dbacher@dustnetworks.com

[-- Attachment #2: gdb-thread-test.cpp --]
[-- Type: application/octet-stream, Size: 891 bytes --]

#include <pthread.h>
#include <unistd.h>

#include <string>
#include <iostream>

using namespace std;

bool gDone = false;


int f(int x)
{
    int r = x * 4;
    return r - 3;
}

void* mainLoop(void* arg)
{
    while (!gDone)
    {
        sleep(5);
        cout << "MARK: five seconds" << endl;
    }
    return NULL;
}



int main(int argc, char* argv[])
{
    pthread_t        myThread;
    pthread_attr_t   attr;
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
    
    pthread_create(&myThread, &attr, mainLoop, NULL);
    pthread_attr_destroy(&attr);
    
    
    std::string a = "this is my string";

    cout << "string [" << a.size() << "]: " << a << endl;

    for (int i = 1; i < 10; ++i)
        cout << "f(" << i << "): " << f(i) << endl;

    cin >> a;

    gDone = true;

    pthread_join(myThread, NULL);
    
    return 0;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-04-21 21:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-21 21:04 gdbserver + pthreads on arm Dave Bacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).