| 1 | /* |
| 2 | Copyright (C) 2004-2005, 2007-2009, 2011, 2020 R. Bernstein |
| 3 | <[email protected]> |
| 4 | This file is part of GNU Make (remake variant). |
| 5 | |
| 6 | GNU Make is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2, or (at your option) |
| 9 | any later version. |
| 10 | |
| 11 | GNU Make is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Make; see the file COPYING. If not, write to |
| 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | Boston, MA 02111-1307, USA. */ |
| 20 | |
| 21 | /** \file libdebugger/command/run.c |
| 22 | * |
| 23 | * \brief Debugger `run` command. |
| 24 | * |
| 25 | * Debugger command to restart `remake`. |
| 26 | */ |
| 27 | |
| 28 | #include "../../src/trace.h" |
| 29 | #include "../../src/buildargv.h" |
| 30 | |
| 31 | extern debug_return_t |
| 32 | dbg_cmd_run(char *psz_arg) |
| 33 | { |
| 34 | char * const *ppsz_argv = (char * const *)global_argv; |
| 35 | const char *psz_make_cmd = global_argv[0]; |
| 36 | printf("Changing directory to %s and restarting...\n", |
| 37 | directory_before_chdir); |
| 38 | |
| 39 | if (chdir(directory_before_chdir) == -1) |
| 40 | fprintf(stderr, "changing working directory; %s\n", |
| 41 | strerror(errno)); |
| 42 | |
| 43 | if (psz_arg && strlen(psz_arg)) { |
| 44 | unsigned int len = strlen(global_argv[0]) + strlen(psz_arg) + 2; |
| 45 | char *psz_full_args = CALLOC(char, len); |
| 46 | snprintf(psz_full_args, len, "%s %s", global_argv[0], psz_arg); |
| 47 | ppsz_argv = buildargv(psz_full_args); |
| 48 | free(psz_full_args); |
| 49 | } |
| 50 | execvp (psz_make_cmd, ppsz_argv); |
| 51 | /* NOT USED: */ |
| 52 | return debug_readloop; |
| 53 | } |
| 54 | |
| 55 | /* |
| 56 | * Local variables: |
| 57 | * c-file-style: "gnu" |
| 58 | * indent-tabs-mode: nil |
| 59 | * End: |
| 60 | */ |