I'm not going to sit and debug your asm, but you're doing something
wrong because this works.

Here's some 32-bit functions I wrote a while back for a project, it
should help you figure out whats going on.


void
unsetTF(void)
{
        __asm__ __volatile__(
                                "pushf                  \n"
                                "mov    $0x100, %eax    \n"
                                "not    %eax            \n"
                                "andl   (%esp), %eax    \n"
                                "popf                   \n"
        );
}
                                
void
setTF(void)
{
        __asm__ __volatile__(
                                "pushf                  \n"
                                "orl    $0x100, (%esp)  \n"             
                                "popf                   "       
        );

        return;
}

unsigned int
isTFset(void)
{
        unsigned int retval;

        __asm__ __volatile__(
                                "xor    %%eax, %%eax    \n"
                                "pushf                  \n"
                                "pop    %%eax           \n"
                                "and    $0x100, %%eax   \n"
                                : "=a" (retval)
        );

        return retval;

}

On Dec 5, 2007 11:19 AM, ninjaboy <[EMAIL PROTECTED]> wrote:
> 2007/12/5, Rene Herman <[EMAIL PROTECTED]>:
>
> > On 05-12-07 15:23, ninjaboy wrote:
> >
> > > why if i put TF in my prog and install an handler to SIGTRAP the
> > > handler is not caught?
> >
> > Works for me.
> >
> > Rene.
> >
> > /* gcc -W -Wall -o sigtrap sigtrap.c */
> >
> > #include <stdlib.h>
> > #include <stdio.h>
> > #include <signal.h>
> >
> > volatile sig_atomic_t trap;
> >
> > void sigtrap(int signum __attribute__((unused)))
> > {
> >         trap = 1;
> > }
> >
> > int main(void)
> > {
> >         struct sigaction sa;
> >
> >         sa.sa_handler = sigtrap;
> >         sigemptyset(&sa.sa_mask);
> >         sa.sa_flags = 0;
> >
> >         if (sigaction(SIGTRAP, &sa, NULL) < 0) {
> >                 perror("could not install handler");
> >                 return EXIT_FAILURE;
> >         }
> >
> >         asm("int3");
> >
> >         printf("trap = %d\n", (int)trap);
> >         return EXIT_SUCCESS;
> > }
> >
> >
> Ehm... int3 works for me too, the TF doesn't work.
>
>       pushf
>       xor %rax, %rax
>       pop %rax
>       orq $0x100, %rax
>       pushq %rax
>       popf
>
> the trap released here doesn't exec my handler.
>
>
> --
> noone is alone.
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to [EMAIL PROTECTED]
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to