GNU Binutils with patches for OS216
Revisión | 124aceb46dfd1f836f35d6075ead4e00e705f6f3 (tree) |
---|---|
Tiempo | 2017-09-16 01:02:51 |
Autor | Simon Marchi <simon.marchi@eric...> |
Commiter | Simon Marchi |
gdbserver: Remove thread_to_gdb_id
As explained in the previous patch, the gdb_id concept is no longer
relevant. The function thread_to_gdb_id is trivial, it returns the
thread's ptid. Remove it and replace its usage with ptid_of.
The changes in nto-low.c and lynx-low.c are fairly straightforward, but
I was not able to build test them.
gdb/gdbserver/ChangeLog:
* inferiors.h (thread_to_gdb_id): Remove.
* inferiors.c (thread_to_gdb_id): Remove.
* server.c (handle_qxfer_threads_worker, handle_query): Adjust.
* lynx-low.c (lynx_resume, lynx_wait_1, lynx_fetch_registers,
lynx_store_registers, lynx_read_memory, lynx_write_memory):
Likewise.
* nto-low.c (nto_fetch_registers, nto_store_registers,
nto_stopped_by_watchpoint, nto_stopped_data_address): Likewise.
@@ -1,5 +1,16 @@ | ||
1 | 1 | 2017-09-15 Simon Marchi <simon.marchi@ericsson.com> |
2 | 2 | |
3 | + * inferiors.h (thread_to_gdb_id): Remove. | |
4 | + * inferiors.c (thread_to_gdb_id): Remove. | |
5 | + * server.c (handle_qxfer_threads_worker, handle_query): Adjust. | |
6 | + * lynx-low.c (lynx_resume, lynx_wait_1, lynx_fetch_registers, | |
7 | + lynx_store_registers, lynx_read_memory, lynx_write_memory): | |
8 | + Likewise. | |
9 | + * nto-low.c (nto_fetch_registers, nto_store_registers, | |
10 | + nto_stopped_by_watchpoint, nto_stopped_data_address): Likewise. | |
11 | + | |
12 | +2017-09-15 Simon Marchi <simon.marchi@ericsson.com> | |
13 | + | |
3 | 14 | * inferiors.h (gdb_id_to_thread_id): Remove. |
4 | 15 | * inferiors.c (gdb_id_to_thread_id): Remove. |
5 | 16 | * server.c (process_serial_event): Adjust to gdb_id_to_thread_id |
@@ -121,12 +121,6 @@ add_thread (ptid_t thread_id, void *target_data) | ||
121 | 121 | return new_thread; |
122 | 122 | } |
123 | 123 | |
124 | -ptid_t | |
125 | -thread_to_gdb_id (struct thread_info *thread) | |
126 | -{ | |
127 | - return thread->entry.id; | |
128 | -} | |
129 | - | |
130 | 124 | /* Wrapper around get_first_inferior to return a struct thread_info *. */ |
131 | 125 | |
132 | 126 | struct thread_info * |
@@ -143,8 +143,6 @@ struct process_info *find_process_pid (int pid); | ||
143 | 143 | int have_started_inferiors_p (void); |
144 | 144 | int have_attached_inferiors_p (void); |
145 | 145 | |
146 | -ptid_t thread_to_gdb_id (struct thread_info *); | |
147 | - | |
148 | 146 | void clear_inferiors (void); |
149 | 147 | struct inferior_list_entry *find_inferior |
150 | 148 | (struct inferior_list *, |
@@ -350,7 +350,7 @@ lynx_resume (struct thread_resume *resume_info, size_t n) | ||
350 | 350 | the moment we resume its execution for the first time. It is |
351 | 351 | fine to use the current_thread's ptid in those cases. */ |
352 | 352 | if (ptid_equal (ptid, minus_one_ptid)) |
353 | - ptid = thread_to_gdb_id (current_thread); | |
353 | + ptid = ptid_of (current_thread); | |
354 | 354 | |
355 | 355 | regcache_invalidate_pid (ptid_get_pid (ptid)); |
356 | 356 |
@@ -423,7 +423,7 @@ lynx_wait_1 (ptid_t ptid, struct target_waitstatus *status, int options) | ||
423 | 423 | ptid_t new_ptid; |
424 | 424 | |
425 | 425 | if (ptid_equal (ptid, minus_one_ptid)) |
426 | - pid = lynx_ptid_get_pid (thread_to_gdb_id (current_thread)); | |
426 | + pid = lynx_ptid_get_pid (ptid_of (current_thread)); | |
427 | 427 | else |
428 | 428 | pid = BUILDPID (lynx_ptid_get_pid (ptid), lynx_ptid_get_tid (ptid)); |
429 | 429 |
@@ -612,7 +612,7 @@ static void | ||
612 | 612 | lynx_fetch_registers (struct regcache *regcache, int regno) |
613 | 613 | { |
614 | 614 | struct lynx_regset_info *regset = lynx_target_regsets; |
615 | - ptid_t inferior_ptid = thread_to_gdb_id (current_thread); | |
615 | + ptid_t inferior_ptid = ptid_of (current_thread); | |
616 | 616 | |
617 | 617 | lynx_debug ("lynx_fetch_registers (regno = %d)", regno); |
618 | 618 |
@@ -637,7 +637,7 @@ static void | ||
637 | 637 | lynx_store_registers (struct regcache *regcache, int regno) |
638 | 638 | { |
639 | 639 | struct lynx_regset_info *regset = lynx_target_regsets; |
640 | - ptid_t inferior_ptid = thread_to_gdb_id (current_thread); | |
640 | + ptid_t inferior_ptid = ptid_of (current_thread); | |
641 | 641 | |
642 | 642 | lynx_debug ("lynx_store_registers (regno = %d)", regno); |
643 | 643 |
@@ -673,7 +673,7 @@ lynx_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) | ||
673 | 673 | int buf; |
674 | 674 | const int xfer_size = sizeof (buf); |
675 | 675 | CORE_ADDR addr = memaddr & -(CORE_ADDR) xfer_size; |
676 | - ptid_t inferior_ptid = thread_to_gdb_id (current_thread); | |
676 | + ptid_t inferior_ptid = ptid_of (current_thread); | |
677 | 677 | |
678 | 678 | while (addr < memaddr + len) |
679 | 679 | { |
@@ -706,7 +706,7 @@ lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len) | ||
706 | 706 | int buf; |
707 | 707 | const int xfer_size = sizeof (buf); |
708 | 708 | CORE_ADDR addr = memaddr & -(CORE_ADDR) xfer_size; |
709 | - ptid_t inferior_ptid = thread_to_gdb_id (current_thread); | |
709 | + ptid_t inferior_ptid = ptid_of (current_thread); | |
710 | 710 | |
711 | 711 | while (addr < memaddr + len) |
712 | 712 | { |
@@ -742,7 +742,7 @@ lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len) | ||
742 | 742 | static void |
743 | 743 | lynx_request_interrupt (void) |
744 | 744 | { |
745 | - ptid_t inferior_ptid = thread_to_gdb_id (get_first_thread ()); | |
745 | + ptid_t inferior_ptid = ptid_of (get_first_thread ()); | |
746 | 746 | |
747 | 747 | kill (lynx_ptid_get_pid (inferior_ptid), SIGINT); |
748 | 748 | } |
@@ -620,7 +620,6 @@ nto_fetch_registers (struct regcache *regcache, int regno) | ||
620 | 620 | { |
621 | 621 | int regsize; |
622 | 622 | procfs_greg greg; |
623 | - ptid_t ptid; | |
624 | 623 | |
625 | 624 | TRACE ("%s (regno=%d)\n", __func__, regno); |
626 | 625 | if (regno >= the_low_target.num_regs) |
@@ -631,7 +630,7 @@ nto_fetch_registers (struct regcache *regcache, int regno) | ||
631 | 630 | TRACE ("current_thread is NULL\n"); |
632 | 631 | return; |
633 | 632 | } |
634 | - ptid = thread_to_gdb_id (current_thread); | |
633 | + ptid_t ptid = ptid_of (current_thread); | |
635 | 634 | if (!nto_set_thread (ptid)) |
636 | 635 | return; |
637 | 636 |
@@ -669,7 +668,6 @@ nto_store_registers (struct regcache *regcache, int regno) | ||
669 | 668 | { |
670 | 669 | procfs_greg greg; |
671 | 670 | int err; |
672 | - ptid_t ptid; | |
673 | 671 | |
674 | 672 | TRACE ("%s (regno:%d)\n", __func__, regno); |
675 | 673 |
@@ -678,7 +676,7 @@ nto_store_registers (struct regcache *regcache, int regno) | ||
678 | 676 | TRACE ("current_thread is NULL\n"); |
679 | 677 | return; |
680 | 678 | } |
681 | - ptid = thread_to_gdb_id (current_thread); | |
679 | + ptid_t ptid = ptid_of (current_thread); | |
682 | 680 | if (!nto_set_thread (ptid)) |
683 | 681 | return; |
684 | 682 |
@@ -867,9 +865,7 @@ nto_stopped_by_watchpoint (void) | ||
867 | 865 | TRACE ("%s\n", __func__); |
868 | 866 | if (nto_inferior.ctl_fd != -1 && current_thread != NULL) |
869 | 867 | { |
870 | - ptid_t ptid; | |
871 | - | |
872 | - ptid = thread_to_gdb_id (current_thread); | |
868 | + ptid_t ptid = ptid_of (current_thread); | |
873 | 869 | if (nto_set_thread (ptid)) |
874 | 870 | { |
875 | 871 | const int watchmask = _DEBUG_FLAG_TRACE_RD | _DEBUG_FLAG_TRACE_WR |
@@ -899,9 +895,7 @@ nto_stopped_data_address (void) | ||
899 | 895 | TRACE ("%s\n", __func__); |
900 | 896 | if (nto_inferior.ctl_fd != -1 && current_thread != NULL) |
901 | 897 | { |
902 | - ptid_t ptid; | |
903 | - | |
904 | - ptid = thread_to_gdb_id (current_thread); | |
898 | + ptid_t ptid = ptid_of (current_thread); | |
905 | 899 | |
906 | 900 | if (nto_set_thread (ptid)) |
907 | 901 | { |
@@ -1687,7 +1687,7 @@ handle_qxfer_threads_worker (struct inferior_list_entry *inf, void *arg) | ||
1687 | 1687 | { |
1688 | 1688 | struct thread_info *thread = (struct thread_info *) inf; |
1689 | 1689 | struct buffer *buffer = (struct buffer *) arg; |
1690 | - ptid_t ptid = thread_to_gdb_id (thread); | |
1690 | + ptid_t ptid = ptid_of (thread); | |
1691 | 1691 | char ptid_s[100]; |
1692 | 1692 | int core = target_core_of_thread (ptid); |
1693 | 1693 | char core_s[21]; |
@@ -2171,21 +2171,20 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) | ||
2171 | 2171 | /* Reply the current thread id. */ |
2172 | 2172 | if (strcmp ("qC", own_buf) == 0 && !disable_packet_qC) |
2173 | 2173 | { |
2174 | - ptid_t gdb_id; | |
2174 | + ptid_t ptid; | |
2175 | 2175 | require_running_or_return (own_buf); |
2176 | 2176 | |
2177 | - if (!ptid_equal (general_thread, null_ptid) | |
2178 | - && !ptid_equal (general_thread, minus_one_ptid)) | |
2179 | - gdb_id = general_thread; | |
2177 | + if (general_thread != null_ptid && general_thread != minus_one_ptid) | |
2178 | + ptid = general_thread; | |
2180 | 2179 | else |
2181 | 2180 | { |
2182 | 2181 | thread_ptr = get_first_inferior (&all_threads); |
2183 | - gdb_id = thread_to_gdb_id ((struct thread_info *)thread_ptr); | |
2182 | + ptid = thread_ptr->id; | |
2184 | 2183 | } |
2185 | 2184 | |
2186 | 2185 | sprintf (own_buf, "QC"); |
2187 | 2186 | own_buf += 2; |
2188 | - write_ptid (own_buf, gdb_id); | |
2187 | + write_ptid (own_buf, ptid); | |
2189 | 2188 | return; |
2190 | 2189 | } |
2191 | 2190 |
@@ -2241,28 +2240,22 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) | ||
2241 | 2240 | { |
2242 | 2241 | if (strcmp ("qfThreadInfo", own_buf) == 0) |
2243 | 2242 | { |
2244 | - ptid_t gdb_id; | |
2245 | - | |
2246 | 2243 | require_running_or_return (own_buf); |
2247 | 2244 | thread_ptr = get_first_inferior (&all_threads); |
2248 | 2245 | |
2249 | 2246 | *own_buf++ = 'm'; |
2250 | - gdb_id = thread_to_gdb_id ((struct thread_info *)thread_ptr); | |
2251 | - write_ptid (own_buf, gdb_id); | |
2247 | + write_ptid (own_buf, thread_ptr->id); | |
2252 | 2248 | thread_ptr = thread_ptr->next; |
2253 | 2249 | return; |
2254 | 2250 | } |
2255 | 2251 | |
2256 | 2252 | if (strcmp ("qsThreadInfo", own_buf) == 0) |
2257 | 2253 | { |
2258 | - ptid_t gdb_id; | |
2259 | - | |
2260 | 2254 | require_running_or_return (own_buf); |
2261 | 2255 | if (thread_ptr != NULL) |
2262 | 2256 | { |
2263 | 2257 | *own_buf++ = 'm'; |
2264 | - gdb_id = thread_to_gdb_id ((struct thread_info *)thread_ptr); | |
2265 | - write_ptid (own_buf, gdb_id); | |
2258 | + write_ptid (own_buf, thread_ptr->id); | |
2266 | 2259 | thread_ptr = thread_ptr->next; |
2267 | 2260 | return; |
2268 | 2261 | } |