(args)
| 1642 | } |
| 1643 | |
| 1644 | cmdBreak(args) { |
| 1645 | if (args.length < 1) { |
| 1646 | // No args: list breakpoints |
| 1647 | this.cmdInfoBreakpoints(); |
| 1648 | return; |
| 1649 | } |
| 1650 | |
| 1651 | // Parse "if <expr>" suffix from args |
| 1652 | let conditionExpr = null; |
| 1653 | const ifIndex = args.indexOf('if'); |
| 1654 | if (ifIndex > 0) { |
| 1655 | conditionExpr = args.slice(ifIndex + 1).join(' '); |
| 1656 | args = args.slice(0, ifIndex); |
| 1657 | if (!conditionExpr) { |
| 1658 | this.commandError('Missing expression after "if".'); |
| 1659 | return; |
| 1660 | } |
| 1661 | } |
| 1662 | |
| 1663 | let path, line; |
| 1664 | const spec = args[0]; |
| 1665 | |
| 1666 | if (spec.includes(':')) { |
| 1667 | const lastColon = spec.lastIndexOf(':'); |
| 1668 | path = spec.substring(0, lastColon); |
| 1669 | const lineStr = spec.substring(lastColon + 1); |
| 1670 | if (isNaN(parseInt(lineStr))) { |
| 1671 | this.commandError('Invalid line number.'); |
| 1672 | return; |
| 1673 | } |
| 1674 | line = parseInt(lineStr); |
| 1675 | |
| 1676 | // Resolve short filenames against known files |
| 1677 | const resolved = this.resolveFilePath(path, true); |
| 1678 | if (resolved === null) { |
| 1679 | this.showPrompt(); |
| 1680 | return; |
| 1681 | } |
| 1682 | path = resolved; |
| 1683 | } |
| 1684 | else if (!isNaN(parseInt(spec))) { |
| 1685 | // Just a line number: use current file |
| 1686 | path = this.currentPath; |
| 1687 | if (!path) { |
| 1688 | this.commandError('No current file. Use "break file:line" or "break function".'); |
| 1689 | return; |
| 1690 | } |
| 1691 | if (spec.startsWith('+') || spec.startsWith('-')) { |
| 1692 | if (!this.currentLine) { |
| 1693 | this.commandError('No current line known for relative breakpoint.'); |
| 1694 | return; |
| 1695 | } |
| 1696 | line = parseInt(this.currentLine) + parseInt(spec); |
| 1697 | } |
| 1698 | else { |
| 1699 | line = parseInt(spec); |
| 1700 | } |
| 1701 | } |
no test coverage detected