Michael,

Here is a some sample code from my program (It drives a turntable motor).
I'm creating one thread here and I've include two points where it should
stop in the thread function (turntableMonitorThread_process). If the
breakpoint()  function is included in the code, the debugger halts the
program but gdb cannot connect to it. If the breakpoint function is taken
out and the divide by zero (on the next line) is there, the program just
keeps on going and motOut remains 0.0.

Also, I should mention that I get the following warnings when I compile
this:
tt_mod.c: In function `init_module':
tt_mod.c:138: warning: implicit declaration of function `kmalloc'
tt_mod.c: In function `cleanup_module':
tt_mod.c:176: warning: implicit declaration of function `kfree'

I've tried using malloc and free and things are really not happy. I've
also tried to include rtl_cpp.h (where kmalloc and kfree seem to be
defined) but then it complains about redefining a bunch of stuff from
pthread.h.

Thanks in advance,
Tim

-------------CODE BEGIN------------------
#include <linux/module.h>
#include <rtl.h>
#include <time.h>
#include <pthread.h>
#include <math.h>
#include <sys/io.h>
#include <mbuff.h>
#include <rtl_debug.h> /* For debugging support */

#include "some local files"

#define TT_VERBOSE 1

HDCONF * tt_config;
pthread_t turntableMonitorThread;

void * turntableMonitorThread_process(void *t) {
        float vDesired = 0.5; /* 0.5 rps = 30 rpm */
        float vActual = 0.0;
        float error = 0.0;
        float Kp = 1.0;
        float motOut = 1.0;

        breakpoint(); /* Should stop here */

        motOut = vDesired / error; /* Should REALLY stop here */

        hd_getKnobState(tt_config, TT_VERBOSE);
        hd_dumpKnobState(tt_config);
        while (1) {
                vActual = tt_config->vMot;
                error = vDesired - vActual;
                motOut = Kp * error;
                hd_motOut(tt_config, motOut, TT_VERBOSE);
                hd_getKnobState(tt_config, TT_VERBOSE);
                hd_dumpKnobState(tt_config);
                pthread_wait_np();
        }
}

int init_module (void) {
        struct sched_param p_tt;
        pthread_attr_t attr_tt;

        /* Allocate memory for turntable configuration structure */
        tt_config = (HDCONF *) kmalloc(sizeof(HDCONF));

        /* set up the turntableMonitorThread */
        pthread_attr_init(&attr_tt);
        pthread_attr_setfp_np(&attr_tt, 1);

        pthread_create (&turntableMonitorThread, &attr_tt,
                       turntableMonitorThread_process, (void *) 1);
        pthread_make_periodic_np (turntableMonitorThread,
                       gethrtime(), 1000000);
        p_tt.sched_priority = 1;
        pthread_setschedparam (turntableMonitorThread, SCHED_FIFO, &p_tt);

        return 0;
}

void cleanup_module (void) {
        hd_closeSensors(tt_config, TT_VERBOSE);
        kfree(tt_config);
        pthread_delete_np (turntableMonitorThread);
}
---------------------CODE END------------------------------




On Mon, 19 Nov 2001, Michael Barabanov wrote:

> Could you please send me a small example that demonstrates the problem?
>
> Tim Beamish ([EMAIL PROTECTED]) wrote:
> > I'm trying to set a breakpoint for the debugger to stop on. I'm using the
> > breakpoint function in rtl_debug.h. It seems to stop but I can't access
> > the module from GDB (actually DDD) by using the command 'target remote
> > /dev/rtf10'. GDB hangs as it searches and when I kill GDB, it complains
> > that it cannot connect to the remote host.
> >
> > I know that the debugger is working because it will stop my module on a
> > line that has an error in it. I can call the same target command from
> > within GDB this time and it works. I can connect to the code and step
> > through it. But I want to stop before I read that error line so I can see
> > what's happening before it. Does the type of signal sent to a module
> > affect GDB's ability to access it? I think my module gets sent SIGHUP
> > (probably by rtl_debug) when it crashes.
> >
> > I've also tried executing really bad code to try and cause an error but
> > rtlinux seems very happy about accessing portions of memory that I don't
> > own and even dividing by zero (5/0 = 0 in rtlinux)!
> >
> > Any ideas?
> >
> > Tim
> >
> > -- [rtl] ---
> > To unsubscribe:
> > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> > echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> > --
> > For more information on Real-Time Linux see:
> > http://www.rtlinux.org/
>

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to