GNU Binutils with patches for OS216
Révision | ec1b7090bba48a7a03355b7f76609b58d89c3887 (tree) |
---|---|
l'heure | 2006-04-01 03:15:57 |
Auteur | Daniel Jacobowitz <drow@fals...> |
Commiter | Daniel Jacobowitz |
qPacketInfo support for the branch (pending for mainline)
@@ -189,8 +189,21 @@ static void show_packet_config_cmd (struct packet_config *config); | ||
189 | 189 | |
190 | 190 | static void update_packet_config (struct packet_config *config); |
191 | 191 | |
192 | +static void set_remote_protocol_packet_cmd (char *args, int from_tty, | |
193 | + struct cmd_list_element *c); | |
194 | + | |
195 | +static void show_remote_protocol_packet_cmd (struct ui_file *file, | |
196 | + int from_tty, | |
197 | + struct cmd_list_element *c, | |
198 | + const char *value); | |
199 | + | |
192 | 200 | void _initialize_remote (void); |
193 | 201 | |
202 | +/* For "set remote" and "show remote". */ | |
203 | + | |
204 | +static struct cmd_list_element *remote_set_cmdlist; | |
205 | +static struct cmd_list_element *remote_show_cmdlist; | |
206 | + | |
194 | 207 | /* Description of the remote protocol. Strictly speaking, when the |
195 | 208 | target is open()ed, remote.c should create a per-target description |
196 | 209 | of the remote protocol using that target's architecture. |
@@ -229,6 +242,10 @@ struct remote_state | ||
229 | 242 | /* This is the maximum size (in chars) of a non read/write packet. |
230 | 243 | It is also used as a cap on the size of read/write packets. */ |
231 | 244 | long remote_packet_size; |
245 | + | |
246 | + /* This flag is set if we negotiated packet size explicitly (and | |
247 | + can bypass various heuristics). */ | |
248 | + int explicit_packet_size; | |
232 | 249 | }; |
233 | 250 | |
234 | 251 |
@@ -457,10 +474,13 @@ get_memory_packet_size (struct memory_packet_config *config) | ||
457 | 474 | if (config->size > 0 |
458 | 475 | && what_they_get > config->size) |
459 | 476 | what_they_get = config->size; |
460 | - /* Limit it to the size of the targets ``g'' response. */ | |
461 | - if ((rs->actual_register_packet_size) > 0 | |
462 | - && what_they_get > (rs->actual_register_packet_size)) | |
463 | - what_they_get = (rs->actual_register_packet_size); | |
477 | + | |
478 | + /* Limit it to the size of the targets ``g'' response unless we have | |
479 | + permission from the stub to use a larger packet size. */ | |
480 | + if (!rs->explicit_packet_size | |
481 | + && rs->actual_register_packet_size > 0 | |
482 | + && what_they_get > rs->actual_register_packet_size) | |
483 | + what_they_get = rs->actual_register_packet_size; | |
464 | 484 | } |
465 | 485 | if (what_they_get > MAX_REMOTE_PACKET_SIZE) |
466 | 486 | what_they_get = MAX_REMOTE_PACKET_SIZE; |
@@ -596,6 +616,7 @@ struct packet_config | ||
596 | 616 | char *title; |
597 | 617 | enum auto_boolean detect; |
598 | 618 | enum packet_support support; |
619 | + int must_be_reported; | |
599 | 620 | }; |
600 | 621 | |
601 | 622 | /* Analyze a packet's return value and update the packet config |
@@ -659,11 +680,8 @@ static void | ||
659 | 680 | add_packet_config_cmd (struct packet_config *config, |
660 | 681 | char *name, |
661 | 682 | char *title, |
662 | - cmd_sfunc_ftype *set_func, | |
663 | - show_value_ftype *show_func, | |
664 | - struct cmd_list_element **set_remote_list, | |
665 | - struct cmd_list_element **show_remote_list, | |
666 | - int legacy) | |
683 | + int legacy, | |
684 | + int must_be_reported) | |
667 | 685 | { |
668 | 686 | char *set_doc; |
669 | 687 | char *show_doc; |
@@ -673,6 +691,7 @@ add_packet_config_cmd (struct packet_config *config, | ||
673 | 691 | config->title = title; |
674 | 692 | config->detect = AUTO_BOOLEAN_AUTO; |
675 | 693 | config->support = PACKET_SUPPORT_UNKNOWN; |
694 | + config->must_be_reported = must_be_reported; | |
676 | 695 | set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet", |
677 | 696 | name, title); |
678 | 697 | show_doc = xstrprintf ("Show current use of remote protocol `%s' (%s) packet", |
@@ -681,17 +700,18 @@ add_packet_config_cmd (struct packet_config *config, | ||
681 | 700 | cmd_name = xstrprintf ("%s-packet", title); |
682 | 701 | add_setshow_auto_boolean_cmd (cmd_name, class_obscure, |
683 | 702 | &config->detect, set_doc, show_doc, NULL, /* help_doc */ |
684 | - set_func, show_func, | |
685 | - set_remote_list, show_remote_list); | |
703 | + set_remote_protocol_packet_cmd, | |
704 | + show_remote_protocol_packet_cmd, | |
705 | + &remote_set_cmdlist, &remote_show_cmdlist); | |
686 | 706 | /* set/show remote NAME-packet {auto,on,off} -- legacy. */ |
687 | 707 | if (legacy) |
688 | 708 | { |
689 | 709 | char *legacy_name; |
690 | 710 | legacy_name = xstrprintf ("%s-packet", name); |
691 | 711 | add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, |
692 | - set_remote_list); | |
712 | + &remote_set_cmdlist); | |
693 | 713 | add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, |
694 | - show_remote_list); | |
714 | + &remote_show_cmdlist); | |
695 | 715 | } |
696 | 716 | } |
697 | 717 |
@@ -762,6 +782,7 @@ packet_ok (const char *buf, struct packet_config *config) | ||
762 | 782 | enum { |
763 | 783 | PACKET_vCont = 0, |
764 | 784 | PACKET_X, |
785 | + PACKET_qOffsets, | |
765 | 786 | PACKET_qSymbol, |
766 | 787 | PACKET_P, |
767 | 788 | PACKET_p, |
@@ -1827,14 +1848,20 @@ get_offsets (void) | ||
1827 | 1848 | CORE_ADDR text_addr, data_addr, bss_addr; |
1828 | 1849 | struct section_offsets *offs; |
1829 | 1850 | |
1851 | + if (remote_protocol_packets[PACKET_qOffsets].support == PACKET_DISABLE) | |
1852 | + return; | |
1853 | + | |
1830 | 1854 | putpkt ("qOffsets"); |
1831 | 1855 | getpkt (buf, rs->remote_packet_size, 0); |
1832 | 1856 | |
1833 | - if (buf[0] == '\000') | |
1834 | - return; /* Return silently. Stub doesn't support | |
1835 | - this command. */ | |
1836 | - if (buf[0] == 'E') | |
1857 | + switch (packet_ok (buf, &remote_protocol_packets[PACKET_qOffsets])) | |
1837 | 1858 | { |
1859 | + case PACKET_OK: | |
1860 | + break; | |
1861 | + case PACKET_UNKNOWN: | |
1862 | + return; /* Return silently. Stub doesn't support | |
1863 | + this command. */ | |
1864 | + case PACKET_ERROR: | |
1838 | 1865 | warning (_("Remote failure reply: %s"), buf); |
1839 | 1866 | return; |
1840 | 1867 | } |
@@ -2034,6 +2061,108 @@ Some events may be lost, rendering further debugging impossible.")); | ||
2034 | 2061 | } |
2035 | 2062 | |
2036 | 2063 | static void |
2064 | +remote_query_packet_info (void) | |
2065 | +{ | |
2066 | + struct remote_state *rs = get_remote_state (); | |
2067 | + char *reply, *next; | |
2068 | + int i; | |
2069 | + | |
2070 | + reply = alloca (rs->remote_packet_size); | |
2071 | + | |
2072 | + putpkt ("qPacketInfo"); | |
2073 | + getpkt (reply, rs->remote_packet_size, 0); | |
2074 | + | |
2075 | + next = reply; | |
2076 | + while (*next) | |
2077 | + { | |
2078 | + enum packet_support is_supported; | |
2079 | + char *p, *end, *name_end; | |
2080 | + | |
2081 | + p = next; | |
2082 | + end = strchr (p, ';'); | |
2083 | + if (end == NULL) | |
2084 | + { | |
2085 | + end = p + strlen (p); | |
2086 | + next = end; | |
2087 | + } | |
2088 | + else | |
2089 | + { | |
2090 | + if (end == p) | |
2091 | + { | |
2092 | + warning (_("empty item in \"qPacketInfo\" response")); | |
2093 | + continue; | |
2094 | + } | |
2095 | + | |
2096 | + *end = '\0'; | |
2097 | + next = end + 1; | |
2098 | + } | |
2099 | + | |
2100 | + name_end = strchr (p, '='); | |
2101 | + if (name_end) | |
2102 | + { | |
2103 | + /* This is a name=value entry. */ | |
2104 | + char *value; | |
2105 | + | |
2106 | + value = name_end + 1; | |
2107 | + *name_end = '\0'; | |
2108 | + | |
2109 | + if (strcmp (p, "PacketSize") == 0) | |
2110 | + { | |
2111 | + int packet_size; | |
2112 | + char *value_end; | |
2113 | + | |
2114 | + packet_size = strtol (value, &value_end, 16); | |
2115 | + if (*value != '\0' && *value_end == '\0') | |
2116 | + { | |
2117 | + /* MERGE WARNING: This needs the infinite length | |
2118 | + incoming packet support, which in turn needs us | |
2119 | + to adjust rs->buf_size here. */ | |
2120 | + if (packet_size >= MAX_REMOTE_PACKET_SIZE) | |
2121 | + { | |
2122 | + warning (_("limiting remote suggested packet size (%d bytes) to %d"), | |
2123 | + packet_size, MAX_REMOTE_PACKET_SIZE); | |
2124 | + packet_size = MAX_REMOTE_PACKET_SIZE; | |
2125 | + } | |
2126 | + rs->remote_packet_size = packet_size; | |
2127 | + rs->explicit_packet_size = 1; | |
2128 | + | |
2129 | + continue; | |
2130 | + } | |
2131 | + } | |
2132 | + | |
2133 | + /* Should we even warn about this? For testing, at least, yes. */ | |
2134 | + warning (_("unrecognized item \"%s=%s\" in \"qPacketInfo\" response"), | |
2135 | + p, value); | |
2136 | + continue; | |
2137 | + } | |
2138 | + | |
2139 | + if (end[-1] != '+' && end[-1] != '-') | |
2140 | + { | |
2141 | + warning (_("unrecognized item \"%s\" in \"qPacketInfo\" response"), p); | |
2142 | + continue; | |
2143 | + } | |
2144 | + | |
2145 | + is_supported = (end[-1] == '+') ? PACKET_ENABLE : PACKET_DISABLE; | |
2146 | + end[-1] = '\0'; | |
2147 | + | |
2148 | + for (i = 0; i < PACKET_MAX; i++) | |
2149 | + if (strcmp (remote_protocol_packets[i].name, p) == 0) | |
2150 | + { | |
2151 | + if (remote_protocol_packets[i].support == PACKET_SUPPORT_UNKNOWN) | |
2152 | + remote_protocol_packets[i].support = is_supported; | |
2153 | + break; | |
2154 | + } | |
2155 | + } | |
2156 | + | |
2157 | + /* Default some unmentioned packets to unsupported. */ | |
2158 | + for (i = 0; i < PACKET_MAX; i++) | |
2159 | + if (remote_protocol_packets[i].must_be_reported | |
2160 | + && remote_protocol_packets[i].support == PACKET_SUPPORT_UNKNOWN) | |
2161 | + remote_protocol_packets[i].support = PACKET_DISABLE; | |
2162 | +} | |
2163 | + | |
2164 | + | |
2165 | +static void | |
2037 | 2166 | remote_open_1 (char *name, int from_tty, struct target_ops *target, |
2038 | 2167 | int extended_p, int async_p) |
2039 | 2168 | { |
@@ -2095,6 +2224,11 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target, | ||
2095 | 2224 | use_threadinfo_query = 1; |
2096 | 2225 | use_threadextra_query = 1; |
2097 | 2226 | |
2227 | + /* The first packet we send to the target is the optional "supported | |
2228 | + packets" request. If the target can answer this, it will tell us | |
2229 | + which later probes to skip. */ | |
2230 | + remote_query_packet_info (); | |
2231 | + | |
2098 | 2232 | /* Without this, some commands which require an active target (such |
2099 | 2233 | as kill) won't work. This variable serves (at least) double duty |
2100 | 2234 | as both the pid of the target process (if it has such), and as a |
@@ -3138,7 +3272,7 @@ fetch_registers_using_g (void) | ||
3138 | 3272 | error (_("remote 'g' packet reply is too large: %s"), buf); |
3139 | 3273 | if (buf_len % 2 != 0) |
3140 | 3274 | error (_("Remote 'g' packet reply is of odd length: %s"), buf); |
3141 | - if (REGISTER_BYTES_OK_P () && !REGISTER_BYTES_OK (i)) | |
3275 | + if (REGISTER_BYTES_OK_P () && !REGISTER_BYTES_OK (buf_len / 2)) | |
3142 | 3276 | error (_("Remote 'g' packet reply is too short: %s"), buf); |
3143 | 3277 | |
3144 | 3278 | /* Save the size of the packet sent to us by the target. It is used |
@@ -5485,9 +5619,6 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", | ||
5485 | 5619 | extended_async_remote_ops.to_mourn_inferior = extended_remote_mourn; |
5486 | 5620 | } |
5487 | 5621 | |
5488 | -static struct cmd_list_element *remote_set_cmdlist; | |
5489 | -static struct cmd_list_element *remote_show_cmdlist; | |
5490 | - | |
5491 | 5622 | static void |
5492 | 5623 | set_remote_cmd (char *args, int from_tty) |
5493 | 5624 | { |
@@ -5665,95 +5796,47 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL, | ||
5665 | 5796 | &setlist, &showlist); |
5666 | 5797 | |
5667 | 5798 | add_packet_config_cmd (&remote_protocol_packets[PACKET_X], |
5668 | - "X", "binary-download", | |
5669 | - set_remote_protocol_packet_cmd, | |
5670 | - show_remote_protocol_packet_cmd, | |
5671 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5672 | - 1); | |
5799 | + "X", "binary-download", 1, 0); | |
5673 | 5800 | |
5674 | 5801 | add_packet_config_cmd (&remote_protocol_packets[PACKET_vCont], |
5675 | - "vCont", "verbose-resume", | |
5676 | - set_remote_protocol_packet_cmd, | |
5677 | - show_remote_protocol_packet_cmd, | |
5678 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5679 | - 0); | |
5802 | + "vCont", "verbose-resume", 0, 0); | |
5803 | + | |
5804 | + add_packet_config_cmd (&remote_protocol_packets[PACKET_qOffsets], | |
5805 | + "qOffsets", "load-offsets", 0, 0); | |
5680 | 5806 | |
5681 | 5807 | add_packet_config_cmd (&remote_protocol_packets[PACKET_qSymbol], |
5682 | - "qSymbol", "symbol-lookup", | |
5683 | - set_remote_protocol_packet_cmd, | |
5684 | - show_remote_protocol_packet_cmd, | |
5685 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5686 | - 0); | |
5808 | + "qSymbol", "symbol-lookup", 0, 0); | |
5687 | 5809 | |
5688 | 5810 | add_packet_config_cmd (&remote_protocol_packets[PACKET_P], |
5689 | - "P", "set-register", | |
5690 | - set_remote_protocol_packet_cmd, | |
5691 | - show_remote_protocol_packet_cmd, | |
5692 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5693 | - 1); | |
5811 | + "P", "set-register", 1, 0); | |
5694 | 5812 | |
5695 | 5813 | add_packet_config_cmd (&remote_protocol_packets[PACKET_p], |
5696 | - "p", "fetch-register", | |
5697 | - set_remote_protocol_packet_cmd, | |
5698 | - show_remote_protocol_packet_cmd, | |
5699 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5700 | - 1); | |
5814 | + "p", "fetch-register", 1, 0); | |
5701 | 5815 | |
5702 | 5816 | add_packet_config_cmd (&remote_protocol_packets[PACKET_Z0], |
5703 | - "Z0", "software-breakpoint", | |
5704 | - set_remote_protocol_packet_cmd, | |
5705 | - show_remote_protocol_packet_cmd, | |
5706 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5707 | - 0); | |
5817 | + "Z0", "software-breakpoint", 0, 0); | |
5708 | 5818 | |
5709 | 5819 | add_packet_config_cmd (&remote_protocol_packets[PACKET_Z1], |
5710 | - "Z1", "hardware-breakpoint", | |
5711 | - set_remote_protocol_packet_cmd, | |
5712 | - show_remote_protocol_packet_cmd, | |
5713 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5714 | - 0); | |
5820 | + "Z1", "hardware-breakpoint", 0, 0); | |
5715 | 5821 | |
5716 | 5822 | add_packet_config_cmd (&remote_protocol_packets[PACKET_Z2], |
5717 | - "Z2", "write-watchpoint", | |
5718 | - set_remote_protocol_packet_cmd, | |
5719 | - show_remote_protocol_packet_cmd, | |
5720 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5721 | - 0); | |
5823 | + "Z2", "write-watchpoint", 0, 0); | |
5722 | 5824 | |
5723 | 5825 | add_packet_config_cmd (&remote_protocol_packets[PACKET_Z3], |
5724 | - "Z3", "read-watchpoint", | |
5725 | - set_remote_protocol_packet_cmd, | |
5726 | - show_remote_protocol_packet_cmd, | |
5727 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5728 | - 0); | |
5826 | + "Z3", "read-watchpoint", 0, 0); | |
5729 | 5827 | |
5730 | 5828 | add_packet_config_cmd (&remote_protocol_packets[PACKET_Z4], |
5731 | - "Z4", "access-watchpoint", | |
5732 | - set_remote_protocol_packet_cmd, | |
5733 | - show_remote_protocol_packet_cmd, | |
5734 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5735 | - 0); | |
5829 | + "Z4", "access-watchpoint", 0, 0); | |
5736 | 5830 | |
5737 | 5831 | add_packet_config_cmd (&remote_protocol_packets[PACKET_qPart_auxv], |
5738 | - "qPart_auxv", "read-aux-vector", | |
5739 | - set_remote_protocol_packet_cmd, | |
5740 | - show_remote_protocol_packet_cmd, | |
5741 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5742 | - 0); | |
5832 | + "qPart:auxv", "read-aux-vector", 0, 0); | |
5743 | 5833 | |
5744 | 5834 | add_packet_config_cmd (&remote_protocol_packets[PACKET_qPart_features], |
5745 | - "qPart_features", "target-features", | |
5746 | - set_remote_protocol_packet_cmd, | |
5747 | - show_remote_protocol_packet_cmd, | |
5748 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5749 | - 0); | |
5835 | + "qPart:features", "target-features", 0, 1); | |
5750 | 5836 | |
5751 | 5837 | add_packet_config_cmd (&remote_protocol_packets[PACKET_qGetTLSAddr], |
5752 | 5838 | "qGetTLSAddr", "get-thread-local-storage-address", |
5753 | - set_remote_protocol_packet_cmd, | |
5754 | - show_remote_protocol_packet_cmd, | |
5755 | - &remote_set_cmdlist, &remote_show_cmdlist, | |
5756 | - 0); | |
5839 | + 0, 0); | |
5757 | 5840 | |
5758 | 5841 | /* Keep the old ``set remote Z-packet ...'' working. Each individual |
5759 | 5842 | Z sub-packet has its own set and show commands, but users may |