)]}'
{
  "commit": "19a76d2bc7ddebc7ae89251c87ca1d7830e6cc18",
  "tree": "21d5781b395f71ac7e4742e5d33fe76eca3fea2e",
  "parents": [
    "483b96f516dbe5aa3535e2af0b7ea61282170ca8"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Thu Dec 04 10:38:23 2025 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Mon Dec 15 14:56:46 2025 +0000"
  },
  "message": "gdb: fix crashes and weird output from new boxed hint text\n\nAfter the commit:\n\n  commit f6df8aa48f120b78f0670b429f8a3363020a47dc\n  Date:   Mon Sep 15 11:56:17 2025 -0300\n\n      gdb: Make startup message more user friendly\n\nI noticed, that when I start GDB with a file on the command line, I\nwas seeing some stray \u0027..\u0027.  Like this:\n\n  $ gdb -nw -nh /tmp/hello.x\n  GNU gdb (GDB) 18.0.50.20251202-git\n  Copyright (C) 2025 Free Software Foundation, Inc.\n  License GPLv3+: GNU GPL version 3 or later \u003chttp://gnu.org/licenses/gpl.html\u003e\n  This is free software: you are free to change and redistribute it.\n  There is NO WARRANTY, to the extent permitted by law.\n  Type \"show copying\" and \"show warranty\" for details.\n  This GDB was configured as \"x86_64-pc-linux-gnu\".\n  Type \"show configuration\" for configuration details.\n  For bug reporting instructions, please see:\n  \u003chttps://www.gnu.org/software/gdb/bugs/\u003e.\n\n  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n  ┃ Find the GDB manual online at:                                               ┃\n  ┃ http://www.gnu.org/software/gdb/documentation/.                              ┃\n  ┃ For help, type \"help\".                                                       ┃\n  ┃ Type \"apropos \u003cword\u003e\" to search for commands related to \u003cword\u003e               ┃\n  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n  ..\n  Reading symbols from /tmp/hello.x...\n\nNotice the \u0027..\u0027 after the boxed hint text, that\u0027s what I\u0027m complaining\nabout.  Also, notice that the last line within the box is missing its\nperiod.\n\nBefore the above commit the last line would appear like this when no\nfile was loaded:\n\n  Type \"apropos \u003cword\u003e\" to search for commands related to \u003cword\u003e.\n\nAnd like this when a file was being loaded:\n\n  Type \"apropos \u003cword\u003e\" to search for commands related to \u003cword\u003e...\n\nThe extra \u0027..\u0027 are added to show that a file is being loaded, and that\nthis might take some time.  But we have the \u0027Reading symbols from ...\u0027\ntext to indicate this now, so I think the extra \u0027..\u0027 are redundant.\nLets just drop them.  This will leave just a single period at the end\nof the sentence.\n\nThe above commit unfortunately, didn\u0027t include any tests, so I thought\nI\u0027d write some to cover this fix.... and that uncovered a bug where\nthe box around the startup hints could be corrupted:\n\n  $ gdb -eiex \u0027set width 50\u0027 -nw -nh\n  GNU gdb (GDB) 18.0.50.20251202-git\n  Copyright (C) 2025 Free Software Foundation, Inc.\n  License GPLv3+: GNU GPL version 3 or later \u003chttp://gnu.org/licenses/gpl.html\u003e\n  This is free software: you are free to change and redistribute it.\n  There is NO WARRANTY, to the extent permitted by law.\n  Type \"show copying\" and \"show warranty\" for details.\n  This GDB was configured as \"x86_64-pc-linux-gnu\".\n  Type \"show configuration\" for configuration details.\n  For bug reporting instructions, please see:\n  \u003chttps://www.gnu.org/software/gdb/bugs/\u003e.\n\n  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n  ┃ Find the GDB manual online at:                 ┃\n  ┃ http://www.gnu.org/software/gdb/documentation/. ┃\n  ┃ For help, type \"help\".                         ┃\n  ┃ Type \"apropos \u003cword\u003e\" to                       ┃\n  ┃  search for commands related to \u003cword\u003e         ┃\n  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n  (gdb)\n\nThis was caused by a mistake on the line where we choose whether to\nbox or not.  The line is currently:\n\n  if (width - 3 \u003c\u003d docs_url.length ())\n\nThere are two problems here, the \u00273\u0027 should be \u00274\u0027.  The box adds 4\ncharacters \u0027| \u0027 and \u0027 |\u0027.  But also, the WIDTH can be very small, less\nthan 4 even, which means that the subtraction can underflow, wrapping\naround and giving a very large value.  I plan to rewrite the line to:\n\n  if (width \u003c docs_url.length () + 1 + 4)\n\nThe \u0027+ 1\u0027 accounts for the period at the end of the URL line (which\nwas previously handled by the \u0027\u003c\u003d\u0027, and the \u0027+ 4\u0027 accounts for the box\nborders.  By making it a \u0027+ 4\u0027 on the URL, rather than \u0027- 4\u0027 from the\nwidth, we avoid underflow.  This is fine so long as the URL to our\ndocumentation doesn\u0027t approach UINT_MAX in length.  Which I hope it\nnever does.\n\nI\u0027ve added a couple of asserts to print_gdb_hints to reflect things\nthat must be true.  The first is that get_chars_per_line never returns\n0.  And later on, I assert that \u0027width \u003e 4\u0027 in a place where we are\nabout to do \u0027width - 4\u0027.  If the assert triggers then underflow would\nhave occurred.\n\nReviewed-By: Guinevere Larsen \u003cguinevere@redhat.com\u003e\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "0fa2b0ecbe432bb911c052705873ee2223328160",
      "old_mode": 33188,
      "old_path": "gdb/main.c",
      "new_id": "e4da715134b2c199870e0cd42ecc8522eb518a33",
      "new_mode": 33188,
      "new_path": "gdb/main.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "0addf3769a2d47d02b37f26508dd5d353988edb1",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/startup-hints.exp"
    },
    {
      "type": "modify",
      "old_id": "adc0596a504fd1f6e26b13597016c83da4b7138d",
      "old_mode": 33188,
      "old_path": "gdb/top.c",
      "new_id": "0ab9b609e45012fadbcf83ec524b313bb055cde5",
      "new_mode": 33188,
      "new_path": "gdb/top.c"
    }
  ]
}
