)]}'
{
  "commit": "ac8f3fc9330da0302ebb491bf2bac8da5e035e35",
  "tree": "9ea8b34ca3d42a0c4ba07acaf9bfe4ba40efa946",
  "parents": [
    "baac6c221e9d69335bf41366a1c7d87d8ab2f893"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Fri Nov 03 21:40:29 2023 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Wed Jan 15 10:07:50 2025 +0000"
  },
  "message": "gdbserver: convert program_args to a single string\n\nThis commit changes how gdbserver stores the inferior arguments from\nbeing a vector of separate arguments into a single string with all of\nthe arguments combined together.\n\nMaking this change might feel a little strange; intuitively it feels\nlike we would be better off storing the arguments as a vector, but\nthis change is part of a larger series of work that aims to improve\nGDB\u0027s inferior argument handling.  The full series was posted here:\n\n  https://inbox.sourceware.org/gdb-patches/cover.1730731085.git.aburgess@redhat.com\n\nBut asking people to review a 14 patch series in unreasonable, so I\u0027m\ninstead posting the patches in smaller batches.  This patch can stand\nalone, and I do think this change makes sense on its own:\n\nFirst, GDB already stores the inferior arguments as a single string,\nso doing this moves gdbserver into line with GDB.  The common code\ninto which gdbserver calls requires the arguments to be a single\nstring, so currently each target\u0027s create_inferior implementation\nmerged the arguments anyway, so all this commit really does is move\nthe merging up the call stack, and store the merged result rather than\nstoring the separate parts.\n\nHowever, the biggest reason for why this commit is needed, is an issue\nwith passing arguments from GDB to gdbserver when starting a new\ninferior.\n\nConsider:\n\n  (gdb) set args $VAR\n  (gdb) run\n  ...\n\nWhen using a native target the inferior will see the value of $VAR\nexpanded by the shell GDB uses to start the inferior.  However, if\nusing an extended-remote target the inferior will see literally $VAR,\nthe unexpanded name of the variable, the reason for this is that,\nalthough GDB sends \u0027$VAR\u0027 to gdbserver, when gdbserver receives this,\nit converts this to \u0027\\$VAR\u0027, which prevents the variable from being\nexpanded by the shell.\n\nThe reason for this is that construct_inferior_arguments escapes all\nspecial shell characters within its arguments, and it is\nconstruct_inferior_arguments that is used to combine the separate\narguments into a single string.\n\nIn the future I will change construct_inferior_arguments so that\nit can apply different escaping strategies.  When this happens we will\nwant to escape arguments coming from the gdbserver command line\ndifferently than arguments coming from GDB (via a vRun packet), which\nmeans we need to call construct_inferior_arguments earlier, at the\npoint where we know if the arguments came from the gdbserver command\nline, or from the vRun packet.\n\nThis argument escaping issue is discussed in PR gdb/28392.\n\nThis commit doesn\u0027t fix any issues, nor does it change\nconstruct_inferior_arguments to actually do different escaping, that\nwill all come later.  This is purely a restructuring.\n\nThere should be no user visible changes after this commit.\n\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d28392\n\nTested-By: Guinevere Larsen \u003cguinevere@redhat.com\u003e\nApproved-By: Simon Marchi \u003csimon.marchi@efficios.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "50ce2b449270465c97d734b1310e26885dd18feb",
      "old_mode": 33188,
      "old_path": "gdbserver/linux-low.cc",
      "new_id": "65268a6ee6cd6906bcb0605d303777e7e75dbdbd",
      "new_mode": 33188,
      "new_path": "gdbserver/linux-low.cc"
    },
    {
      "type": "modify",
      "old_id": "5be00b8c98cb87fb12277ac269d804e1efe602e1",
      "old_mode": 33188,
      "old_path": "gdbserver/linux-low.h",
      "new_id": "75af38d898fe7bf93da17224ab6d14b64a98f1ae",
      "new_mode": 33188,
      "new_path": "gdbserver/linux-low.h"
    },
    {
      "type": "modify",
      "old_id": "04e103563e793a06fbd90a7bbcb139da8a4b9a63",
      "old_mode": 33188,
      "old_path": "gdbserver/netbsd-low.cc",
      "new_id": "9e7314b02a94157e4e08116c8c90e3f64bf9e00f",
      "new_mode": 33188,
      "new_path": "gdbserver/netbsd-low.cc"
    },
    {
      "type": "modify",
      "old_id": "53200ddffc42a8102f66f0808289589e65af8762",
      "old_mode": 33188,
      "old_path": "gdbserver/netbsd-low.h",
      "new_id": "aef1ce40cb90a3c914e51f2c7a4500c4baab0aa1",
      "new_mode": 33188,
      "new_path": "gdbserver/netbsd-low.h"
    },
    {
      "type": "modify",
      "old_id": "bc591599b0299fe5257e0ca779b6ad1a46703b34",
      "old_mode": 33188,
      "old_path": "gdbserver/server.cc",
      "new_id": "c1b18cc947e85617287da2be3e2e4487b2e4c10c",
      "new_mode": 33188,
      "new_path": "gdbserver/server.cc"
    },
    {
      "type": "modify",
      "old_id": "3643b9110dac760f3aadabe481b6f360d7210f5e",
      "old_mode": 33188,
      "old_path": "gdbserver/target.h",
      "new_id": "1a013bb83db53c5ccec5b545e47ade110a4c08da",
      "new_mode": 33188,
      "new_path": "gdbserver/target.h"
    },
    {
      "type": "modify",
      "old_id": "da858b65e6f7fba5501153e56430d567c1753a20",
      "old_mode": 33188,
      "old_path": "gdbserver/win32-low.cc",
      "new_id": "3cfae74d61a7ca891a3a86aa03746c871077ce78",
      "new_mode": 33188,
      "new_path": "gdbserver/win32-low.cc"
    },
    {
      "type": "modify",
      "old_id": "daed16a6ae6a097ad4383c7ebe8b3cd3752b5eae",
      "old_mode": 33188,
      "old_path": "gdbserver/win32-low.h",
      "new_id": "e9dd6adc5a827a86981b2e0d3191c10a46956eee",
      "new_mode": 33188,
      "new_path": "gdbserver/win32-low.h"
    }
  ]
}
