GNU Binutils with patches for OS216
Revisión | a9889169e5b21efb8c42105fc62461be43968d64 (tree) |
---|---|
Tiempo | 2015-10-21 23:37:33 |
Autor | Aleksandar Ristovski <aristovski@qnx....> |
Commiter | Aleksandar Ristovski |
[nto] Fix nto target stopped by watchpoint.
Fix 'stopped by watchpoint' detection: add inferior data, use inferior data
for storing last stopped flags needed for detection.
gdb/ChangeLog:
* nto-procfs.c (procfs_wait): Set stopped_flags nad stopped_pc.
(procfs_stopped_by_watchpoint): Use flags stored in inferior data.
* nto-tdep.c (nto_new_inferior_data_reg): New definition.
(nto_new_inferior_data, nto_inferior_data_cleanup, nto_inferior_data):
New functions.
(_initialize_nto_tdep): New forward declaration, new function.
* nto-tdep.h (struct nto_inferior_data): New struct.
(nto_inferior_data): New function declaration.
@@ -1,3 +1,14 @@ | ||
1 | +2015-10-21 Aleksandar Ristovski <aristovski@qnx.com> | |
2 | + | |
3 | + * nto-procfs.c (procfs_wait): Set stopped_flags nad stopped_pc. | |
4 | + (procfs_stopped_by_watchpoint): Use flags stored in inferior data. | |
5 | + * nto-tdep.c (nto_new_inferior_data_reg): New definition. | |
6 | + (nto_new_inferior_data, nto_inferior_data_cleanup, nto_inferior_data): | |
7 | + New functions. | |
8 | + (_initialize_nto_tdep): New forward declaration, new function. | |
9 | + * nto-tdep.h (struct nto_inferior_data): New struct. | |
10 | + (nto_inferior_data): New function declaration. | |
11 | + | |
1 | 12 | 2015-10-20 Jan Kratochvil <jan.kratochvil@redhat.com> |
2 | 13 | |
3 | 14 | * findvar.c (address_from_register): Check REGNUM validity. |
@@ -784,6 +784,9 @@ procfs_wait (struct target_ops *ops, | ||
784 | 784 | devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0); |
785 | 785 | } |
786 | 786 | |
787 | + nto_inferior_data (NULL)->stopped_flags = status.flags; | |
788 | + nto_inferior_data (NULL)->stopped_pc = status.ip; | |
789 | + | |
787 | 790 | if (status.flags & _DEBUG_FLAG_SSTEP) |
788 | 791 | { |
789 | 792 | ourstatus->kind = TARGET_WAITKIND_STOPPED; |
@@ -1626,5 +1629,21 @@ procfs_insert_hw_watchpoint (struct target_ops *self, | ||
1626 | 1629 | static int |
1627 | 1630 | procfs_stopped_by_watchpoint (struct target_ops *ops) |
1628 | 1631 | { |
1629 | - return 0; | |
1632 | + /* NOTE: nto_stopped_by_watchpoint will be called ONLY while we are | |
1633 | + stopped due to a SIGTRAP. This assumes gdb works in 'all-stop' mode; | |
1634 | + future gdb versions will likely run in 'non-stop' mode in which case | |
1635 | + we will have to store/examine statuses per thread in question. | |
1636 | + Until then, this will work fine. */ | |
1637 | + | |
1638 | + struct inferior *inf = current_inferior (); | |
1639 | + struct nto_inferior_data *inf_data; | |
1640 | + | |
1641 | + gdb_assert (inf != NULL); | |
1642 | + | |
1643 | + inf_data = nto_inferior_data (inf); | |
1644 | + | |
1645 | + return inf_data->stopped_flags | |
1646 | + & (_DEBUG_FLAG_TRACE_RD | |
1647 | + | _DEBUG_FLAG_TRACE_WR | |
1648 | + | _DEBUG_FLAG_TRACE_MODIFY); | |
1630 | 1649 | } |
@@ -46,6 +46,8 @@ static char default_nto_target[] = ""; | ||
46 | 46 | |
47 | 47 | struct nto_target_ops current_nto_target; |
48 | 48 | |
49 | +static const struct inferior_data *nto_inferior_data_reg; | |
50 | + | |
49 | 51 | static char * |
50 | 52 | nto_target (void) |
51 | 53 | { |
@@ -477,3 +479,53 @@ nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack, gdb_byte *readbuf, | ||
477 | 479 | } |
478 | 480 | return len_read; |
479 | 481 | } |
482 | + | |
483 | +/* Allocate new nto_inferior_data object. */ | |
484 | + | |
485 | +static struct nto_inferior_data * | |
486 | +nto_new_inferior_data (void) | |
487 | +{ | |
488 | + struct nto_inferior_data *const inf_data | |
489 | + = XCNEW (struct nto_inferior_data); | |
490 | + | |
491 | + return inf_data; | |
492 | +} | |
493 | + | |
494 | +/* Free inferior data. */ | |
495 | + | |
496 | +static void | |
497 | +nto_inferior_data_cleanup (struct inferior *const inf, void *const dat) | |
498 | +{ | |
499 | + xfree (dat); | |
500 | +} | |
501 | + | |
502 | +/* Return nto_inferior_data for the given INFERIOR. If not yet created, | |
503 | + construct it. */ | |
504 | + | |
505 | +struct nto_inferior_data * | |
506 | +nto_inferior_data (struct inferior *const inferior) | |
507 | +{ | |
508 | + struct inferior *const inf = inferior ? inferior : current_inferior (); | |
509 | + struct nto_inferior_data *inf_data; | |
510 | + | |
511 | + gdb_assert (inf != NULL); | |
512 | + | |
513 | + inf_data = inferior_data (inf, nto_inferior_data_reg); | |
514 | + if (inf_data == NULL) | |
515 | + { | |
516 | + set_inferior_data (inf, nto_inferior_data_reg, | |
517 | + (inf_data = nto_new_inferior_data ())); | |
518 | + } | |
519 | + | |
520 | + return inf_data; | |
521 | +} | |
522 | + | |
523 | +/* Provide a prototype to silence -Wmissing-prototypes. */ | |
524 | +extern initialize_file_ftype _initialize_nto_tdep; | |
525 | + | |
526 | +void | |
527 | +_initialize_nto_tdep (void) | |
528 | +{ | |
529 | + nto_inferior_data_reg | |
530 | + = register_inferior_data_with_cleanup (NULL, nto_inferior_data_cleanup); | |
531 | +} |
@@ -142,6 +142,16 @@ struct private_thread_info | ||
142 | 142 | char name[1]; |
143 | 143 | }; |
144 | 144 | |
145 | +/* Per-inferior data, common for both procfs and remote. */ | |
146 | +struct nto_inferior_data | |
147 | +{ | |
148 | + /* Last stopped flags result from wait function */ | |
149 | + unsigned int stopped_flags; | |
150 | + | |
151 | + /* Last known stopped PC */ | |
152 | + CORE_ADDR stopped_pc; | |
153 | +}; | |
154 | + | |
145 | 155 | /* Generic functions in nto-tdep.c. */ |
146 | 156 | |
147 | 157 | void nto_init_solib_absolute_prefix (void); |
@@ -171,4 +181,7 @@ char *nto_extra_thread_info (struct target_ops *self, struct thread_info *); | ||
171 | 181 | LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR inital_stack, |
172 | 182 | gdb_byte *readbuf, |
173 | 183 | LONGEST len, size_t sizeof_auxv_t); |
184 | + | |
185 | +struct nto_inferior_data *nto_inferior_data (struct inferior *inf); | |
186 | + | |
174 | 187 | #endif |