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 212201 Details for
Bug 311881
ptrace: 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.
Standalone C testcase.
x86_64-running-i386-debugger.c (text/plain), 4.50 KB, created by
Jan Kratochvil
on 2007-10-01 11:00:43 UTC
(
hide
)
Description:
Standalone C testcase.
Filename:
MIME Type:
Creator:
Jan Kratochvil
Created:
2007-10-01 11:00:43 UTC
Size:
4.50 KB
patch
obsolete
>/* RHEL-5.1 fix: https://bugzilla.redhat.com/show_bug.cgi?id=247427 */ >/* RHEL-4.7?: https://bugzilla.redhat.com/show_bug.cgi?id=311881 */ >/* Fedora fix: https://bugzilla.redhat.com/show_bug.cgi?id=247561 */ >/* F-8 (kernel-2.6.23-0.204.rc8.fc8.x86_64): No bugs. */ >/* F-7 (kernel-2.6.22.9-91.fc7.x86_64): No bugs. */ >/* F-6 (kernel-2.6.22.7-57.fc6.x86_64): No bugs. */ > >/* This software is provided 'as-is', without any express or implied > warranty. In no event will the authors be held liable for any damages > arising from the use of this software. > > Permission is granted to anyone to use this software for any purpose, > including commercial applications, and to alter it and redistribute it > freely. */ > >#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> > >#ifndef __i386__ > >int main (void) >{ > /* No #warning "i386 (or x86_64 with -m32) required" > as we run with -Werror. */ > return 77; >} > >#else /* __i386__ */ > >#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 (signo, SIG_DFL); > raise (signo); >} > >/* Used only for PTRACE_GET_THREAD_AREA. */ >static int gs_to_idx (int gs) >{ > switch (gs) > { > case 0x33: > return 6; > /* NOTREACHED */ > case 0x63: > return 12; > /* NOTREACHED */ > } > assert (0); > /* NOTREACHED */ >} > >static unsigned short local_get_gs (void) >{ > unsigned short gs; > > __asm__ __volatile__ ("movw %%gs, %0" : "=r" (gs)); > > return gs; >} > >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; > > atexit (cleanup); > signal (SIGABRT, handler_fail); > signal (SIGINT, handler_fail); > > child = fork (); > switch (child) > { > case -1: > assert (0); > case 0: > i = pthread_create (&thread1, NULL, start, NULL); /* create1 */ > assert (i == 0); > > /* Sanity check libpthread really set our local %gs. */ > assert (local_get_gs () != 0); > > l = ptrace (PTRACE_TRACEME, 0, NULL, NULL); > assert (l == 0); > > i = raise (SIGUSR1); > assert (i == 0); > > for (;;) > pause (); > /* NOTREACHED */ > assert (0); > default: > break; > } > > got_pid = waitpid (child, &status, 0); > assert (got_pid == child); > assert (WIFSTOPPED (status)); > assert (WSTOPSIG (status) == SIGUSR1); > > debugreg0_orig = ptrace (PTRACE_PEEKUSER, child, (void *) (offsetof (struct user, u_debugreg[0])), NULL); >#if 0 > printf ("u_debugreg[0] == 0x%lx\n", debugreg0_orig); >#endif > assert (debugreg0_orig == 0); > gs_orig = ptrace (PTRACE_PEEKUSER, child, (void *) (offsetof (struct user, regs.gs)), NULL); >#if 0 > printf ("gs == 0x%lx\n", gs_orig); >#endif > /* FIXME: RHEL-4.6 x86_64 fails here. If CHILD's %gs would be 0 we would not > earlier pass the CHILD's LOCAL_GET_GS assertion above. */ > 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]; >#if 0 > printf ("thread_area == 0x%x\n", thread_area_orig); >#endif > >#if 0 > printf ("u_debugreg[0] = 0x01010101\n"); >#endif > 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); >#if 0 > printf ("u_debugreg[0] == 0x%lx\n", debugreg0_new); >#endif > gs_new = ptrace (PTRACE_PEEKUSER, child, (void *) (offsetof (struct user, regs.gs)), NULL); >#if 0 > printf ("gs == 0x%lx\n", gs_new); >#endif > l = ptrace (PTRACE_GET_THREAD_AREA, child, (void *) gs_to_idx (gs_orig), &desc); > assert (l == 0); > thread_area_new = desc[1]; >#if 0 > printf ("thread_area == 0x%x\n", thread_area_new); >#endif > > assert (gs_new == gs_orig); > assert (debugreg0_new == 0x01010101); > assert (thread_area_new == thread_area_orig); > >#if 0 > puts ("PASS"); >#endif > return 0; >} > >#endif /* __i386__ */
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 311881
:
211021
|
212201