mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-23 11:29:46 +00:00
prog: rename ProgGen to Builder
golint suggests that "prog.Prog" is a bad naming because everything in prog package is ProgSomething. Rename to Builder, "prog.Builder" sounds right.
This commit is contained in:
parent
65ed24721e
commit
b80cc86486
@ -237,14 +237,14 @@ func (g *Gen) MutateArg(arg0 Arg) (calls []*Call) {
|
||||
return calls
|
||||
}
|
||||
|
||||
type ProgGen struct {
|
||||
type Builder struct {
|
||||
target *Target
|
||||
ma *memAlloc
|
||||
p *Prog
|
||||
}
|
||||
|
||||
func MakeProgGen(target *Target) *ProgGen {
|
||||
return &ProgGen{
|
||||
func MakeProgGen(target *Target) *Builder {
|
||||
return &Builder{
|
||||
target: target,
|
||||
ma: newMemAlloc(target.NumPages * target.PageSize),
|
||||
p: &Prog{
|
||||
@ -253,24 +253,24 @@ func MakeProgGen(target *Target) *ProgGen {
|
||||
}
|
||||
}
|
||||
|
||||
func (pg *ProgGen) Append(c *Call) error {
|
||||
func (pg *Builder) Append(c *Call) error {
|
||||
pg.target.assignSizesCall(c)
|
||||
pg.target.SanitizeCall(c)
|
||||
pg.p.Calls = append(pg.p.Calls, c)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pg *ProgGen) Allocate(size uint64) uint64 {
|
||||
func (pg *Builder) Allocate(size uint64) uint64 {
|
||||
return pg.ma.alloc(nil, size)
|
||||
}
|
||||
|
||||
func (pg *ProgGen) AllocateVMA(npages uint64) uint64 {
|
||||
func (pg *Builder) AllocateVMA(npages uint64) uint64 {
|
||||
psize := pg.target.PageSize
|
||||
addr := pg.ma.alloc(nil, (npages+1)*psize)
|
||||
return (addr + psize - 1) & ^(psize - 1)
|
||||
}
|
||||
|
||||
func (pg *ProgGen) Finalize() (*Prog, error) {
|
||||
func (pg *Builder) Finalize() (*Prog, error) {
|
||||
if err := pg.p.validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func parseTree(tree *parser.TraceTree, pid int64, target *prog.Target, progs *[]
|
||||
|
||||
// Context stores metadata related to a syzkaller program
|
||||
type context struct {
|
||||
pg *prog.ProgGen
|
||||
builder *prog.Builder
|
||||
target *prog.Target
|
||||
callSelector *callSelector
|
||||
returnCache returnCache
|
||||
@ -63,7 +63,7 @@ type context struct {
|
||||
func genProg(trace *parser.Trace, target *prog.Target) *prog.Prog {
|
||||
returnCache := newRCache()
|
||||
ctx := &context{
|
||||
pg: prog.MakeProgGen(target),
|
||||
builder: prog.MakeProgGen(target),
|
||||
target: target,
|
||||
callSelector: newCallSelector(target, returnCache),
|
||||
returnCache: returnCache,
|
||||
@ -85,11 +85,11 @@ func genProg(trace *parser.Trace, target *prog.Target) *prog.Prog {
|
||||
if call == nil {
|
||||
continue
|
||||
}
|
||||
if err := ctx.pg.Append(call); err != nil {
|
||||
if err := ctx.builder.Append(call); err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
}
|
||||
p, err := ctx.pg.Finalize()
|
||||
p, err := ctx.builder.Finalize()
|
||||
if err != nil {
|
||||
log.Fatalf("error validating program: %v", err)
|
||||
}
|
||||
@ -182,7 +182,7 @@ func (ctx *context) genVma(syzType *prog.VmaType, _ parser.IrType) prog.Arg {
|
||||
if syzType.RangeBegin != 0 || syzType.RangeEnd != 0 {
|
||||
npages = syzType.RangeEnd
|
||||
}
|
||||
return prog.MakeVmaPointerArg(syzType, ctx.pg.AllocateVMA(npages), npages)
|
||||
return prog.MakeVmaPointerArg(syzType, ctx.builder.AllocateVMA(npages), npages)
|
||||
}
|
||||
|
||||
func (ctx *context) genArray(syzType *prog.ArrayType, traceType parser.IrType) prog.Arg {
|
||||
@ -388,7 +388,7 @@ func (ctx *context) parseProc(syzType *prog.ProcType, traceType parser.IrType) p
|
||||
}
|
||||
|
||||
func (ctx *context) addr(syzType prog.Type, size uint64, data prog.Arg) prog.Arg {
|
||||
return prog.MakePointerArg(syzType, ctx.pg.Allocate(size), data)
|
||||
return prog.MakePointerArg(syzType, ctx.builder.Allocate(size), data)
|
||||
}
|
||||
|
||||
func (ctx *context) reorderStructFields(syzType *prog.StructType, traceType *parser.GroupType) {
|
||||
|
Loading…
Reference in New Issue
Block a user