OLD | NEW |
1 /* Low level interface for debugging AIX 4.3+ pthreads. | 1 /* Low level interface for debugging AIX 4.3+ pthreads. |
2 | 2 |
3 Copyright (C) 1999-2000, 2002, 2007-2012 Free Software Foundation, | 3 Copyright (C) 1999-2013 Free Software Foundation, Inc. |
4 Inc. | |
5 Written by Nick Duffek <nsd@redhat.com>. | 4 Written by Nick Duffek <nsd@redhat.com>. |
6 | 5 |
7 This file is part of GDB. | 6 This file is part of GDB. |
8 | 7 |
9 This program is free software; you can redistribute it and/or modify | 8 This program is free software; you can redistribute it and/or modify |
10 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
11 the Free Software Foundation; either version 3 of the License, or | 10 the Free Software Foundation; either version 3 of the License, or |
12 (at your option) any later version. | 11 (at your option) any later version. |
13 | 12 |
14 This program is distributed in the hope that it will be useful, | 13 This program is distributed in the hope that it will be useful, |
(...skipping 26 matching lines...) Expand all Loading... |
41 */ | 40 */ |
42 | 41 |
43 #include "defs.h" | 42 #include "defs.h" |
44 #include "gdb_assert.h" | 43 #include "gdb_assert.h" |
45 #include "gdbthread.h" | 44 #include "gdbthread.h" |
46 #include "target.h" | 45 #include "target.h" |
47 #include "inferior.h" | 46 #include "inferior.h" |
48 #include "regcache.h" | 47 #include "regcache.h" |
49 #include "gdbcmd.h" | 48 #include "gdbcmd.h" |
50 #include "ppc-tdep.h" | 49 #include "ppc-tdep.h" |
51 #include "gdb_string.h" | 50 #include <string.h> |
52 #include "observer.h" | 51 #include "observer.h" |
53 | 52 |
54 #include <procinfo.h> | 53 #include <procinfo.h> |
55 #include <sys/types.h> | 54 #include <sys/types.h> |
56 #include <sys/ptrace.h> | 55 #include <sys/ptrace.h> |
57 #include <sys/reg.h> | 56 #include <sys/reg.h> |
58 #include <sched.h> | 57 #include <sched.h> |
59 #include <sys/pthdebug.h> | 58 #include <sys/pthdebug.h> |
60 | 59 |
61 #if !HAVE_DECL_GETTHRDS | 60 #if !HAVE_DECL_GETTHRDS |
62 extern int getthrds (pid_t, struct thrdsinfo64 *, int, pthdb_tid_t *, int); | 61 extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int); |
63 #endif | 62 #endif |
64 | 63 |
65 /* Whether to emit debugging output. */ | 64 /* Whether to emit debugging output. */ |
66 static int debug_aix_thread; | 65 static int debug_aix_thread; |
67 | 66 |
68 /* In AIX 5.1, functions use pthdb_tid_t instead of tid_t. */ | 67 /* In AIX 5.1, functions use pthdb_tid_t instead of tid_t. */ |
69 #ifndef PTHDB_VERSION_3 | 68 #ifndef PTHDB_VERSION_3 |
70 #define pthdb_tid_t tid_t | 69 #define pthdb_tid_t tid_t |
71 #endif | 70 #endif |
72 | 71 |
73 /* Return whether to treat PID as a debuggable thread id. */ | 72 /* Return whether to treat PID as a debuggable thread id. */ |
74 | 73 |
75 #define PD_TID(ptid) (pd_active && ptid_get_tid (ptid) != 0) | 74 #define PD_TID(ptid) (pd_active && ptid_get_tid (ptid) != 0) |
76 | 75 |
77 /* Build a thread ptid. */ | |
78 #define BUILD_THREAD(TID, PID) ptid_build (PID, 0, TID) | |
79 | |
80 /* Build and lwp ptid. */ | |
81 #define BUILD_LWP(LWP, PID) MERGEPID (PID, LWP) | |
82 | |
83 /* pthdb_user_t value that we pass to pthdb functions. 0 causes | 76 /* pthdb_user_t value that we pass to pthdb functions. 0 causes |
84 PTHDB_BAD_USER errors, so use 1. */ | 77 PTHDB_BAD_USER errors, so use 1. */ |
85 | 78 |
86 #define PD_USER 1 | 79 #define PD_USER 1 |
87 | 80 |
88 /* Success and failure values returned by pthdb callbacks. */ | 81 /* Success and failure values returned by pthdb callbacks. */ |
89 | 82 |
90 #define PDC_SUCCESS PTHDB_SUCCESS | 83 #define PDC_SUCCESS PTHDB_SUCCESS |
91 #define PDC_FAILURE PTHDB_CALLBACK | 84 #define PDC_FAILURE PTHDB_CALLBACK |
92 | 85 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 req, id, ret, errno); | 224 req, id, ret, errno); |
232 return ret == -1 ? 0 : 1; | 225 return ret == -1 ? 0 : 1; |
233 } | 226 } |
234 break; | 227 break; |
235 } | 228 } |
236 error (_("aix-thread: ptrace (%d, %d) returned %d (errno = %d %s)"), | 229 error (_("aix-thread: ptrace (%d, %d) returned %d (errno = %d %s)"), |
237 req, id, ret, errno, safe_strerror (errno)); | 230 req, id, ret, errno, safe_strerror (errno)); |
238 return 0; /* Not reached. */ | 231 return 0; /* Not reached. */ |
239 } | 232 } |
240 | 233 |
241 /* Call ptracex (REQ, ID, ADDR, DATA, BUF). Return success. */ | 234 /* Call ptracex (REQ, ID, ADDR, DATA, BUF) or |
| 235 ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64. |
| 236 Return success. */ |
| 237 |
| 238 #ifdef HAVE_PTRACE64 |
| 239 # define ptracex(request, pid, addr, data, buf) \ |
| 240 » ptrace64 (request, pid, addr, data, buf) |
| 241 #endif |
242 | 242 |
243 static int | 243 static int |
244 ptrace64aix (int req, int id, long long addr, int data, int *buf) | 244 ptrace64aix (int req, int id, long long addr, int data, int *buf) |
245 { | 245 { |
246 errno = 0; | 246 errno = 0; |
247 return ptrace_check (req, id, ptracex (req, id, addr, data, buf)); | 247 return ptrace_check (req, id, ptracex (req, id, addr, data, buf)); |
248 } | 248 } |
249 | 249 |
250 /* Call ptrace (REQ, ID, ADDR, DATA, BUF). Return success. */ | 250 /* Call ptrace (REQ, ID, ADDR, DATA, BUF) or |
| 251 ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64. |
| 252 Return success. */ |
| 253 |
| 254 #ifdef HAVE_PTRACE64 |
| 255 # define ptrace(request, pid, addr, data, buf) \ |
| 256 » ptrace64 (request, pid, addr, data, buf) |
| 257 # define addr_ptr long long |
| 258 #else |
| 259 # define addr_ptr int * |
| 260 #endif |
251 | 261 |
252 static int | 262 static int |
253 ptrace32 (int req, int id, int *addr, int data, int *buf) | 263 ptrace32 (int req, int id, addr_ptr addr, int data, int *buf) |
254 { | 264 { |
255 errno = 0; | 265 errno = 0; |
256 return ptrace_check (req, id, | 266 return ptrace_check (req, id, |
257 » » ptrace (req, id, (int *) addr, data, buf)); | 267 » » ptrace (req, id, addr, data, buf)); |
258 } | 268 } |
259 | 269 |
260 /* If *PIDP is a composite process/thread id, convert it to a | 270 /* If *PIDP is a composite process/thread id, convert it to a |
261 process id. */ | 271 process id. */ |
262 | 272 |
263 static void | 273 static void |
264 pid_to_prc (ptid_t *ptidp) | 274 pid_to_prc (ptid_t *ptidp) |
265 { | 275 { |
266 ptid_t ptid; | 276 ptid_t ptid; |
267 | 277 |
268 ptid = *ptidp; | 278 ptid = *ptidp; |
269 if (PD_TID (ptid)) | 279 if (PD_TID (ptid)) |
270 *ptidp = pid_to_ptid (PIDGET (ptid)); | 280 *ptidp = pid_to_ptid (ptid_get_pid (ptid)); |
271 } | 281 } |
272 | 282 |
273 /* pthdb callback: for <i> from 0 to COUNT, set SYMBOLS[<i>].addr to | 283 /* pthdb callback: for <i> from 0 to COUNT, set SYMBOLS[<i>].addr to |
274 the address of SYMBOLS[<i>].name. */ | 284 the address of SYMBOLS[<i>].name. */ |
275 | 285 |
276 static int | 286 static int |
277 pdc_symbol_addrs (pthdb_user_t user, pthdb_symbol_t *symbols, int count) | 287 pdc_symbol_addrs (pthdb_user_t user, pthdb_symbol_t *symbols, int count) |
278 { | 288 { |
279 struct minimal_symbol *ms; | 289 struct minimal_symbol *ms; |
280 int i; | 290 int i; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 { | 365 { |
356 if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL)) | 366 if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL)) |
357 memset (gprs32, 0, sizeof (gprs32)); | 367 memset (gprs32, 0, sizeof (gprs32)); |
358 memcpy (context->gpr, gprs32, sizeof(gprs32)); | 368 memcpy (context->gpr, gprs32, sizeof(gprs32)); |
359 } | 369 } |
360 } | 370 } |
361 | 371 |
362 /* Floating-point registers. */ | 372 /* Floating-point registers. */ |
363 if (flags & PTHDB_FLAG_FPRS) | 373 if (flags & PTHDB_FLAG_FPRS) |
364 { | 374 { |
365 if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL)) | 375 if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL)) |
366 memset (fprs, 0, sizeof (fprs)); | 376 memset (fprs, 0, sizeof (fprs)); |
367 memcpy (context->fpr, fprs, sizeof(fprs)); | 377 memcpy (context->fpr, fprs, sizeof(fprs)); |
368 } | 378 } |
369 | 379 |
370 /* Special-purpose registers. */ | 380 /* Special-purpose registers. */ |
371 if (flags & PTHDB_FLAG_SPRS) | 381 if (flags & PTHDB_FLAG_SPRS) |
372 { | 382 { |
373 if (arch64) | 383 if (arch64) |
374 { | 384 { |
375 if (!ptrace64aix (PTT_READ_SPRS, tid, | 385 if (!ptrace64aix (PTT_READ_SPRS, tid, |
376 (unsigned long) &sprs64, 0, NULL)) | 386 (unsigned long) &sprs64, 0, NULL)) |
377 memset (&sprs64, 0, sizeof (sprs64)); | 387 memset (&sprs64, 0, sizeof (sprs64)); |
378 memcpy (&context->msr, &sprs64, sizeof(sprs64)); | 388 memcpy (&context->msr, &sprs64, sizeof(sprs64)); |
379 } | 389 } |
380 else | 390 else |
381 { | 391 { |
382 » if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL)) | 392 » if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL)) |
383 memset (&sprs32, 0, sizeof (sprs32)); | 393 memset (&sprs32, 0, sizeof (sprs32)); |
384 memcpy (&context->msr, &sprs32, sizeof(sprs32)); | 394 memcpy (&context->msr, &sprs32, sizeof(sprs32)); |
385 } | 395 } |
386 } | 396 } |
387 return 0; | 397 return 0; |
388 } | 398 } |
389 | 399 |
390 /* Write register function should be able to write requested context | 400 /* Write register function should be able to write requested context |
391 information to specified debuggee's kernel thread id. | 401 information to specified debuggee's kernel thread id. |
392 If successful return 0, else non-zero is returned. */ | 402 If successful return 0, else non-zero is returned. */ |
(...skipping 14 matching lines...) Expand all Loading... |
407 fprintf_unfiltered (gdb_stdlog, "pdc_write_regs tid=%d flags=%s\n", | 417 fprintf_unfiltered (gdb_stdlog, "pdc_write_regs tid=%d flags=%s\n", |
408 (int) tid, hex_string (flags)); | 418 (int) tid, hex_string (flags)); |
409 | 419 |
410 /* General-purpose registers. */ | 420 /* General-purpose registers. */ |
411 if (flags & PTHDB_FLAG_GPRS) | 421 if (flags & PTHDB_FLAG_GPRS) |
412 { | 422 { |
413 if (arch64) | 423 if (arch64) |
414 ptrace64aix (PTT_WRITE_GPRS, tid, | 424 ptrace64aix (PTT_WRITE_GPRS, tid, |
415 (unsigned long) context->gpr, 0, NULL); | 425 (unsigned long) context->gpr, 0, NULL); |
416 else | 426 else |
417 » ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL); | 427 » ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) context->gpr, 0, NULL); |
418 } | 428 } |
419 | 429 |
420 /* Floating-point registers. */ | 430 /* Floating-point registers. */ |
421 if (flags & PTHDB_FLAG_FPRS) | 431 if (flags & PTHDB_FLAG_FPRS) |
422 { | 432 { |
423 ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL); | 433 ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) context->fpr, 0, NULL); |
424 } | 434 } |
425 | 435 |
426 /* Special-purpose registers. */ | 436 /* Special-purpose registers. */ |
427 if (flags & PTHDB_FLAG_SPRS) | 437 if (flags & PTHDB_FLAG_SPRS) |
428 { | 438 { |
429 if (arch64) | 439 if (arch64) |
430 { | 440 { |
431 ptrace64aix (PTT_WRITE_SPRS, tid, | 441 ptrace64aix (PTT_WRITE_SPRS, tid, |
432 (unsigned long) &context->msr, 0, NULL); | 442 (unsigned long) &context->msr, 0, NULL); |
433 } | 443 } |
434 else | 444 else |
435 { | 445 { |
436 » ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0, NULL); | 446 » ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &context->msr, 0, NULL); |
437 } | 447 } |
438 } | 448 } |
439 return 0; | 449 return 0; |
440 } | 450 } |
441 | 451 |
442 /* pthdb callback: read LEN bytes from process ADDR into BUF. */ | 452 /* pthdb callback: read LEN bytes from process ADDR into BUF. */ |
443 | 453 |
444 static int | 454 static int |
445 pdc_read_data (pthdb_user_t user, void *buf, | 455 pdc_read_data (pthdb_user_t user, void *buf, |
446 pthdb_addr_t addr, size_t len) | 456 pthdb_addr_t addr, size_t len) |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 } | 651 } |
642 | 652 |
643 /* Search through the list of all kernel threads for the thread | 653 /* Search through the list of all kernel threads for the thread |
644 that has stopped on a SIGTRAP signal, and return its TID. | 654 that has stopped on a SIGTRAP signal, and return its TID. |
645 Return 0 if none found. */ | 655 Return 0 if none found. */ |
646 | 656 |
647 static pthdb_tid_t | 657 static pthdb_tid_t |
648 get_signaled_thread (void) | 658 get_signaled_thread (void) |
649 { | 659 { |
650 struct thrdsinfo64 thrinf; | 660 struct thrdsinfo64 thrinf; |
651 pthdb_tid_t ktid = 0; | 661 tid_t ktid = 0; |
652 int result = 0; | 662 int result = 0; |
653 | 663 |
654 while (1) | 664 while (1) |
655 { | 665 { |
656 if (getthrds (PIDGET (inferior_ptid), &thrinf, | 666 if (getthrds (ptid_get_pid (inferior_ptid), &thrinf, |
657 sizeof (thrinf), &ktid, 1) != 1) | 667 sizeof (thrinf), &ktid, 1) != 1) |
658 break; | 668 break; |
659 | 669 |
660 if (thrinf.ti_cursig == SIGTRAP) | 670 if (thrinf.ti_cursig == SIGTRAP) |
661 return thrinf.ti_tid; | 671 return thrinf.ti_tid; |
662 } | 672 } |
663 | 673 |
664 /* Didn't find any thread stopped on a SIGTRAP signal. */ | 674 /* Didn't find any thread stopped on a SIGTRAP signal. */ |
665 return 0; | 675 return 0; |
666 } | 676 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 /* Accumulate an array of GDB threads sorted by pid. */ | 739 /* Accumulate an array of GDB threads sorted by pid. */ |
730 | 740 |
731 gcount = 0; | 741 gcount = 0; |
732 iterate_over_threads (giter_count, &gcount); | 742 iterate_over_threads (giter_count, &gcount); |
733 g = gbuf = (struct thread_info **) xmalloc (gcount * sizeof *gbuf); | 743 g = gbuf = (struct thread_info **) xmalloc (gcount * sizeof *gbuf); |
734 iterate_over_threads (giter_accum, &g); | 744 iterate_over_threads (giter_accum, &g); |
735 qsort (gbuf, gcount, sizeof *gbuf, gcmp); | 745 qsort (gbuf, gcount, sizeof *gbuf, gcmp); |
736 | 746 |
737 /* Apply differences between the two arrays to GDB's thread list. */ | 747 /* Apply differences between the two arrays to GDB's thread list. */ |
738 | 748 |
739 infpid = PIDGET (inferior_ptid); | 749 infpid = ptid_get_pid (inferior_ptid); |
740 for (pi = gi = 0; pi < pcount || gi < gcount;) | 750 for (pi = gi = 0; pi < pcount || gi < gcount;) |
741 { | 751 { |
742 if (pi == pcount) | 752 if (pi == pcount) |
743 { | 753 { |
744 delete_thread (gbuf[gi]->ptid); | 754 delete_thread (gbuf[gi]->ptid); |
745 gi++; | 755 gi++; |
746 } | 756 } |
747 else if (gi == gcount) | 757 else if (gi == gcount) |
748 { | 758 { |
749 » thread = add_thread (BUILD_THREAD (pbuf[pi].pthid, infpid)); | 759 » thread = add_thread (ptid_build (infpid, 0, pbuf[pi].pthid)); |
750 thread->private = xmalloc (sizeof (struct private_thread_info)); | 760 thread->private = xmalloc (sizeof (struct private_thread_info)); |
751 thread->private->pdtid = pbuf[pi].pdtid; | 761 thread->private->pdtid = pbuf[pi].pdtid; |
752 thread->private->tid = pbuf[pi].tid; | 762 thread->private->tid = pbuf[pi].tid; |
753 pi++; | 763 pi++; |
754 } | 764 } |
755 else | 765 else |
756 { | 766 { |
757 ptid_t pptid, gptid; | 767 ptid_t pptid, gptid; |
758 int cmp_result; | 768 int cmp_result; |
759 | 769 |
760 » pptid = BUILD_THREAD (pbuf[pi].pthid, infpid); | 770 » pptid = ptid_build (infpid, 0, pbuf[pi].pthid); |
761 gptid = gbuf[gi]->ptid; | 771 gptid = gbuf[gi]->ptid; |
762 pdtid = pbuf[pi].pdtid; | 772 pdtid = pbuf[pi].pdtid; |
763 tid = pbuf[pi].tid; | 773 tid = pbuf[pi].tid; |
764 | 774 |
765 cmp_result = ptid_cmp (pptid, gptid); | 775 cmp_result = ptid_cmp (pptid, gptid); |
766 | 776 |
767 if (cmp_result == 0) | 777 if (cmp_result == 0) |
768 { | 778 { |
769 gbuf[gi]->private->pdtid = pdtid; | 779 gbuf[gi]->private->pdtid = pdtid; |
770 gbuf[gi]->private->tid = tid; | 780 gbuf[gi]->private->tid = tid; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 { | 890 { |
881 int status; | 891 int status; |
882 char *stub_name; | 892 char *stub_name; |
883 struct minimal_symbol *ms; | 893 struct minimal_symbol *ms; |
884 | 894 |
885 /* Don't initialize twice. */ | 895 /* Don't initialize twice. */ |
886 if (pd_able) | 896 if (pd_able) |
887 return; | 897 return; |
888 | 898 |
889 /* Check application word size. */ | 899 /* Check application word size. */ |
890 arch64 = register_size (target_gdbarch, 0) == 8; | 900 arch64 = register_size (target_gdbarch (), 0) == 8; |
891 | 901 |
892 /* Check whether the application is pthreaded. */ | 902 /* Check whether the application is pthreaded. */ |
893 stub_name = NULL; | 903 stub_name = NULL; |
894 status = pthdb_session_pthreaded (PD_USER, PTHDB_FLAG_REGS, | 904 status = pthdb_session_pthreaded (PD_USER, PTHDB_FLAG_REGS, |
895 &pd_callbacks, &stub_name); | 905 &pd_callbacks, &stub_name); |
896 if ((status != PTHDB_SUCCESS | 906 if ((status != PTHDB_SUCCESS |
897 && status != PTHDB_NOT_PTHREADED) || !stub_name) | 907 && status != PTHDB_NOT_PTHREADED) || !stub_name) |
898 return; | 908 return; |
899 | 909 |
900 /* Set a breakpoint on the returned stub function. */ | 910 /* Set a breakpoint on the returned stub function. */ |
901 if (!(ms = lookup_minimal_symbol (stub_name, NULL, NULL))) | 911 if (!(ms = lookup_minimal_symbol (stub_name, NULL, NULL))) |
902 return; | 912 return; |
903 pd_brk_addr = SYMBOL_VALUE_ADDRESS (ms); | 913 pd_brk_addr = SYMBOL_VALUE_ADDRESS (ms); |
904 if (!create_thread_event_breakpoint (target_gdbarch, pd_brk_addr)) | 914 if (!create_thread_event_breakpoint (target_gdbarch (), pd_brk_addr)) |
905 return; | 915 return; |
906 | 916 |
907 /* Prepare for thread debugging. */ | 917 /* Prepare for thread debugging. */ |
908 push_target (&aix_thread_ops); | 918 push_target (&aix_thread_ops); |
909 pd_able = 1; | 919 pd_able = 1; |
910 | 920 |
911 /* If we're debugging a core file or an attached inferior, the | 921 /* If we're debugging a core file or an attached inferior, the |
912 pthread library may already have been initialized, so try to | 922 pthread library may already have been initialized, so try to |
913 activate thread debugging. */ | 923 activate thread debugging. */ |
914 pd_activate (1); | 924 pd_activate (1); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 { | 960 { |
951 struct target_ops *beneath = find_target_beneath (ops); | 961 struct target_ops *beneath = find_target_beneath (ops); |
952 | 962 |
953 beneath->to_attach (beneath, args, from_tty); | 963 beneath->to_attach (beneath, args, from_tty); |
954 pd_activate (1); | 964 pd_activate (1); |
955 } | 965 } |
956 | 966 |
957 /* Detach from the process attached to by aix_thread_attach(). */ | 967 /* Detach from the process attached to by aix_thread_attach(). */ |
958 | 968 |
959 static void | 969 static void |
960 aix_thread_detach (struct target_ops *ops, char *args, int from_tty) | 970 aix_thread_detach (struct target_ops *ops, const char *args, int from_tty) |
961 { | 971 { |
962 struct target_ops *beneath = find_target_beneath (ops); | 972 struct target_ops *beneath = find_target_beneath (ops); |
963 | 973 |
964 pd_disable (); | 974 pd_disable (); |
965 beneath->to_detach (beneath, args, from_tty); | 975 beneath->to_detach (beneath, args, from_tty); |
966 } | 976 } |
967 | 977 |
968 /* Tell the inferior process to continue running thread PID if != -1 | 978 /* Tell the inferior process to continue running thread PID if != -1 |
969 and all threads otherwise. */ | 979 and all threads otherwise. */ |
970 | 980 |
971 static void | 981 static void |
972 aix_thread_resume (struct target_ops *ops, | 982 aix_thread_resume (struct target_ops *ops, |
973 ptid_t ptid, int step, enum gdb_signal sig) | 983 ptid_t ptid, int step, enum gdb_signal sig) |
974 { | 984 { |
975 struct thread_info *thread; | 985 struct thread_info *thread; |
976 pthdb_tid_t tid[2]; | 986 pthdb_tid_t tid[2]; |
977 | 987 |
978 if (!PD_TID (ptid)) | 988 if (!PD_TID (ptid)) |
979 { | 989 { |
980 struct cleanup *cleanup = save_inferior_ptid (); | 990 struct cleanup *cleanup = save_inferior_ptid (); |
981 struct target_ops *beneath = find_target_beneath (ops); | 991 struct target_ops *beneath = find_target_beneath (ops); |
982 | 992 |
983 inferior_ptid = pid_to_ptid (PIDGET (inferior_ptid)); | 993 inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid)); |
984 beneath->to_resume (beneath, ptid, step, sig); | 994 beneath->to_resume (beneath, ptid, step, sig); |
985 do_cleanups (cleanup); | 995 do_cleanups (cleanup); |
986 } | 996 } |
987 else | 997 else |
988 { | 998 { |
989 thread = find_thread_ptid (ptid); | 999 thread = find_thread_ptid (ptid); |
990 if (!thread) | 1000 if (!thread) |
991 error (_("aix-thread resume: unknown pthread %ld"), | 1001 error (_("aix-thread resume: unknown pthread %ld"), |
992 » TIDGET (ptid)); | 1002 » ptid_get_lwp (ptid)); |
993 | 1003 |
994 tid[0] = thread->private->tid; | 1004 tid[0] = thread->private->tid; |
995 if (tid[0] == PTHDB_INVALID_TID) | 1005 if (tid[0] == PTHDB_INVALID_TID) |
996 error (_("aix-thread resume: no tid for pthread %ld"), | 1006 error (_("aix-thread resume: no tid for pthread %ld"), |
997 » TIDGET (ptid)); | 1007 » ptid_get_lwp (ptid)); |
998 tid[1] = 0; | 1008 tid[1] = 0; |
999 | 1009 |
1000 if (arch64) | 1010 if (arch64) |
1001 » ptrace64aix (PTT_CONTINUE, tid[0], 1, | 1011 » ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1, |
1002 gdb_signal_to_host (sig), (void *) tid); | 1012 gdb_signal_to_host (sig), (void *) tid); |
1003 else | 1013 else |
1004 » ptrace32 (PTT_CONTINUE, tid[0], (int *) 1, | 1014 » ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1, |
1005 gdb_signal_to_host (sig), (void *) tid); | 1015 gdb_signal_to_host (sig), (void *) tid); |
1006 } | 1016 } |
1007 } | 1017 } |
1008 | 1018 |
1009 /* Wait for thread/process ID if != -1 or for any thread otherwise. | 1019 /* Wait for thread/process ID if != -1 or for any thread otherwise. |
1010 If an error occurs, return -1, else return the pid of the stopped | 1020 If an error occurs, return -1, else return the pid of the stopped |
1011 thread. */ | 1021 thread. */ |
1012 | 1022 |
1013 static ptid_t | 1023 static ptid_t |
1014 aix_thread_wait (struct target_ops *ops, | 1024 aix_thread_wait (struct target_ops *ops, |
1015 ptid_t ptid, struct target_waitstatus *status, int options) | 1025 ptid_t ptid, struct target_waitstatus *status, int options) |
1016 { | 1026 { |
1017 struct cleanup *cleanup = save_inferior_ptid (); | 1027 struct cleanup *cleanup = save_inferior_ptid (); |
1018 struct target_ops *beneath = find_target_beneath (ops); | 1028 struct target_ops *beneath = find_target_beneath (ops); |
1019 | 1029 |
1020 pid_to_prc (&ptid); | 1030 pid_to_prc (&ptid); |
1021 | 1031 |
1022 inferior_ptid = pid_to_ptid (PIDGET (inferior_ptid)); | 1032 inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid)); |
1023 ptid = beneath->to_wait (beneath, ptid, status, options); | 1033 ptid = beneath->to_wait (beneath, ptid, status, options); |
1024 do_cleanups (cleanup); | 1034 do_cleanups (cleanup); |
1025 | 1035 |
1026 if (PIDGET (ptid) == -1) | 1036 if (ptid_get_pid (ptid) == -1) |
1027 return pid_to_ptid (-1); | 1037 return pid_to_ptid (-1); |
1028 | 1038 |
1029 /* Check whether libpthdebug might be ready to be initialized. */ | 1039 /* Check whether libpthdebug might be ready to be initialized. */ |
1030 if (!pd_active && status->kind == TARGET_WAITKIND_STOPPED | 1040 if (!pd_active && status->kind == TARGET_WAITKIND_STOPPED |
1031 && status->value.sig == GDB_SIGNAL_TRAP) | 1041 && status->value.sig == GDB_SIGNAL_TRAP) |
1032 { | 1042 { |
1033 struct regcache *regcache = get_thread_regcache (ptid); | 1043 struct regcache *regcache = get_thread_regcache (ptid); |
1034 struct gdbarch *gdbarch = get_regcache_arch (regcache); | 1044 struct gdbarch *gdbarch = get_regcache_arch (regcache); |
1035 | 1045 |
1036 if (regcache_read_pc (regcache) | 1046 if (regcache_read_pc (regcache) |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 { | 1243 { |
1234 if (arch64) | 1244 if (arch64) |
1235 { | 1245 { |
1236 if (!ptrace64aix (PTT_READ_GPRS, tid, | 1246 if (!ptrace64aix (PTT_READ_GPRS, tid, |
1237 (unsigned long) gprs64, 0, NULL)) | 1247 (unsigned long) gprs64, 0, NULL)) |
1238 memset (gprs64, 0, sizeof (gprs64)); | 1248 memset (gprs64, 0, sizeof (gprs64)); |
1239 supply_gprs64 (regcache, gprs64); | 1249 supply_gprs64 (regcache, gprs64); |
1240 } | 1250 } |
1241 else | 1251 else |
1242 { | 1252 { |
1243 » if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL)) | 1253 » if (!ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL)) |
1244 memset (gprs32, 0, sizeof (gprs32)); | 1254 memset (gprs32, 0, sizeof (gprs32)); |
1245 for (i = 0; i < ppc_num_gprs; i++) | 1255 for (i = 0; i < ppc_num_gprs; i++) |
1246 supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]); | 1256 supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]); |
1247 } | 1257 } |
1248 } | 1258 } |
1249 | 1259 |
1250 /* Floating-point registers. */ | 1260 /* Floating-point registers. */ |
1251 | 1261 |
1252 if (ppc_floating_point_unit_p (gdbarch) | 1262 if (ppc_floating_point_unit_p (gdbarch) |
1253 && (regno == -1 | 1263 && (regno == -1 |
1254 || (regno >= tdep->ppc_fp0_regnum | 1264 || (regno >= tdep->ppc_fp0_regnum |
1255 && regno < tdep->ppc_fp0_regnum + ppc_num_fprs))) | 1265 && regno < tdep->ppc_fp0_regnum + ppc_num_fprs))) |
1256 { | 1266 { |
1257 if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL)) | 1267 if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL)) |
1258 memset (fprs, 0, sizeof (fprs)); | 1268 memset (fprs, 0, sizeof (fprs)); |
1259 supply_fprs (regcache, fprs); | 1269 supply_fprs (regcache, fprs); |
1260 } | 1270 } |
1261 | 1271 |
1262 /* Special-purpose registers. */ | 1272 /* Special-purpose registers. */ |
1263 | 1273 |
1264 if (regno == -1 || special_register_p (gdbarch, regno)) | 1274 if (regno == -1 || special_register_p (gdbarch, regno)) |
1265 { | 1275 { |
1266 if (arch64) | 1276 if (arch64) |
1267 { | 1277 { |
1268 if (!ptrace64aix (PTT_READ_SPRS, tid, | 1278 if (!ptrace64aix (PTT_READ_SPRS, tid, |
1269 (unsigned long) &sprs64, 0, NULL)) | 1279 (unsigned long) &sprs64, 0, NULL)) |
1270 memset (&sprs64, 0, sizeof (sprs64)); | 1280 memset (&sprs64, 0, sizeof (sprs64)); |
1271 supply_sprs64 (regcache, sprs64.pt_iar, sprs64.pt_msr, | 1281 supply_sprs64 (regcache, sprs64.pt_iar, sprs64.pt_msr, |
1272 sprs64.pt_cr, sprs64.pt_lr, sprs64.pt_ctr, | 1282 sprs64.pt_cr, sprs64.pt_lr, sprs64.pt_ctr, |
1273 sprs64.pt_xer, sprs64.pt_fpscr); | 1283 sprs64.pt_xer, sprs64.pt_fpscr); |
1274 } | 1284 } |
1275 else | 1285 else |
1276 { | 1286 { |
1277 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | 1287 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
1278 | 1288 |
1279 » if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL)) | 1289 » if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL)) |
1280 memset (&sprs32, 0, sizeof (sprs32)); | 1290 memset (&sprs32, 0, sizeof (sprs32)); |
1281 supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr, sprs32.pt_cr, | 1291 supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr, sprs32.pt_cr, |
1282 sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer, | 1292 sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer, |
1283 sprs32.pt_fpscr); | 1293 sprs32.pt_fpscr); |
1284 | 1294 |
1285 if (tdep->ppc_mq_regnum >= 0) | 1295 if (tdep->ppc_mq_regnum >= 0) |
1286 regcache_raw_supply (regcache, tdep->ppc_mq_regnum, | 1296 regcache_raw_supply (regcache, tdep->ppc_mq_regnum, |
1287 (char *) &sprs32.pt_mq); | 1297 (char *) &sprs32.pt_mq); |
1288 } | 1298 } |
1289 } | 1299 } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 if (arch64) | 1574 if (arch64) |
1565 { | 1575 { |
1566 /* Pre-fetch: some regs may not be in the cache. */ | 1576 /* Pre-fetch: some regs may not be in the cache. */ |
1567 ptrace64aix (PTT_READ_GPRS, tid, (unsigned long) gprs64, 0, NULL); | 1577 ptrace64aix (PTT_READ_GPRS, tid, (unsigned long) gprs64, 0, NULL); |
1568 fill_gprs64 (regcache, gprs64); | 1578 fill_gprs64 (regcache, gprs64); |
1569 ptrace64aix (PTT_WRITE_GPRS, tid, (unsigned long) gprs64, 0, NULL); | 1579 ptrace64aix (PTT_WRITE_GPRS, tid, (unsigned long) gprs64, 0, NULL); |
1570 } | 1580 } |
1571 else | 1581 else |
1572 { | 1582 { |
1573 /* Pre-fetch: some regs may not be in the cache. */ | 1583 /* Pre-fetch: some regs may not be in the cache. */ |
1574 » ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL); | 1584 » ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL); |
1575 fill_gprs32 (regcache, gprs32); | 1585 fill_gprs32 (regcache, gprs32); |
1576 » ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL); | 1586 » ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) gprs32, 0, NULL); |
1577 } | 1587 } |
1578 } | 1588 } |
1579 | 1589 |
1580 /* Floating-point registers. */ | 1590 /* Floating-point registers. */ |
1581 | 1591 |
1582 if (ppc_floating_point_unit_p (gdbarch) | 1592 if (ppc_floating_point_unit_p (gdbarch) |
1583 && (regno == -1 | 1593 && (regno == -1 |
1584 || (regno >= tdep->ppc_fp0_regnum | 1594 || (regno >= tdep->ppc_fp0_regnum |
1585 && regno < tdep->ppc_fp0_regnum + ppc_num_fprs))) | 1595 && regno < tdep->ppc_fp0_regnum + ppc_num_fprs))) |
1586 { | 1596 { |
1587 /* Pre-fetch: some regs may not be in the cache. */ | 1597 /* Pre-fetch: some regs may not be in the cache. */ |
1588 ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL); | 1598 ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL); |
1589 fill_fprs (regcache, fprs); | 1599 fill_fprs (regcache, fprs); |
1590 ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL); | 1600 ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) fprs, 0, NULL); |
1591 } | 1601 } |
1592 | 1602 |
1593 /* Special-purpose registers. */ | 1603 /* Special-purpose registers. */ |
1594 | 1604 |
1595 if (regno == -1 || special_register_p (gdbarch, regno)) | 1605 if (regno == -1 || special_register_p (gdbarch, regno)) |
1596 { | 1606 { |
1597 if (arch64) | 1607 if (arch64) |
1598 { | 1608 { |
1599 /* Pre-fetch: some registers won't be in the cache. */ | 1609 /* Pre-fetch: some registers won't be in the cache. */ |
1600 ptrace64aix (PTT_READ_SPRS, tid, | 1610 ptrace64aix (PTT_READ_SPRS, tid, |
(...skipping 11 matching lines...) Expand all Loading... |
1612 Use temporaries to work around this problem. Also, add an | 1622 Use temporaries to work around this problem. Also, add an |
1613 assert here to make sure we fail if the system header files | 1623 assert here to make sure we fail if the system header files |
1614 use "unsigned long", and the size of that type is not what | 1624 use "unsigned long", and the size of that type is not what |
1615 the headers expect. */ | 1625 the headers expect. */ |
1616 uint32_t tmp_iar, tmp_msr, tmp_cr, tmp_lr, tmp_ctr, tmp_xer, | 1626 uint32_t tmp_iar, tmp_msr, tmp_cr, tmp_lr, tmp_ctr, tmp_xer, |
1617 tmp_fpscr; | 1627 tmp_fpscr; |
1618 | 1628 |
1619 gdb_assert (sizeof (sprs32.pt_iar) == 4); | 1629 gdb_assert (sizeof (sprs32.pt_iar) == 4); |
1620 | 1630 |
1621 /* Pre-fetch: some registers won't be in the cache. */ | 1631 /* Pre-fetch: some registers won't be in the cache. */ |
1622 » ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL); | 1632 » ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL); |
1623 | 1633 |
1624 fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr, | 1634 fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr, |
1625 &tmp_ctr, &tmp_xer, &tmp_fpscr); | 1635 &tmp_ctr, &tmp_xer, &tmp_fpscr); |
1626 | 1636 |
1627 sprs32.pt_iar = tmp_iar; | 1637 sprs32.pt_iar = tmp_iar; |
1628 sprs32.pt_msr = tmp_msr; | 1638 sprs32.pt_msr = tmp_msr; |
1629 sprs32.pt_cr = tmp_cr; | 1639 sprs32.pt_cr = tmp_cr; |
1630 sprs32.pt_lr = tmp_lr; | 1640 sprs32.pt_lr = tmp_lr; |
1631 sprs32.pt_ctr = tmp_ctr; | 1641 sprs32.pt_ctr = tmp_ctr; |
1632 sprs32.pt_xer = tmp_xer; | 1642 sprs32.pt_xer = tmp_xer; |
1633 sprs32.pt_fpscr = tmp_fpscr; | 1643 sprs32.pt_fpscr = tmp_fpscr; |
1634 | 1644 |
1635 if (tdep->ppc_mq_regnum >= 0) | 1645 if (tdep->ppc_mq_regnum >= 0) |
1636 if (REG_VALID == regcache_register_status (regcache, | 1646 if (REG_VALID == regcache_register_status (regcache, |
1637 tdep->ppc_mq_regnum)) | 1647 tdep->ppc_mq_regnum)) |
1638 regcache_raw_collect (regcache, tdep->ppc_mq_regnum, | 1648 regcache_raw_collect (regcache, tdep->ppc_mq_regnum, |
1639 &sprs32.pt_mq); | 1649 &sprs32.pt_mq); |
1640 | 1650 |
1641 » ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL); | 1651 » ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &sprs32, 0, NULL); |
1642 } | 1652 } |
1643 } | 1653 } |
1644 } | 1654 } |
1645 | 1655 |
1646 /* Store gdb's current view of the register set into the | 1656 /* Store gdb's current view of the register set into the |
1647 thread/process specified by inferior_ptid. */ | 1657 thread/process specified by inferior_ptid. */ |
1648 | 1658 |
1649 static void | 1659 static void |
1650 aix_thread_store_registers (struct target_ops *ops, | 1660 aix_thread_store_registers (struct target_ops *ops, |
1651 struct regcache *regcache, int regno) | 1661 struct regcache *regcache, int regno) |
(...skipping 23 matching lines...) Expand all Loading... |
1675 static LONGEST | 1685 static LONGEST |
1676 aix_thread_xfer_partial (struct target_ops *ops, enum target_object object, | 1686 aix_thread_xfer_partial (struct target_ops *ops, enum target_object object, |
1677 const char *annex, gdb_byte *readbuf, | 1687 const char *annex, gdb_byte *readbuf, |
1678 const gdb_byte *writebuf, | 1688 const gdb_byte *writebuf, |
1679 ULONGEST offset, LONGEST len) | 1689 ULONGEST offset, LONGEST len) |
1680 { | 1690 { |
1681 struct cleanup *old_chain = save_inferior_ptid (); | 1691 struct cleanup *old_chain = save_inferior_ptid (); |
1682 LONGEST xfer; | 1692 LONGEST xfer; |
1683 struct target_ops *beneath = find_target_beneath (ops); | 1693 struct target_ops *beneath = find_target_beneath (ops); |
1684 | 1694 |
1685 inferior_ptid = pid_to_ptid (PIDGET (inferior_ptid)); | 1695 inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid)); |
1686 xfer = beneath->to_xfer_partial (beneath, object, annex, | 1696 xfer = beneath->to_xfer_partial (beneath, object, annex, |
1687 readbuf, writebuf, offset, len); | 1697 readbuf, writebuf, offset, len); |
1688 | 1698 |
1689 do_cleanups (old_chain); | 1699 do_cleanups (old_chain); |
1690 return xfer; | 1700 return xfer; |
1691 } | 1701 } |
1692 | 1702 |
1693 /* Clean up after the inferior exits. */ | 1703 /* Clean up after the inferior exits. */ |
1694 | 1704 |
1695 static void | 1705 static void |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 | 1841 |
1832 /* Module startup initialization function, automagically called by | 1842 /* Module startup initialization function, automagically called by |
1833 init.c. */ | 1843 init.c. */ |
1834 | 1844 |
1835 void _initialize_aix_thread (void); | 1845 void _initialize_aix_thread (void); |
1836 | 1846 |
1837 void | 1847 void |
1838 _initialize_aix_thread (void) | 1848 _initialize_aix_thread (void) |
1839 { | 1849 { |
1840 init_aix_thread_ops (); | 1850 init_aix_thread_ops (); |
1841 add_target (&aix_thread_ops); | 1851 complete_target_initialization (&aix_thread_ops); |
1842 | 1852 |
1843 /* Notice when object files get loaded and unloaded. */ | 1853 /* Notice when object files get loaded and unloaded. */ |
1844 observer_attach_new_objfile (new_objfile); | 1854 observer_attach_new_objfile (new_objfile); |
1845 | 1855 |
1846 add_setshow_boolean_cmd ("aix-thread", class_maintenance, &debug_aix_thread, | 1856 add_setshow_boolean_cmd ("aix-thread", class_maintenance, &debug_aix_thread, |
1847 _("Set debugging of AIX thread module."), | 1857 _("Set debugging of AIX thread module."), |
1848 _("Show debugging of AIX thread module."), | 1858 _("Show debugging of AIX thread module."), |
1849 _("Enables debugging output (used to debug GDB)."), | 1859 _("Enables debugging output (used to debug GDB)."), |
1850 NULL, NULL, | 1860 NULL, NULL, |
1851 /* FIXME: i18n: Debugging of AIX thread | 1861 /* FIXME: i18n: Debugging of AIX thread |
1852 module is \"%d\". */ | 1862 module is \"%d\". */ |
1853 &setdebuglist, &showdebuglist); | 1863 &setdebuglist, &showdebuglist); |
1854 } | 1864 } |
OLD | NEW |