Skip to content

Commit

Permalink
Add segv pass to trigger a segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
akashlevy committed Nov 14, 2024
1 parent 77257b1 commit f5f673d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ OBJS += passes/cmds/splitnetlist.o
OBJS += passes/cmds/reconstructbusses.o
OBJS += passes/sat/sim.o

OBJS += passes/cmds/segv.o

include $(YOSYS_SRC)/passes/hierarchy/Makefile.inc
include $(YOSYS_SRC)/passes/memory/Makefile.inc
include $(YOSYS_SRC)/passes/pmgen/Makefile.inc
Expand Down
43 changes: 43 additions & 0 deletions passes/cmds/segv.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* yosys -- Yosys Open SYnthesis Suite
*
* Copyright (C) 2024 Akash Levy <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/

#include "kernel/yosys.h"
#include "kernel/sigtools.h"

USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN

struct SegvPass : public Pass {
SegvPass() : Pass("segv", "trigger a segfault") { }
void help() override
{
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
log("\n");
log(" segv\n");
log("\n");
log("This command triggers a segfault for debugging.\n");
log("\n");
}
void execute(std::vector<std::string>, RTLIL::Design *) override
{
raise(SIGSEGV);
}
} SegvPass;

PRIVATE_NAMESPACE_END

0 comments on commit f5f673d

Please sign in to comment.