Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 158750 Details for
Bug 247427
utrace: i386 debugger + x86_64 kernel + threaded (i386) inferior = error
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Testcase (`-m32').
debugreg32.c (text/plain), 3.70 KB, created by
Jan Kratochvil
on 2007-07-09 08:50:28 UTC
(
hide
)
Description:
Testcase (`-m32').
Filename:
MIME Type:
Creator:
Jan Kratochvil
Created:
2007-07-09 08:50:28 UTC
Size:
3.70 KB
patch
obsolete
>#include <pthread.h> >#include <assert.h> >#include <unistd.h> >#include <sys/wait.h> >#include <stdio.h> >#include <stdlib.h> >#include <sys/ptrace.h> >#include <stddef.h> >#include <errno.h> > >#ifdef __x86_64__ >#error "-m32 required" >#endif > >#ifndef __i386__ >#error "i386 required" >#endif > >#include <asm/user.h> > >static pid_t child; > >static void *start (void *arg) >{ > for (;;) > pause (); > /* NOTREACHED */ > assert (0); > return arg; >} > >static void >cleanup (void) >{ > if (child != 0) > kill (child, SIGKILL); >} > >static void >handler_fail (int signo) >{ > cleanup (); > > signal (SIGABRT, SIG_DFL); > abort (); >} > >static volatile int handler_ignore_met; > >static void handler_ignore (int signo) >{ > handler_ignore_met++; >} > >static int gs_to_idx (int gs) >{ > switch (gs) > { > case 0x33: > return 6; > /* NOTREACHED */ > case 0x63: > return 12; > /* NOTREACHED */ > } > assert (0); > /* NOTREACHED */ >} > >int main (void) >{ > pthread_t thread1; > pid_t got_pid; > int i, status; > long l; > long debugreg0_orig, gs_orig; > long debugreg0_new, gs_new; > unsigned int desc[4]; > unsigned thread_area_orig; > unsigned thread_area_new; > sigset_t sigset; > > signal (SIGUSR1, handler_ignore); > i = sigemptyset (&sigset); > assert (i == 0); > i = sigaddset (&sigset, SIGUSR1); > assert (i == 0); > i = sigprocmask (SIG_BLOCK, &sigset, NULL); > assert (i == 0); > i = sigemptyset (&sigset); > assert (i == 0); > > child = fork (); > switch (child) > { > case -1: > assert (0); > case 0: > i = pthread_create (&thread1, NULL, start, NULL); /* create1 */ > assert (i == 0); > > i = kill (getppid (), SIGUSR1); > assert (i == 0); > > for (;;) > pause (); > /* NOTREACHED */ > assert (0); > default: > break; > } > atexit (cleanup); > signal (SIGABRT, handler_fail); > signal (SIGINT, handler_fail); > > /* Meet SIGUSR1. */ > i = sigsuspend (&sigset); > assert (i == -1); > assert (errno == EINTR); > assert (handler_ignore_met); > > i = ptrace (PTRACE_ATTACH, child, NULL, NULL); > assert (i == 0); > > got_pid = waitpid (child, &status, 0); > assert (got_pid == child); > assert (WIFSTOPPED (status)); > assert (WSTOPSIG (status) == SIGSTOP); > > debugreg0_orig = ptrace (PTRACE_PEEKUSER, child, (void *) (offsetof (struct user, u_debugreg[0])), NULL); > printf ("u_debugreg[0] == 0x%lx\n", debugreg0_orig); > assert (debugreg0_orig == 0); > gs_orig = ptrace (PTRACE_PEEKUSER, child, (void *) (offsetof (struct user, regs.gs)), NULL); > printf ("gs == 0x%lx\n", gs_orig); > assert (gs_orig != 0); >/* Its definition location varies. */ >#ifndef PTRACE_GET_THREAD_AREA >#define PTRACE_GET_THREAD_AREA 25 >#endif > l = ptrace (PTRACE_GET_THREAD_AREA, child, (void *) gs_to_idx (gs_orig), &desc); > assert (l == 0); > thread_area_orig = desc[1]; > printf ("thread_area == 0x%x\n", thread_area_orig); > > printf ("u_debugreg[0] = 0x01010101\n"); > l = ptrace (PTRACE_POKEUSER, child, (void *) (offsetof (struct user, u_debugreg[0])), (void *) 0x01010101); > assert (l == 0); >#if 0 /* Disallowed. */ > printf ("gs = 0x02020202\n"); > l = ptrace (PTRACE_POKEUSER, child, (void *) (offsetof (struct user, regs.gs)), (void *) 0x02020202); > assert (l == 0); >#endif > > debugreg0_new = ptrace (PTRACE_PEEKUSER, child, (void *) (offsetof (struct user, u_debugreg[0])), NULL); > printf ("u_debugreg[0] == 0x%lx\n", debugreg0_new); > gs_new = ptrace (PTRACE_PEEKUSER, child, (void *) (offsetof (struct user, regs.gs)), NULL); > printf ("gs == 0x%lx\n", gs_new); > l = ptrace (PTRACE_GET_THREAD_AREA, child, (void *) gs_to_idx (gs_orig), &desc); > assert (l == 0); > thread_area_new = desc[1]; > printf ("thread_area == 0x%x\n", thread_area_new); > > assert (gs_new == gs_orig); > assert (debugreg0_new == 0x01010101); > assert (thread_area_new == thread_area_orig); > > puts ("PASS"); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 247427
:
158749
| 158750