Re: sigtrap and TF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05-12-07 20:19, ninjaboy wrote:

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.

Ah, I just skipped reading the bit with the fucks and the sucks. But, well, works for me again:

$ ./sigtrap
trap = 1
trap = 3
$

Rene.
/* gcc -W -Wall -o sigtrap sigtrap.c */

#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <sys/io.h>

volatile sig_atomic_t trap;

void sigtrap(int signum __attribute__((unused)))
{
	trap++;
}

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);

	asm(	"pushf			\n\t"
		"orl	$0x100, (%esp)	\n\t"
		"popf			");

	asm(	"nop");
	asm(	"nop");

	printf("trap = %d\n", (int)trap);

	return EXIT_SUCCESS;
}

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux