| 1 | /* |
| 2 | Copyright (C) 2004-2005, 2007-2009, 2011, 2015, 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/finish.c |
| 22 | * |
| 23 | * \brief Debugger `finish` command. |
| 24 | * |
| 25 | * Debugger command to run until the current target is finished |
| 26 | * dependency update and running any commands associated with the |
| 27 | * target. This is also known as "step out". |
| 28 | */ |
| 29 | |
| 30 | #include "../../src/trace.h" |
| 31 | #include "../../src/variable.h" |
| 32 | #include "../stack.h" |
| 33 | #include "../cmd.h" |
| 34 | #include "../fns.h" |
| 35 | |
| 36 | extern debug_return_t |
| 37 | dbg_cmd_finish(char *psz_amount) |
| 38 | { |
| 39 | target_stack_node_t *p=p_stack; |
| 40 | unsigned int i_amount=0; |
| 41 | unsigned int i=0; |
| 42 | if ('\0' != *psz_debugger_args) { |
| 43 | if (!get_uint(psz_amount, &i_amount, true)) |
| 44 | return debug_readloop; |
| 45 | |
| 46 | if (p_stack_top) { |
| 47 | /* We have a target stack */ |
| 48 | |
| 49 | for (i=0 ; p ; p = p->p_parent, i++ ) { |
| 50 | if (i_amount == i) break; |
| 51 | } |
| 52 | |
| 53 | } |
| 54 | } |
| 55 | if (p) { |
| 56 | i_debugger_nexting = 0; |
| 57 | i_debugger_stepping = 0; |
| 58 | p->p_shared_target->tracing |= (BRK_AFTER_CMD); |
| 59 | define_variable_in_set("MAKEFLAGS", sizeof("MAKEFLAGS")-1, |
| 60 | "", o_debugger, 0, NULL, NULL); |
| 61 | return continue_execution; |
| 62 | } else { |
| 63 | if (i > i_amount) |
| 64 | printf("Target level %u not found\n", i_amount); |
| 65 | else |
| 66 | printf("Level %u is too large; maximum value is %u.\n", |
| 67 | i_amount, i-1); |
| 68 | } |
| 69 | |
| 70 | return debug_readloop; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | /* |
| 75 | * Local variables: |
| 76 | * eval: (c-set-style "gnu") |
| 77 | * indent-tabs-mode: nil |
| 78 | * End: |
| 79 | */ |