diff options
-rw-r--r-- | bfd/version.h | 2 | ||||
-rw-r--r-- | binutils/resbin.c | 363 | ||||
-rw-r--r-- | binutils/rescoff.c | 58 | ||||
-rw-r--r-- | gdb/ada-lang.c | 115 | ||||
-rwxr-xr-x | gdb/copyright.py | 101 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/bg-execution-repeat.c | 2 |
6 files changed, 319 insertions, 322 deletions
diff --git a/bfd/version.h b/bfd/version.h index 532112c..e797ad0 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -16,7 +16,7 @@ In releases, the date is not included in either version strings or sonames. */ -#define BFD_VERSION_DATE 20250415 +#define BFD_VERSION_DATE 20250417 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@ #define REPORT_BUGS_TO @report_bugs_to@ diff --git a/binutils/resbin.c b/binutils/resbin.c index 1698e14..98dd68b 100644 --- a/binutils/resbin.c +++ b/binutils/resbin.c @@ -141,7 +141,7 @@ get_unicode (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length, ++c; } - ret = (unichar *) res_alloc ((c + 1) * sizeof (unichar)); + ret = res_alloc ((c + 1) * sizeof (unichar)); for (i = 0; i < c; i++) ret[i] = windres_get_16 (wrbfd, data + i * 2, 2); @@ -198,7 +198,7 @@ bin_to_res_generic (windres_bfd *wrbfd ATTRIBUTE_UNUSED, enum rc_res_type type, { rc_res_resource *r; - r = (rc_res_resource *) res_alloc (sizeof (rc_res_resource)); + r = res_alloc (sizeof (rc_res_resource)); r->type = type; r->u.data.data = data; r->u.data.length = length; @@ -220,13 +220,13 @@ bin_to_res_cursor (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length return NULL; } - c = (rc_cursor *) res_alloc (sizeof (rc_cursor)); + c = res_alloc (sizeof (rc_cursor)); c->xhotspot = windres_get_16 (wrbfd, data, 2); c->yhotspot = windres_get_16 (wrbfd, data + 2, 2); c->length = length - 4; c->data = data + 4; - r = (rc_res_resource *) res_alloc (sizeof *r); + r = res_alloc (sizeof *r); r->type = RES_TYPE_CURSOR; r->u.cursor = c; @@ -242,10 +242,10 @@ bin_to_res_menu (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) rc_menu *m; rc_uint_type version, got; - r = (rc_res_resource *) res_alloc (sizeof *r); + r = res_alloc (sizeof *r); r->type = RES_TYPE_MENU; - m = (rc_menu *) res_alloc (sizeof (rc_menu)); + m = res_alloc (sizeof (rc_menu)); r->u.menu = m; if (length < 2) @@ -301,8 +301,8 @@ bin_to_res_menu (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) /* Convert menu items from binary. */ static rc_menuitem * -bin_to_res_menuitems (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length, - rc_uint_type *got) +bin_to_res_menuitems (windres_bfd *wrbfd, const bfd_byte *data, + rc_uint_type length, rc_uint_type *got) { rc_menuitem *first, **pp; @@ -323,7 +323,7 @@ bin_to_res_menuitems (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type len return NULL; } - mi = (rc_menuitem *) res_alloc (sizeof *mi); + mi = res_alloc (sizeof *mi); mi->state = 0; mi->help = 0; @@ -365,8 +365,8 @@ bin_to_res_menuitems (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type len rc_uint_type subread; mi->id = 0; - mi->popup = bin_to_res_menuitems (wrbfd, data + itemlen, length - itemlen, - &subread); + mi->popup = bin_to_res_menuitems (wrbfd, data + itemlen, + length - itemlen, &subread); if (mi->popup == NULL) return NULL; itemlen += subread; @@ -390,8 +390,8 @@ bin_to_res_menuitems (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type len /* Convert menuex items from binary. */ static rc_menuitem * -bin_to_res_menuexitems (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length, - rc_uint_type *got) +bin_to_res_menuexitems (windres_bfd *wrbfd, const bfd_byte *data, + rc_uint_type length, rc_uint_type *got) { rc_menuitem *first, **pp; @@ -412,7 +412,7 @@ bin_to_res_menuexitems (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type l return NULL; } - mi = (rc_menuitem *) res_alloc (sizeof (rc_menuitem)); + mi = res_alloc (sizeof (rc_menuitem)); mi->type = windres_get_32 (wrbfd, data, 4); mi->state = windres_get_32 (wrbfd, data + 4, 4); mi->id = windres_get_32 (wrbfd, data + 8, 4); @@ -492,7 +492,7 @@ bin_to_res_dialog (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length return NULL; } - d = (rc_dialog *) res_alloc (sizeof (rc_dialog)); + d = res_alloc (sizeof (rc_dialog)); signature = windres_get_16 (wrbfd, data + 2, 2); if (signature != 0xffff) @@ -513,7 +513,7 @@ bin_to_res_dialog (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length return NULL; } - d->ex = (rc_dialog_ex *) res_alloc (sizeof (rc_dialog_ex)); + d->ex = res_alloc (sizeof (rc_dialog_ex)); d->ex->help = windres_get_32 (wrbfd, data + 4, 4); d->exstyle = windres_get_32 (wrbfd, data + 8, 4); d->style = windres_get_32 (wrbfd, data + 12, 4); @@ -602,7 +602,7 @@ bin_to_res_dialog (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length off = (off + 3) &~ 3; - dc = (rc_dialog_control *) res_alloc (sizeof (rc_dialog_control)); + dc = res_alloc (sizeof (rc_dialog_control)); if (d->ex == NULL) { @@ -677,8 +677,7 @@ bin_to_res_dialog (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length return NULL; } - dc->data = ((rc_rcdata_item *) - res_alloc (sizeof (rc_rcdata_item))); + dc->data = res_alloc (sizeof (rc_rcdata_item)); dc->data->next = NULL; dc->data->type = RCDATA_BUFFER; dc->data->u.buffer.length = datalen; @@ -692,7 +691,7 @@ bin_to_res_dialog (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length pp = &dc->next; } - r = (rc_res_resource *) res_alloc (sizeof *r); + r = res_alloc (sizeof *r); r->type = RES_TYPE_DIALOG; r->u.dialog = d; @@ -708,7 +707,7 @@ bin_to_res_string (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length int i; rc_res_resource *r; - st = (rc_stringtable *) res_alloc (sizeof (rc_stringtable)); + st = res_alloc (sizeof (rc_stringtable)); for (i = 0; i < 16; i++) { @@ -733,7 +732,7 @@ bin_to_res_string (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length return NULL; } - s = (unichar *) res_alloc (slen * sizeof (unichar)); + s = res_alloc (slen * sizeof (unichar)); st->strings[i].string = s; for (j = 0; j < slen; j++) @@ -744,7 +743,7 @@ bin_to_res_string (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length length -= 2 + 2 * slen; } - r = (rc_res_resource *) res_alloc (sizeof *r); + r = res_alloc (sizeof *r); r->type = RES_TYPE_STRINGTABLE; r->u.stringtable = st; @@ -754,7 +753,8 @@ bin_to_res_string (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length /* Convert a fontdir resource from binary. */ static rc_res_resource * -bin_to_res_fontdir (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +bin_to_res_fontdir (windres_bfd *wrbfd, const bfd_byte *data, + rc_uint_type length) { rc_uint_type c, i; rc_fontdir *first, **pp; @@ -784,7 +784,7 @@ bin_to_res_fontdir (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt } bfi = (const struct bin_fontdir_item *) data; - fd = (rc_fontdir *) res_alloc (sizeof *fd); + fd = res_alloc (sizeof *fd); fd->index = windres_get_16 (wrbfd, bfi->index, 2); /* To work out the length of the fontdir data, we must get the @@ -827,7 +827,7 @@ bin_to_res_fontdir (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt length -= off; } - r = (rc_res_resource *) res_alloc (sizeof *r); + r = res_alloc (sizeof *r); r->type = RES_TYPE_FONTDIR; r->u.fontdir = first; @@ -837,7 +837,8 @@ bin_to_res_fontdir (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt /* Convert an accelerators resource from binary. */ static rc_res_resource * -bin_to_res_accelerators (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +bin_to_res_accelerators (windres_bfd *wrbfd, const bfd_byte *data, + rc_uint_type length) { rc_accelerator *first, **pp; rc_res_resource *r; @@ -855,7 +856,7 @@ bin_to_res_accelerators (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type return NULL; } - a = (rc_accelerator *) res_alloc (sizeof (rc_accelerator)); + a = res_alloc (sizeof (rc_accelerator)); a->flags = windres_get_16 (wrbfd, data, 2); a->key = windres_get_16 (wrbfd, data + 2, 2); @@ -872,7 +873,7 @@ bin_to_res_accelerators (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length -= 8; } - r = (rc_res_resource *) res_alloc (sizeof (rc_res_resource)); + r = res_alloc (sizeof (rc_res_resource)); r->type = RES_TYPE_ACCELERATOR; r->u.acc = first; @@ -888,14 +889,14 @@ bin_to_res_rcdata (windres_bfd *wrbfd ATTRIBUTE_UNUSED, const bfd_byte *data, rc_rcdata_item *ri; rc_res_resource *r; - ri = (rc_rcdata_item *) res_alloc (sizeof (rc_rcdata_item)); + ri = res_alloc (sizeof (rc_rcdata_item)); ri->next = NULL; ri->type = RCDATA_BUFFER; ri->u.buffer.length = length; ri->u.buffer.data = data; - r = (rc_res_resource *) res_alloc (sizeof *r); + r = res_alloc (sizeof *r); r->type = rctyp; r->u.rcdata = ri; @@ -905,7 +906,8 @@ bin_to_res_rcdata (windres_bfd *wrbfd ATTRIBUTE_UNUSED, const bfd_byte *data, /* Convert a group cursor resource from binary. */ static rc_res_resource * -bin_to_res_group_cursor (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +bin_to_res_group_cursor (windres_bfd *wrbfd, const bfd_byte *data, + rc_uint_type length) { int type, c, i; rc_group_cursor *first, **pp; @@ -942,7 +944,7 @@ bin_to_res_group_cursor (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type return NULL; } - gc = (rc_group_cursor *) res_alloc (sizeof *gc); + gc = res_alloc (sizeof *gc); gc->width = windres_get_16 (wrbfd, data, 2); gc->height = windres_get_16 (wrbfd, data + 2, 2); @@ -959,7 +961,7 @@ bin_to_res_group_cursor (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length -= 14; } - r = (rc_res_resource *) res_alloc (sizeof (rc_res_resource)); + r = res_alloc (sizeof (rc_res_resource)); r->type = RES_TYPE_GROUP_CURSOR; r->u.group_cursor = first; @@ -969,7 +971,8 @@ bin_to_res_group_cursor (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type /* Convert a group icon resource from binary. */ static rc_res_resource * -bin_to_res_group_icon (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +bin_to_res_group_icon (windres_bfd *wrbfd, const bfd_byte *data, + rc_uint_type length) { int type, c, i; rc_group_icon *first, **pp; @@ -1006,7 +1009,7 @@ bin_to_res_group_icon (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type le return NULL; } - gi = (rc_group_icon *) res_alloc (sizeof (rc_group_icon)); + gi = res_alloc (sizeof (rc_group_icon)); gi->width = windres_get_8 (wrbfd, data, 1); gi->height = windres_get_8 (wrbfd, data + 1, 1); @@ -1024,7 +1027,7 @@ bin_to_res_group_icon (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type le length -= 14; } - r = (rc_res_resource *) res_alloc (sizeof *r); + r = res_alloc (sizeof *r); r->type = RES_TYPE_GROUP_ICON; r->u.group_icon = first; @@ -1037,8 +1040,8 @@ bin_to_res_group_icon (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type le to the type, and *OFF to the offset to the children. */ static bool -get_version_header (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length, - const char *key, unichar **pkey, +get_version_header (windres_bfd *wrbfd, const bfd_byte *data, + rc_uint_type length, const char *key, unichar **pkey, rc_uint_type *len, rc_uint_type *vallen, rc_uint_type *type, rc_uint_type *off) { @@ -1099,7 +1102,8 @@ get_version_header (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt /* Convert a version resource from binary. */ static rc_res_resource * -bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length) +bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, + rc_uint_type length) { rc_uint_type verlen, vallen, type, off; rc_fixed_versioninfo *fi; @@ -1125,7 +1129,8 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt return NULL; } - /* PR 27686: Ignore any padding bytes after the end of the version structure. */ + /* PR 27686: Ignore any padding bytes after the end of the version + structure. */ length = verlen; data += off; @@ -1164,7 +1169,7 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt return NULL; } - fi = (rc_fixed_versioninfo *) res_alloc (sizeof (rc_fixed_versioninfo)); + fi = res_alloc (sizeof (rc_fixed_versioninfo)); fi->file_version_ms = windres_get_32 (wrbfd, data + 8, 4); fi->file_version_ls = windres_get_32 (wrbfd, data + 12, 4); @@ -1196,7 +1201,7 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt return NULL; } - vi = (rc_ver_info *) res_alloc (sizeof (rc_ver_info)); + vi = res_alloc (sizeof (rc_ver_info)); ch = windres_get_16 (wrbfd, data + 6, 2); @@ -1238,7 +1243,7 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt return NULL; } - vst = (rc_ver_stringtable *) res_alloc (sizeof (rc_ver_stringtable)); + vst = res_alloc (sizeof (rc_ver_stringtable)); if (!get_version_header (wrbfd, data, length, (const char *) NULL, &vst->language, &stverlen, &vallen, @@ -1256,64 +1261,65 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt length -= off; verlen -= off; - stverlen -= off; + stverlen -= off; - vst->strings = NULL; - ppvs = &vst->strings; + vst->strings = NULL; + ppvs = &vst->strings; - while (stverlen > 0) - { - rc_ver_stringinfo *vs; - rc_uint_type sverlen, vslen, valoff; - - if (length < 8) + while (stverlen > 0) { - toosmall (_("version string")); - return NULL; - } - - vs = (rc_ver_stringinfo *) res_alloc (sizeof (rc_ver_stringinfo)); - - if (!get_version_header (wrbfd, data, length, (const char *) NULL, - &vs->key, &sverlen, &vallen, &type, &off)) - return NULL; - - data += off; - length -= off; - - vs->value = get_unicode (wrbfd, data, length, &vslen); - if (vs->value == NULL) - return NULL; - valoff = vslen * 2 + 2; - valoff = (valoff + 3) & ~3; - - if (off + valoff != sverlen) - { - non_fatal (_("unexpected version string length %ld != %ld + %ld"), - (long) sverlen, (long) off, (long) valoff); - return NULL; + rc_ver_stringinfo *vs; + rc_uint_type sverlen, vslen, valoff; + + if (length < 8) + { + toosmall (_("version string")); + return NULL; + } + + vs = res_alloc (sizeof (rc_ver_stringinfo)); + + if (!get_version_header (wrbfd, data, length, + (const char *) NULL, &vs->key, + &sverlen, &vallen, &type, &off)) + return NULL; + + data += off; + length -= off; + + vs->value = get_unicode (wrbfd, data, length, &vslen); + if (vs->value == NULL) + return NULL; + valoff = vslen * 2 + 2; + valoff = (valoff + 3) & ~3; + + if (off + valoff != sverlen) + { + non_fatal (_("unexpected version string length %ld != %ld + %ld"), + (long) sverlen, (long) off, (long) valoff); + return NULL; + } + + data += valoff; + length -= valoff; + + if (stverlen < sverlen) + { + non_fatal (_("unexpected version string length %ld < %ld"), + (long) verlen, (long) sverlen); + return NULL; + } + stverlen -= sverlen; + verlen -= sverlen; + + vs->next = NULL; + *ppvs = vs; + ppvs = &vs->next; } - data += valoff; - length -= valoff; - - if (stverlen < sverlen) - { - non_fatal (_("unexpected version string length %ld < %ld"), - (long) verlen, (long) sverlen); - return NULL; - } - stverlen -= sverlen; - verlen -= sverlen; - - vs->next = NULL; - *ppvs = vs; - ppvs = &vs->next; - } - - vst->next = NULL; - *ppvst = vst; - ppvst = &vst->next; + vst->next = NULL; + *ppvst = vst; + ppvst = &vst->next; } } else if (ch == 'V') @@ -1358,7 +1364,7 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt return NULL; } - vv = (rc_ver_varinfo *) res_alloc (sizeof (rc_ver_varinfo)); + vv = res_alloc (sizeof (rc_ver_varinfo)); vv->language = windres_get_16 (wrbfd, data, 2); vv->charset = windres_get_16 (wrbfd, data + 2, 2); @@ -1399,11 +1405,11 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt pp = &vi->next; } - v = (rc_versioninfo *) res_alloc (sizeof (rc_versioninfo)); + v = res_alloc (sizeof (rc_versioninfo)); v->fixed = fi; v->var = first; - r = (rc_res_resource *) res_alloc (sizeof *r); + r = res_alloc (sizeof *r); r->type = RES_TYPE_VERSIONINFO; r->u.versioninfo = v; @@ -1419,14 +1425,14 @@ bin_to_res_userdata (windres_bfd *wrbfd ATTRIBUTE_UNUSED, const bfd_byte *data, rc_rcdata_item *ri; rc_res_resource *r; - ri = (rc_rcdata_item *) res_alloc (sizeof (rc_rcdata_item)); + ri = res_alloc (sizeof (rc_rcdata_item)); ri->next = NULL; ri->type = RCDATA_BUFFER; ri->u.buffer.length = length; ri->u.buffer.data = data; - r = (rc_res_resource *) res_alloc (sizeof *r); + r = res_alloc (sizeof *r); r->type = RES_TYPE_USERDATA; r->u.rcdata = ri; @@ -1446,7 +1452,7 @@ bin_to_res_toolbar (windres_bfd *wrbfd, const bfd_byte *data, toosmall (_("toolbar")); return NULL; } - ri = (rc_toolbar *) res_alloc (sizeof (rc_toolbar)); + ri = res_alloc (sizeof (rc_toolbar)); ri->button_width = windres_get_32 (wrbfd, data, 4); ri->button_height = windres_get_32 (wrbfd, data + 4, 4); ri->nitems = windres_get_32 (wrbfd, data + 8, 4); @@ -1455,27 +1461,30 @@ bin_to_res_toolbar (windres_bfd *wrbfd, const bfd_byte *data, data += 12; length -= 12; for (i = 0; i < ri->nitems; i++) - { - rc_toolbar_item *it; - it = (rc_toolbar_item *) res_alloc (sizeof (rc_toolbar_item)); - it->id.named = 0; - if (length < 4) - toosmall (_("toolbar item")); - it->id.u.id = (int) windres_get_32 (wrbfd, data, 4); - it->prev = it->next = NULL; - data += 4; - length -= 4; - if(ri->items) { - rc_toolbar_item *ii = ri->items; - while (ii->next != NULL) - ii = ii->next; - it->prev = ii; - ii->next = it; - } - else - ri->items = it; - } - r = (rc_res_resource *) res_alloc (sizeof *r); + { + rc_toolbar_item *it; + it = res_alloc (sizeof (rc_toolbar_item)); + it->id.named = 0; + if (length < 4) + { + toosmall (_("toolbar item")); + return NULL; + } + it->id.u.id = (int) windres_get_32 (wrbfd, data, 4); + it->prev = it->next = NULL; + data += 4; + length -= 4; + if(ri->items) { + rc_toolbar_item *ii = ri->items; + while (ii->next != NULL) + ii = ii->next; + it->prev = ii; + ii->next = it; + } + else + ri->items = it; + } + r = res_alloc (sizeof *r); r->type = RES_TYPE_TOOLBAR; r->u.toolbar = ri; return r; @@ -1514,7 +1523,8 @@ res_to_bin (windres_bfd *wrbfd, rc_uint_type off, const rc_res_resource *res) case RES_TYPE_FONT: case RES_TYPE_ICON: case RES_TYPE_MESSAGETABLE: - return res_to_bin_generic (wrbfd, off, res->u.data.length, res->u.data.data); + return res_to_bin_generic (wrbfd, off, res->u.data.length, + res->u.data.data); case RES_TYPE_ACCELERATOR: return res_to_bin_accelerator (wrbfd, off, res->u.acc); case RES_TYPE_CURSOR: @@ -1565,13 +1575,13 @@ resid_to_bin (windres_bfd *wrbfd, rc_uint_type off, rc_res_id id) rc_uint_type len = (id.u.n.name ? unichar_len (id.u.n.name) : 0); if (wrbfd) { - bfd_byte *d = (bfd_byte *) reswr_alloc ((len + 1) * sizeof (unichar)); + bfd_byte *d = reswr_alloc ((len + 1) * sizeof (unichar)); rc_uint_type i; for (i = 0; i < len; i++) windres_put_16 (wrbfd, d + (i * sizeof (unichar)), id.u.n.name[i]); windres_put_16 (wrbfd, d + (len * sizeof (unichar)), 0); set_windres_bfd_content (wrbfd, d, off, (len + 1) * sizeof (unichar)); - } + } off += (rc_uint_type) ((len + 1) * sizeof (unichar)); } return off; @@ -1592,7 +1602,7 @@ unicode_to_bin (windres_bfd *wrbfd, rc_uint_type off, const unichar *str) { bfd_byte *d; rc_uint_type i; - d = (bfd_byte *) reswr_alloc ( (len + 1) * sizeof (unichar)); + d = reswr_alloc ((len + 1) * sizeof (unichar)); for (i = 0; i < len; i++) windres_put_16 (wrbfd, d + (i * sizeof (unichar)), str[i]); windres_put_16 (wrbfd, d + (len * sizeof (unichar)), 0); @@ -1617,12 +1627,13 @@ res_to_bin_accelerator (windres_bfd *wrbfd, rc_uint_type off, { struct bin_accelerator ba; - windres_put_16 (wrbfd, ba.flags, a->flags | (a->next != NULL ? 0 : ACC_LAST)); + windres_put_16 (wrbfd, ba.flags, + a->flags | (a->next != NULL ? 0 : ACC_LAST)); windres_put_16 (wrbfd, ba.key, a->key); windres_put_16 (wrbfd, ba.id, a->id); windres_put_16 (wrbfd, ba.pad, 0); set_windres_bfd_content (wrbfd, &ba, off, BIN_ACCELERATOR_SIZE); - } + } off += BIN_ACCELERATOR_SIZE; } return off; @@ -1641,7 +1652,8 @@ res_to_bin_cursor (windres_bfd *wrbfd, rc_uint_type off, const rc_cursor *c) windres_put_16 (wrbfd, bc.yhotspot, c->yhotspot); set_windres_bfd_content (wrbfd, &bc, off, BIN_CURSOR_SIZE); if (c->length) - set_windres_bfd_content (wrbfd, c->data, off + BIN_CURSOR_SIZE, c->length); + set_windres_bfd_content (wrbfd, c->data, off + BIN_CURSOR_SIZE, + c->length); } off = (off + BIN_CURSOR_SIZE + (rc_uint_type) c->length); return off; @@ -1671,8 +1683,9 @@ res_to_bin_group_cursor (windres_bfd *wrbfd, rc_uint_type off, windres_put_16 (wrbfd, bgci.bits, gc->bits); windres_put_32 (wrbfd, bgci.bytes, gc->bytes); windres_put_16 (wrbfd, bgci.index, gc->index); - set_windres_bfd_content (wrbfd, &bgci, off, BIN_GROUP_CURSOR_ITEM_SIZE); - } + set_windres_bfd_content (wrbfd, &bgci, off, + BIN_GROUP_CURSOR_ITEM_SIZE); + } off += BIN_GROUP_CURSOR_ITEM_SIZE; } @@ -1705,17 +1718,17 @@ res_to_bin_dialog (windres_bfd *wrbfd, rc_uint_type off, const rc_dialog *dialog if (wrbfd) { - if (! dialogex) - { + if (! dialogex) + { windres_put_32 (wrbfd, bd.style, dialog->style); windres_put_32 (wrbfd, bd.exstyle, dialog->exstyle); windres_put_16 (wrbfd, bd.x, dialog->x); windres_put_16 (wrbfd, bd.y, dialog->y); windres_put_16 (wrbfd, bd.width, dialog->width); windres_put_16 (wrbfd, bd.height, dialog->height); - } - else - { + } + else + { windres_put_16 (wrbfd, bdx.sig1, 1); windres_put_16 (wrbfd, bdx.sig2, 0xffff); windres_put_32 (wrbfd, bdx.help, (dialog->ex ? dialog->ex->help : 0)); @@ -1748,9 +1761,12 @@ res_to_bin_dialog (windres_bfd *wrbfd, rc_uint_type off, const rc_dialog *dialog { struct bin_dialogexfont bdxf; windres_put_16 (wrbfd, bdxf.pointsize, dialog->pointsize); - windres_put_16 (wrbfd, bdxf.weight, (dialog->ex == NULL ? 0 : dialog->ex->weight)); - windres_put_8 (wrbfd, bdxf.italic, (dialog->ex == NULL ? 0 : dialog->ex->italic)); - windres_put_8 (wrbfd, bdxf.charset, (dialog->ex == NULL ? 1 : dialog->ex->charset)); + windres_put_16 (wrbfd, bdxf.weight, + dialog->ex == NULL ? 0 : dialog->ex->weight); + windres_put_8 (wrbfd, bdxf.italic, + dialog->ex == NULL ? 0 : dialog->ex->italic); + windres_put_8 (wrbfd, bdxf.charset, + dialog->ex == NULL ? 1 : dialog->ex->charset); set_windres_bfd_content (wrbfd, &bdxf, off, BIN_DIALOGEXFONT_SIZE); } } @@ -1764,8 +1780,8 @@ res_to_bin_dialog (windres_bfd *wrbfd, rc_uint_type off, const rc_dialog *dialog off += (4 - ((off - off_delta) & 3)) & 3; if (wrbfd) { - if (! dialogex) - { + if (! dialogex) + { struct bin_dialog_control bdc; windres_put_32 (wrbfd, bdc.style, dc->style); @@ -1775,10 +1791,11 @@ res_to_bin_dialog (windres_bfd *wrbfd, rc_uint_type off, const rc_dialog *dialog windres_put_16 (wrbfd, bdc.width, dc->width); windres_put_16 (wrbfd, bdc.height, dc->height); windres_put_16 (wrbfd, bdc.id, dc->id); - set_windres_bfd_content (wrbfd, &bdc, off, BIN_DIALOG_CONTROL_SIZE); - } - else - { + set_windres_bfd_content (wrbfd, &bdc, off, + BIN_DIALOG_CONTROL_SIZE); + } + else + { struct bin_dialogex_control bdc; windres_put_32 (wrbfd, bdc.help, dc->help); @@ -1789,11 +1806,11 @@ res_to_bin_dialog (windres_bfd *wrbfd, rc_uint_type off, const rc_dialog *dialog windres_put_16 (wrbfd, bdc.width, dc->width); windres_put_16 (wrbfd, bdc.height, dc->height); windres_put_32 (wrbfd, bdc.id, dc->id); - set_windres_bfd_content (wrbfd, &bdc, off, BIN_DIALOGEX_CONTROL_SIZE); + set_windres_bfd_content (wrbfd, &bdc, off, + BIN_DIALOGEX_CONTROL_SIZE); } } - off += (dialogex != 0 ? BIN_DIALOGEX_CONTROL_SIZE : BIN_DIALOG_CONTROL_SIZE); - + off += dialogex != 0 ? BIN_DIALOGEX_CONTROL_SIZE : BIN_DIALOG_CONTROL_SIZE; off = resid_to_bin (wrbfd, off, dc->class); off = resid_to_bin (wrbfd, off, dc->text); @@ -1835,7 +1852,8 @@ res_to_bin_dialog (windres_bfd *wrbfd, rc_uint_type off, const rc_dialog *dialog /* Convert a fontdir resource to binary. */ static rc_uint_type -res_to_bin_fontdir (windres_bfd *wrbfd, rc_uint_type off, const rc_fontdir *fontdirs) +res_to_bin_fontdir (windres_bfd *wrbfd, rc_uint_type off, + const rc_fontdir *fontdirs) { rc_uint_type start; int c; @@ -1869,7 +1887,8 @@ res_to_bin_fontdir (windres_bfd *wrbfd, rc_uint_type off, const rc_fontdir *font /* Convert a group icon resource to binary. */ static rc_uint_type -res_to_bin_group_icon (windres_bfd *wrbfd, rc_uint_type off, const rc_group_icon *group_icons) +res_to_bin_group_icon (windres_bfd *wrbfd, rc_uint_type off, + const rc_group_icon *group_icons) { rc_uint_type start; struct bin_group_icon bgi; @@ -1919,21 +1938,21 @@ res_to_bin_menu (windres_bfd *wrbfd, rc_uint_type off, const rc_menu *menu) if (wrbfd) { - if (! menuex) - { + if (! menuex) + { struct bin_menu bm; windres_put_16 (wrbfd, bm.sig1, 0); windres_put_16 (wrbfd, bm.sig2, 0); set_windres_bfd_content (wrbfd, &bm, off, BIN_MENU_SIZE); - } - else - { + } + else + { struct bin_menuex bm; windres_put_16 (wrbfd, bm.sig1, 1); windres_put_16 (wrbfd, bm.sig2, 4); windres_put_32 (wrbfd, bm.help, menu->help); set_windres_bfd_content (wrbfd, &bm, off, BIN_MENUEX_SIZE); - } + } } off += (menuex != 0 ? BIN_MENUEX_SIZE : BIN_MENU_SIZE); if (! menuex) @@ -1950,7 +1969,8 @@ res_to_bin_menu (windres_bfd *wrbfd, rc_uint_type off, const rc_menu *menu) /* Convert menu items to binary. */ static rc_uint_type -res_to_bin_menuitems (windres_bfd *wrbfd, rc_uint_type off, const rc_menuitem *items) +res_to_bin_menuitems (windres_bfd *wrbfd, rc_uint_type off, + const rc_menuitem *items) { const rc_menuitem *mi; @@ -1990,7 +2010,8 @@ res_to_bin_menuitems (windres_bfd *wrbfd, rc_uint_type off, const rc_menuitem *i /* Convert menuex items to binary. */ static rc_uint_type -res_to_bin_menuexitems (windres_bfd *wrbfd, rc_uint_type off, const rc_menuitem *items) +res_to_bin_menuexitems (windres_bfd *wrbfd, rc_uint_type off, + const rc_menuitem *items) { rc_uint_type off_delta = off; const rc_menuitem *mi; @@ -2043,7 +2064,8 @@ res_to_bin_menuexitems (windres_bfd *wrbfd, rc_uint_type off, const rc_menuitem to binary. */ static rc_uint_type -res_to_bin_rcdata (windres_bfd *wrbfd, rc_uint_type off, const rc_rcdata_item *items) +res_to_bin_rcdata (windres_bfd *wrbfd, rc_uint_type off, + const rc_rcdata_item *items) { const rc_rcdata_item *ri; @@ -2089,9 +2111,10 @@ res_to_bin_rcdata (windres_bfd *wrbfd, rc_uint_type off, const rc_rcdata_item *i { rc_uint_type i; - hp = (bfd_byte *) reswr_alloc (len); + hp = reswr_alloc (len); for (i = 0; i < ri->u.wstring.length; i++) - windres_put_16 (wrbfd, hp + i * sizeof (unichar), ri->u.wstring.w[i]); + windres_put_16 (wrbfd, hp + i * sizeof (unichar), + ri->u.wstring.w[i]); } break; case RCDATA_BUFFER: @@ -2128,7 +2151,7 @@ res_to_bin_stringtable (windres_bfd *wrbfd, rc_uint_type off, bfd_byte *hp; rc_uint_type j; - hp = (bfd_byte *) reswr_alloc (length); + hp = reswr_alloc (length); windres_put_16 (wrbfd, hp, slen); for (j = 0; j < slen; j++) @@ -2155,7 +2178,7 @@ string_to_unicode_bin (windres_bfd *wrbfd, rc_uint_type off, const char *s) rc_uint_type i; bfd_byte *hp; - hp = (bfd_byte *) reswr_alloc ((len + 1) * sizeof (unichar)); + hp = reswr_alloc ((len + 1) * sizeof (unichar)); for (i = 0; i < len; i++) windres_put_16 (wrbfd, hp + i * 2, s[i]); @@ -2182,7 +2205,7 @@ res_to_bin_toolbar (windres_bfd *wrbfd, rc_uint_type off, rc_toolbar *tb) bfd_byte *ids; rc_uint_type i = 0; - ids = (bfd_byte *) reswr_alloc (tb->nitems * 4); + ids = reswr_alloc (tb->nitems * 4); it=tb->items; while(it != NULL) { @@ -2221,7 +2244,7 @@ res_to_bin_versioninfo (windres_bfd *wrbfd, rc_uint_type off, struct bin_fixed_versioninfo bfv; const rc_fixed_versioninfo *fi; - fi = versioninfo->fixed; + fi = versioninfo->fixed; windres_put_32 (wrbfd, bfv.sig1, 0xfeef04bd); windres_put_32 (wrbfd, bfv.sig2, 0x10000); windres_put_32 (wrbfd, bfv.file_version, fi->file_version_ms); @@ -2348,13 +2371,13 @@ res_to_bin_versioninfo (windres_bfd *wrbfd, rc_uint_type off, off += 4; } if (wrbfd) - { + { windres_put_16 (wrbfd, bvvd.size, off - vvd_off); windres_put_16 (wrbfd, bvvd.sig1, off - vvvd_off); windres_put_16 (wrbfd, bvvd.sig2, 0); set_windres_bfd_content (wrbfd, &bvvd, vvd_off, BIN_VER_INFO_SIZE); - } + } break; } @@ -2375,7 +2398,7 @@ res_to_bin_versioninfo (windres_bfd *wrbfd, rc_uint_type off, windres_put_16 (wrbfd, bvi.size, off - start); windres_put_16 (wrbfd, bvi.fixed_size, versioninfo->fixed == NULL ? 0 - : BIN_FIXED_VERSIONINFO_SIZE); + : BIN_FIXED_VERSIONINFO_SIZE); windres_put_16 (wrbfd, bvi.sig2, 0); set_windres_bfd_content (wrbfd, &bvi, start, BIN_VER_INFO_SIZE); } diff --git a/binutils/rescoff.c b/binutils/rescoff.c index 98e5eb0..88b5f34 100644 --- a/binutils/rescoff.c +++ b/binutils/rescoff.c @@ -218,7 +218,8 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data, return NULL; } - if ((size_t) (flaginfo->data_end - data) < sizeof (struct extern_res_directory)) + size_t data_len = flaginfo->data_end - data; + if (data_len < sizeof (struct extern_res_directory)) { overrun (flaginfo, _("directory")); return NULL; @@ -249,7 +250,8 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data, const bfd_byte *ers; int length, j; - if ((const bfd_byte *) ere >= flaginfo->data_end) + if ((const bfd_byte *) ere > flaginfo->data_end + || flaginfo->data_end - (const bfd_byte *) ere < 8) { overrun (flaginfo, _("named directory entry")); return NULL; @@ -261,31 +263,32 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data, /* For some reason the high bit in NAME is set. */ name &=~ 0x80000000; - if (name > (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + if (name > data_len) { overrun (flaginfo, _("directory entry name")); return NULL; } ers = flaginfo->data + name; - + if (flaginfo->data_end - ers < 2) + { + overrun (flaginfo, _("resource name")); + return NULL; + } + length = windres_get_16 (wrbfd, ers, 2); + /* PR 17512: file: 05dc4a16. */ + if (length * 2 + 4 > flaginfo->data_end - ers) + { + overrun (flaginfo, _("resource name")); + return NULL; + } re = (rc_res_entry *) res_alloc (sizeof *re); re->next = NULL; re->id.named = 1; - length = windres_get_16 (wrbfd, ers, 2); re->id.u.n.length = length; re->id.u.n.name = (unichar *) res_alloc (length * sizeof (unichar)); for (j = 0; j < length; j++) - { - /* PR 17512: file: 05dc4a16. */ - if (length < 0 || ers >= flaginfo->data_end - || ers + j * 2 + 4 >= flaginfo->data_end) - { - overrun (flaginfo, _("resource name")); - return NULL; - } - re->id.u.n.name[j] = windres_get_16 (wrbfd, ers + j * 2 + 2, 2); - } + re->id.u.n.name[j] = windres_get_16 (wrbfd, ers + j * 2 + 2, 2); if (level == 0) type = &re->id; @@ -293,24 +296,25 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data, if ((rva & 0x80000000) != 0) { rva &=~ 0x80000000; - if (rva >= (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + if (rva >= data_len) { overrun (flaginfo, _("named subdirectory")); return NULL; } re->subdir = 1; - re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo, type, - level + 1); + re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo, + type, level + 1); } else { - if (rva >= (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + if (rva >= data_len) { overrun (flaginfo, _("named resource")); return NULL; } re->subdir = 0; - re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva, flaginfo, type); + re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva, + flaginfo, type); } *pp = re; @@ -322,7 +326,8 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data, unsigned long name, rva; rc_res_entry *re; - if ((const bfd_byte *) ere >= flaginfo->data_end) + if ((const bfd_byte *) ere > flaginfo->data_end + || flaginfo->data_end - (const bfd_byte *) ere < 8) { overrun (flaginfo, _("ID directory entry")); return NULL; @@ -342,24 +347,25 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data, if ((rva & 0x80000000) != 0) { rva &=~ 0x80000000; - if (rva >= (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + if (rva >= data_len) { overrun (flaginfo, _("ID subdirectory")); return NULL; } re->subdir = 1; - re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo, type, - level + 1); + re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo, + type, level + 1); } else { - if (rva >= (rc_uint_type) (flaginfo->data_end - flaginfo->data)) + if (rva >= data_len) { overrun (flaginfo, _("ID resource")); return NULL; } re->subdir = 0; - re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva, flaginfo, type); + re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva, + flaginfo, type); } *pp = re; diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9d35440..3f5e707 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -36,7 +36,7 @@ #include "objfiles.h" #include "breakpoint.h" #include "gdbcore.h" -#include "hashtab.h" +#include "gdbsupport/unordered_set.h" #include "gdbsupport/gdb_obstack.h" #include "ada-lang.h" #include "completer.h" @@ -52,6 +52,7 @@ #include "namespace.h" #include "cli/cli-style.h" #include "cli/cli-decode.h" +#include "gdbsupport/string-set.h" #include "value.h" #include "mi/mi-common.h" @@ -349,56 +350,58 @@ struct cache_entry_search { const char *name; domain_search_flags domain; +}; + +/* Hash function for cache entry. */ + +struct cache_entry_hash +{ + using is_transparent = void; + using is_avalanching = void; - hashval_t hash () const + /* This implementation works for both cache_entry and + cache_entry_search. */ + template<typename T> + uint64_t operator() (const T &entry) const noexcept { - /* This must agree with hash_cache_entry, below. */ - return htab_hash_string (name); + return ankerl::unordered_dense::hash<std::string_view> () (entry.name); } }; -/* Hash function for cache_entry. */ +/* Equality function for cache entry. */ -static hashval_t -hash_cache_entry (const void *v) +struct cache_entry_eq { - const cache_entry *entry = (const cache_entry *) v; - return htab_hash_string (entry->name.c_str ()); -} - -/* Equality function for cache_entry. */ + using is_transparent = void; -static int -eq_cache_entry (const void *a, const void *b) -{ - const cache_entry *entrya = (const cache_entry *) a; - const cache_entry_search *entryb = (const cache_entry_search *) b; + /* This implementation works for both cache_entry and + cache_entry_search. */ + template<typename T> + bool operator() (const T &lhs, const cache_entry &rhs) const noexcept + { + return lhs.domain == rhs.domain && lhs.name == rhs.name; + } +}; - return entrya->domain == entryb->domain && entrya->name == entryb->name; -} +using cache_entry_set + = gdb::unordered_set<cache_entry, cache_entry_hash, cache_entry_eq>; /* Key to our per-program-space data. */ -static const registry<program_space>::key<htab, htab_deleter> +static const registry<program_space>::key<cache_entry_set> ada_pspace_data_handle; -/* Return this module's data for the given program space (PSPACE). - If not is found, add a zero'ed one now. - - This function always returns a valid object. */ +/* Return this module's data for the given program space (PSPACE). If + not is found, one is created. This function always returns a valid + object. */ -static htab_t +static cache_entry_set & get_ada_pspace_data (struct program_space *pspace) { - htab_t data = ada_pspace_data_handle.get (pspace); + cache_entry_set *data = ada_pspace_data_handle.get (pspace); if (data == nullptr) - { - data = htab_create_alloc (10, hash_cache_entry, eq_cache_entry, - htab_delete_entry<cache_entry>, - xcalloc, xfree); - ada_pspace_data_handle.set (pspace, data); - } + data = ada_pspace_data_handle.emplace (pspace); - return data; + return *data; } /* Utilities */ @@ -1603,7 +1606,7 @@ ada_decode_tests () storage leak, it should not be significant unless there are massive changes in the set of decoded names in successive versions of a symbol table loaded during a single session. */ -static struct htab *decoded_names_store; +static gdb::string_set decoded_names_store; /* Returns the decoded name of GSYMBOL, as for ada_decode, caching it in the language-specific part of GSYMBOL, if it has not been @@ -1637,13 +1640,7 @@ ada_decode_symbol (const struct general_symbol_info *arg) which case, we put the result on the heap. Since we only decode when needed, we hope this usually does not cause a significant memory leak (FIXME). */ - - char **slot = (char **) htab_find_slot (decoded_names_store, - decoded.c_str (), INSERT); - - if (*slot == NULL) - *slot = xstrdup (decoded.c_str ()); - *resultp = *slot; + *resultp = decoded_names_store.insert (decoded); } } @@ -3950,9 +3947,9 @@ ada_type_match (struct type *ftype, struct type *atype) atype = ada_check_typedef (atype); if (ftype->code () == TYPE_CODE_REF) - ftype = ftype->target_type (); + ftype = ada_check_typedef (ftype->target_type ()); if (atype->code () == TYPE_CODE_REF) - atype = atype->target_type (); + atype = ada_check_typedef (atype->target_type ()); switch (ftype->code ()) { @@ -4695,19 +4692,18 @@ static int lookup_cached_symbol (const char *name, domain_search_flags domain, struct symbol **sym, const struct block **block) { - htab_t tab = get_ada_pspace_data (current_program_space); + cache_entry_set &htab = get_ada_pspace_data (current_program_space); cache_entry_search search; search.name = name; search.domain = domain; - cache_entry *e = (cache_entry *) htab_find_with_hash (tab, &search, - search.hash ()); - if (e == nullptr) + auto iter = htab.find (search); + if (iter == htab.end ()) return 0; if (sym != nullptr) - *sym = e->sym; + *sym = iter->sym; if (block != nullptr) - *block = e->block; + *block = iter->block; return 1; } @@ -4735,21 +4731,8 @@ cache_symbol (const char *name, domain_search_flags domain, return; } - htab_t tab = get_ada_pspace_data (current_program_space); - cache_entry_search search; - search.name = name; - search.domain = domain; - - void **slot = htab_find_slot_with_hash (tab, &search, - search.hash (), INSERT); - - cache_entry *e = new cache_entry; - e->name = name; - e->domain = domain; - e->sym = sym; - e->block = block; - - *slot = e; + cache_entry_set &tab = get_ada_pspace_data (current_program_space); + tab.insert (cache_entry {name, domain, sym, block}); } /* Symbol Lookup */ @@ -14049,10 +14032,6 @@ When enabled, the debugger will stop using the DW_AT_GNAT_descriptive_type\n\ DWARF attribute."), NULL, NULL, &maint_set_ada_cmdlist, &maint_show_ada_cmdlist); - decoded_names_store = htab_create_alloc (256, htab_hash_string, - htab_eq_string, - NULL, xcalloc, xfree); - /* The ada-lang observers. */ gdb::observers::new_objfile.attach (ada_new_objfile_observer, "ada-lang"); gdb::observers::all_objfiles_removed.attach (ada_clear_symbol_cache, diff --git a/gdb/copyright.py b/gdb/copyright.py index 5ec9944..bd854dc 100755 --- a/gdb/copyright.py +++ b/gdb/copyright.py @@ -30,13 +30,16 @@ # # This removes the bulk of the changes which are most likely to be correct. +# pyright: strict + import argparse import locale import os import os.path +import pathlib import subprocess import sys -from typing import List, Optional +from typing import Iterable def get_update_list(): @@ -66,24 +69,20 @@ def get_update_list(): .split("\0") ) - def include_file(filename): - (dirname, basename) = os.path.split(filename) - dirbasename = os.path.basename(dirname) - return not ( - basename in EXCLUDE_ALL_LIST - or dirbasename in EXCLUDE_ALL_LIST - or dirname in EXCLUDE_LIST - or dirname in NOT_FSF_LIST - or dirname in BY_HAND - or filename in EXCLUDE_LIST - or filename in NOT_FSF_LIST - or filename in BY_HAND - ) + full_exclude_list = EXCLUDE_LIST + BY_HAND + + def include_file(filename: str): + path = pathlib.Path(filename) + for pattern in full_exclude_list: + if path.full_match(pattern): + return False + + return True return filter(include_file, result) -def update_files(update_list): +def update_files(update_list: Iterable[str]): """Update the copyright header of the files in the given list. We use gnulib's update-copyright script for that. @@ -128,7 +127,7 @@ def update_files(update_list): print("*** " + line) -def may_have_copyright_notice(filename): +def may_have_copyright_notice(filename: str): """Check that the given file does not seem to have a copyright notice. The filename is relative to the root directory. @@ -166,7 +165,7 @@ def get_parser() -> argparse.ArgumentParser: return parser -def main(argv: List[str]) -> Optional[int]: +def main(argv: list[str]) -> int | None: """The main subprogram.""" parser = get_parser() _ = parser.parse_args(argv) @@ -210,8 +209,14 @@ def main(argv: List[str]) -> Optional[int]: # generated, non-FSF, or otherwise special (e.g. license text, # or test cases which must be sensitive to line numbering). # -# Filenames are relative to the root directory. +# Entries are treated as glob patterns. EXCLUDE_LIST = ( + "**/aclocal.m4", + "**/configure", + "**/COPYING.LIB", + "**/COPYING", + "**/fdl.texi", + "**/gpl.texi", "gdb/copying.c", "gdb/nat/glibc_thread_db.h", "gdb/CONTRIBUTE", @@ -219,45 +224,11 @@ EXCLUDE_LIST = ( "gdbsupport/unordered_dense.h", "gnulib/doc/gendocs_template", "gnulib/doc/gendocs_template_min", - "gnulib/import", + "gnulib/import/**", "gnulib/config.in", "gnulib/Makefile.in", -) - -# Files which should not be modified, either because they are -# generated, non-FSF, or otherwise special (e.g. license text, -# or test cases which must be sensitive to line numbering). -# -# Matches any file or directory name anywhere. Use with caution. -# This is mostly for files that can be found in multiple directories. -# Eg: We want all files named COPYING to be left untouched. - -EXCLUDE_ALL_LIST = ( - "COPYING", - "COPYING.LIB", - "configure", - "fdl.texi", - "gpl.texi", - "aclocal.m4", -) - -# The list of files to update by hand. -BY_HAND = ( - # Nothing at the moment :-). -) - -# Files containing multiple copyright headers. This script is only -# fixing the first one it finds, so we need to finish the update -# by hand. -MULTIPLE_COPYRIGHT_HEADERS = ( - "gdb/doc/gdb.texinfo", - "gdb/doc/refcard.tex", - "gdb/syscalls/update-netbsd.sh", -) - -# The list of file which have a copyright, but not held by the FSF. -# Filenames are relative to the root directory. -NOT_FSF_LIST = ( + "sim/Makefile.in", + # The files below have a copyright, but not held by the FSF. "gdb/exc_request.defs", "gdb/gdbtk", "gdb/testsuite/gdb.gdbtk/", @@ -294,9 +265,27 @@ NOT_FSF_LIST = ( "sim/mips/sim-main.c", "sim/moxie/moxie-gdb.dts", # Not a single file in sim/ppc/ appears to be copyright FSF :-(. - "sim/ppc", + "sim/ppc/**", "sim/testsuite/mips/mips32-dsp2.s", ) +# The list of files to update by hand. +# +# Entries are treated as glob patterns. +BY_HAND: tuple[str, ...] = ( + # Nothing at the moment :-). +) + +# Files containing multiple copyright headers. This script is only +# fixing the first one it finds, so we need to finish the update +# by hand. +# +# Entries are treated as glob patterns. +MULTIPLE_COPYRIGHT_HEADERS = ( + "gdb/doc/gdb.texinfo", + "gdb/doc/refcard.tex", + "gdb/syscalls/update-netbsd.sh", +) + if __name__ == "__main__": sys.exit(main(sys.argv[1:])) diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.c b/gdb/testsuite/gdb.base/bg-execution-repeat.c index 8e9bae4..3c0cc76 100644 --- a/gdb/testsuite/gdb.base/bg-execution-repeat.c +++ b/gdb/testsuite/gdb.base/bg-execution-repeat.c @@ -37,9 +37,9 @@ main (void) { alarm (60); + do_wait = 1; foo (); - do_wait = 1; wait (); /* do_wait set to 0 externally. */ |