KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_debug_tool_main.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020-2022 KiCad Developers.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program 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 this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25#include <wx/cmdline.h>
26
28#include <advanced_config.h>
29
30#include "pns_log_file.h"
32
33
34static const wxCmdLineEntryDesc g_cmdLineDesc[] = {
35 {
36 wxCMD_LINE_SWITCH,
37 "h",
38 "help",
39 _( "displays help on the command line parameters" ).mb_str(),
40 wxCMD_LINE_VAL_NONE,
41 wxCMD_LINE_OPTION_HELP,
42 },
43 {
44 wxCMD_LINE_OPTION,
45 "i",
46 "iteration-limit",
47 _( "Max number of iterations" ).mb_str(),
48 wxCMD_LINE_VAL_NUMBER,
49 wxCMD_LINE_PARAM_OPTIONAL,
50 },
51 {
52 wxCMD_LINE_OPTION,
53 "s",
54 "steps-limit",
55 _( "execute log up to steps-limit events" ).mb_str(),
56 wxCMD_LINE_VAL_NUMBER,
57 wxCMD_LINE_PARAM_OPTIONAL,
58 },
59 {
60 wxCMD_LINE_PARAM,
61 "filename",
62 "filename",
63 _( "log file name (no extensions)" ).mb_str(),
64 wxCMD_LINE_VAL_STRING,
65 wxCMD_LINE_PARAM_OPTIONAL,
66 },
67 { wxCMD_LINE_NONE }
68};
69
70int replay_main_func( int argc, char* argv[] )
71{
72 wxCmdLineParser cl_parser( argc, argv );
73 cl_parser.SetDesc( g_cmdLineDesc );
74 cl_parser.AddUsageText(
75 _( "PNS Log (Re)player. Allows to step through the log written by the ROUTER_TOOL "
76 "in debug KiCad builds." ) );
77
78 int cmd_parsed_ok = cl_parser.Parse();
79
80 if( cl_parser.Found("help") )
81 {
82 return 0;
83 }
84
85 if( cmd_parsed_ok != 0 )
86 {
87 printf("P&S Log Replay/Debug tool. For command line options, call %s -h.\n\n", argv[0] );
88 return ( cmd_parsed_ok == -1 ) ? KI_TEST::RET_CODES::OK : KI_TEST::RET_CODES::BAD_CMDLINE;
89 }
90
91
92#if 0
93 long iter_limit = 256;
94 long steps_limit = -1;
95 cl_parser.Found( "iteration-limit", &iter_limit );
96 cl_parser.Found( "steps-limit", &steps_limit );
97#endif
98
99 auto frame = new PNS_LOG_VIEWER_FRAME( nullptr );
100
101 if( cl_parser.GetParamCount() > 0 )
102 {
103 frame->LoadLogFile( cl_parser.GetParam( 0 ) );
104 }
105
106 return 0;
107}
108
109
111 "replay",
112 "PNS Log Player",
114} );
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
#define _(s)
@ OK
Tool exited OK.
@ BAD_CMDLINE
The command line was not correct for the tool.
static bool registered
static const wxCmdLineEntryDesc g_cmdLineDesc[]
int replay_main_func(int argc, char *argv[])