router: feature to save debug event log & board dump for easier recreation of router bugs and misbehaviours
This commit is contained in:
parent
ebdc68ac1d
commit
b67e5768a6
|
@ -21,6 +21,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <wx/hyperlink.h>
|
#include <wx/hyperlink.h>
|
||||||
|
#include <advanced_config.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
|
@ -51,9 +53,7 @@ using namespace std::placeholders;
|
||||||
|
|
||||||
#include "pns_kicad_iface.h"
|
#include "pns_kicad_iface.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#include <plugins/kicad/kicad_plugin.h>
|
#include <plugins/kicad/kicad_plugin.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace KIGFX;
|
using namespace KIGFX;
|
||||||
|
|
||||||
|
@ -480,51 +480,80 @@ void ROUTER_TOOL::Reset( RESET_REASON aReason )
|
||||||
TOOL_BASE::Reset( aReason );
|
TOOL_BASE::Reset( aReason );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Saves the complete event log and the dump of the PCB, allowing us to
|
||||||
|
// recreate hard-to-find P&S quirks and bugs.
|
||||||
|
|
||||||
void ROUTER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent )
|
void ROUTER_TOOL::saveRouterDebugLog()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
auto logger = m_router->Logger();
|
||||||
if( aEvent.IsKeyPressed() )
|
|
||||||
|
if( ! logger )
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxString cwd = wxGetCwd();
|
||||||
|
|
||||||
|
wxFileName fname_log( cwd );
|
||||||
|
fname_log.SetName( "pns.log" );
|
||||||
|
|
||||||
|
wxFileName fname_dump( cwd );
|
||||||
|
fname_dump.SetName( "pns.dump" );
|
||||||
|
|
||||||
|
wxString msg = wxString::Format( _( "Event file: %s\nBoard dump: %s" ), fname_log.GetFullPath(), fname_log.GetFullPath() );
|
||||||
|
|
||||||
|
int rv = OKOrCancelDialog( nullptr, _("Save router log"), _("Would you like to save the router\nevent log for debugging purposes?"), msg, _("OK"), _("Cancel") );
|
||||||
|
|
||||||
|
if( !rv )
|
||||||
|
return;
|
||||||
|
|
||||||
|
FILE *f = fopen( fname_log.GetFullPath().c_str(), "wb" );
|
||||||
|
|
||||||
|
// save base router configuration (mode, etc.)
|
||||||
|
fprintf(f, "config %d %d %d\n",
|
||||||
|
m_router->Settings().Mode(),
|
||||||
|
m_router->Settings().RemoveLoops() ? 1 : 0,
|
||||||
|
m_router->Settings().GetFixAllSegments() ? 1 : 0
|
||||||
|
);
|
||||||
|
|
||||||
|
const auto& events = logger->GetEvents();
|
||||||
|
|
||||||
|
for( auto evt : events)
|
||||||
{
|
{
|
||||||
switch( aEvent.KeyCode() )
|
wxString id = "null";
|
||||||
{
|
if( evt.item && evt.item->Parent() )
|
||||||
case '0':
|
id = evt.item->Parent()->m_Uuid.AsString();
|
||||||
{
|
|
||||||
auto logger = m_router->Logger();
|
|
||||||
|
|
||||||
if( ! logger )
|
fprintf( f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type,
|
||||||
return;
|
(const char*) id.c_str() );
|
||||||
|
}
|
||||||
FILE *f = fopen("/tmp/pns.log", "wb");
|
|
||||||
wxLogTrace( "PNS", "saving drag/route log...\n" );
|
fclose( f );
|
||||||
|
|
||||||
const auto& events = logger->GetEvents();
|
// Export as *.kicad_pcb format, using a strategy which is specifically chosen
|
||||||
|
// as an example on how it could also be used to send it to the system clipboard.
|
||||||
for( auto evt : events)
|
|
||||||
{
|
PCB_IO pcb_io;
|
||||||
wxString id = "null";
|
|
||||||
|
pcb_io.Save( fname_dump.GetFullPath(), m_iface->GetBoard(), nullptr );
|
||||||
if( evt.item && evt.item->Parent() )
|
}
|
||||||
id = evt.item->Parent()->m_Uuid.AsString();
|
|
||||||
|
|
||||||
fprintf( f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type,
|
void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
|
||||||
(const char*) id.c_str() );
|
{
|
||||||
}
|
if( !aEvent.IsKeyPressed() )
|
||||||
|
return;
|
||||||
fclose( f );
|
|
||||||
|
switch( aEvent.KeyCode() )
|
||||||
// Export as *.kicad_pcb format, using a strategy which is specifically chosen
|
{
|
||||||
// as an example on how it could also be used to send it to the system clipboard.
|
case '0':
|
||||||
|
if( !ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics )
|
||||||
PCB_IO pcb_io;
|
return;
|
||||||
|
|
||||||
pcb_io.Save( "/tmp/pns.dump", m_iface->GetBoard(), nullptr );
|
saveRouterDebugLog();
|
||||||
|
aEvent.SetPassEvent( false );
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1684,6 +1713,8 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
evt->SetPassEvent();
|
evt->SetPassEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleCommonEvents( *evt );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( footprint )
|
if( footprint )
|
||||||
|
|
|
@ -59,7 +59,7 @@ private:
|
||||||
void performDragging( int aMode = PNS::DM_ANY );
|
void performDragging( int aMode = PNS::DM_ANY );
|
||||||
void breakTrack();
|
void breakTrack();
|
||||||
|
|
||||||
void handleCommonEvents( const TOOL_EVENT& evt );
|
void handleCommonEvents( TOOL_EVENT& evt );
|
||||||
int handleLayerSwitch( const TOOL_EVENT& aEvent, bool aForceVia );
|
int handleLayerSwitch( const TOOL_EVENT& aEvent, bool aForceVia );
|
||||||
|
|
||||||
int getStartLayer( const PNS::ITEM* aItem );
|
int getStartLayer( const PNS::ITEM* aItem );
|
||||||
|
@ -71,6 +71,7 @@ private:
|
||||||
|
|
||||||
bool prepareInteractive();
|
bool prepareInteractive();
|
||||||
bool finishInteractive();
|
bool finishInteractive();
|
||||||
|
void saveRouterDebugLog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<ACTION_MENU> m_diffPairMenu;
|
std::shared_ptr<ACTION_MENU> m_diffPairMenu;
|
||||||
|
|
Loading…
Reference in New Issue