How to use complexPtrs method of prog Package

Best Syzkaller code snippet using prog.complexPtrs

mutation.go

Source:mutation.go Github

copy

Full Screen

...16 switch {17 case r.oneOf(5):18 // Not all calls have anything squashable,19 // so this has lower priority in reality.20 complexPtrs := p.complexPtrs()21 if len(complexPtrs) == 0 {22 retry = true23 continue24 }25 ptr := complexPtrs[r.Intn(len(complexPtrs))]26 if !p.Target.isAnyPtr(ptr.Type()) {27 p.Target.squashPtr(ptr, true)28 }29 var blobs []*DataArg30 var bases []*PointerArg31 ForeachSubArg(ptr, func(arg Arg, ctx *ArgCtx) {32 if data, ok := arg.(*DataArg); ok && arg.Type().Dir() != DirOut {33 blobs = append(blobs, data)34 bases = append(bases, ctx.Base)35 }36 })37 if len(blobs) == 0 {38 retry = true39 continue40 }41 // TODO(dvyukov): we probably want special mutation for ANY.42 // E.g. merging adjacent ANYBLOBs (we don't create them,43 // but they can appear in future); or replacing ANYRES44 // with a blob (and merging it with adjacent blobs).45 idx := r.Intn(len(blobs))46 arg := blobs[idx]47 base := bases[idx]48 baseSize := base.Res.Size()49 arg.data = mutateData(r, arg.Data(), 0, maxBlobLen)50 // Update base pointer if size has increased.51 if baseSize < base.Res.Size() {52 s := analyze(ct, p, p.Calls[0])53 newArg := r.allocAddr(s, base.Type(), base.Res.Size(), base.Res)54 *base = *newArg55 }56 case r.nOutOf(1, 100):57 // Splice with another prog from corpus.58 if len(corpus) == 0 || len(p.Calls) == 0 {59 retry = true60 continue61 }62 p0 := corpus[r.Intn(len(corpus))]63 p0c := p0.Clone()64 idx := r.Intn(len(p.Calls))65 for i := 0; i < 2; i++ {66 if index[i] >= idx {67 index[i] += len(p0c.Calls)68 }69 }70 p.Calls = append(p.Calls[:idx], append(p0c.Calls, p.Calls[idx:]...)...)71 for i := len(p.Calls) - 1; i >= ncalls; i-- {72 p.removeCall(i)73 }74 case r.nOutOf(20, 31):75 // Insert a new call.76 if len(p.Calls) >= ncalls {77 retry = true78 continue79 }80 idx := r.biasedRand(len(p.Calls)+1, 5)81 var c *Call82 if idx < len(p.Calls) {83 c = p.Calls[idx]84 }85 s := analyze(ct, p, c)86 calls := r.generateCall(s, p)87 for i := 0; i < 2; i++ {88 if index[i] >= idx {89 index[i] += len(calls)90 }91 }92 p.insertBefore(c, calls)93 case r.nOutOf(10, 11):94 // Change args of a call.95 if len(p.Calls) == 0 {96 retry = true97 continue98 }99 cidx := r.Intn(len(p.Calls))100 c := p.Calls[cidx]101 if len(c.Args) == 0 {102 retry = true103 continue104 }105 s := analyze(ct, p, c)106 updateSizes := true107 retryArg := false108 for stop := false; !stop || retryArg; stop = r.oneOf(3) {109 retryArg = false110 ma := &mutationArgs{target: p.Target}111 ForeachArg(c, ma.collectArg)112 if len(ma.args) == 0 {113 retry = true114 continue outer115 }116 idx := r.Intn(len(ma.args))117 arg, ctx := ma.args[idx], ma.ctxes[idx]118 calls, ok := p.Target.mutateArg(r, s, arg, ctx, &updateSizes)119 if !ok {120 retryArg = true121 continue122 }123 for i := 0; i < 2; i++ {124 if index[i] >= cidx {125 index[i] += len(calls)126 }127 }128 p.insertBefore(c, calls)129 cidx += len(calls)130 if updateSizes {131 p.Target.assignSizesCall(c)132 }133 p.Target.SanitizeCall(c)134 }135 default:136 // Remove a random call.137 if len(p.Calls) == 0 {138 retry = true139 continue140 }141 idx := r.Intn(len(p.Calls))142 if idx == index[0] || idx == index[1] {143 retry = true144 continue145 }146 for i := 0; i < 2; i++ {147 if index[i] > idx {148 index[i]--149 }150 }151 p.removeCall(idx)152 }153 }154 for _, c := range p.Calls {155 p.Target.SanitizeCall(c)156 }157 if debug {158 if err := p.validate(); err != nil {159 panic(err)160 }161 }162 return index163}164func (p *Prog) Mutate(rs rand.Source, ncalls int, ct *ChoiceTable, corpus []*Prog) {165 r := newRand(p.Target, rs)166 retry := false167outer:168 for stop := false; !stop || retry; stop = r.oneOf(3) {169 retry = false170 switch {171 case r.oneOf(5):172 // Not all calls have anything squashable,173 // so this has lower priority in reality.174 complexPtrs := p.complexPtrs()175 if len(complexPtrs) == 0 {176 retry = true177 continue178 }179 ptr := complexPtrs[r.Intn(len(complexPtrs))]180 if !p.Target.isAnyPtr(ptr.Type()) {181 p.Target.squashPtr(ptr, true)182 }183 var blobs []*DataArg184 var bases []*PointerArg185 ForeachSubArg(ptr, func(arg Arg, ctx *ArgCtx) {186 if data, ok := arg.(*DataArg); ok && arg.Type().Dir() != DirOut {187 blobs = append(blobs, data)188 bases = append(bases, ctx.Base)189 }190 })191 if len(blobs) == 0 {192 retry = true193 continue...

Full Screen

Full Screen

any_test.go

Source:any_test.go Github

copy

Full Screen

...23 for i := 0; i < iters; i++ {24 s := newState(target, ct, nil)25 calls := r.generateParticularCall(s, meta)26 p := &Prog{Target: target, Calls: calls}27 for _, arg := range p.complexPtrs() {28 compl[arg.Res.Type().String()] = true29 }30 }31 }32 var arr []string33 for id := range compl {34 arr = append(arr, id)35 }36 sort.Strings(arr)37 t.Log("complex types:\n" + strings.Join(arr, "\n"))38}39func TestSquash(t *testing.T) {40 target := initTargetTest(t, "test", "64")41 // nolint: lll...

Full Screen

Full Screen

complexPtrs

Using AI Code Generation

copy

Full Screen

1func main() {2 prog := new(Prog)3 prog.complexPtrs()4}5func main() {6 prog := new(Prog)7 prog.complexPtrs()8}9func main() {10 prog := new(Prog)11 prog.complexPtrs()12}13func main() {14 prog := new(Prog)15 prog.complexPtrs()16}17func main() {18 prog := new(Prog)19 prog.complexPtrs()20}21func main() {22 prog := new(Prog)23 prog.complexPtrs()24}25func main() {26 prog := new(Prog)27 prog.complexPtrs()28}29func main() {30 prog := new(Prog)31 prog.complexPtrs()32}33func main() {34 prog := new(Prog)35 prog.complexPtrs()36}37func main() {38 prog := new(Prog)39 prog.complexPtrs()40}41func main() {42 prog := new(Prog)43 prog.complexPtrs()44}45func main() {46 prog := new(Prog)47 prog.complexPtrs()48}49func main() {50 prog := new(Prog)51 prog.complexPtrs()52}53func main() {

Full Screen

Full Screen

complexPtrs

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 p.complexPtrs()4}5import "fmt"6func main() {7 p.complexPtrs()8}9import "fmt"10func main() {11 p.complexPtrs()12}13import "fmt"14func main() {15 p.complexPtrs()16}17import "fmt"18func main() {19 p.complexPtrs()20}21import "fmt"22func main() {23 p.complexPtrs()24}25import "fmt"26func main() {27 p.complexPtrs()28}29import "fmt"30func main() {31 p.complexPtrs()32}33import "fmt"34func main() {35 p.complexPtrs()36}37import "fmt"38func main() {39 p.complexPtrs()40}41import "fmt"42func main() {43 p.complexPtrs()44}45import "fmt"46func main() {47 p.complexPtrs()48}49import "fmt

Full Screen

Full Screen

complexPtrs

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 result := complexPtrs(&num1, &num2)4 fmt.Printf("Sum: (%f, %f)", real(result), imag(result))5}6import "fmt"7func main() {8 result := complexPtrs(&num1, &num2)9 fmt.Printf("Sum: (%f, %f)", real(result), imag(result))10}11import "fmt"12func main() {13 result := complexPtrs(&num1, &num2)14 fmt.Printf("Sum: (%f, %f)", real(result), imag(result))15}16import "fmt"17func main() {18 result := complexPtrs(&num1, &num2)19 fmt.Printf("Sum: (%f, %f)", real(result), imag(result))20}21import "fmt"22func main() {23 result := complexPtrs(&num1, &num2)24 fmt.Printf("Sum: (%f, %f)", real(result), imag(result))25}26import "fmt"27func main() {

Full Screen

Full Screen

complexPtrs

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 prog1.complexPtrs()4}5import (6type prog struct {7}8func (p *prog) complexPtrs() {9}

Full Screen

Full Screen

complexPtrs

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main(){3 var x complex128 = complex(1,2)4 var y complex128 = complex(3,4)5 fmt.Println(x*y)6}

Full Screen

Full Screen

complexPtrs

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("a = ", a, "b = ", b)4 fmt.Println("a + b = ", a + b)5 fmt.Println("a - b = ", a - b)6 fmt.Println("a * b = ", a * b)7 fmt.Println("a / b = ", a / b)8 fmt.Println("a % b = ", a % b)9 fmt.Println("a++ = ", a)10 fmt.Println("a-- = ", a)11}12import "fmt"13func main() {14 fmt.Printf("a = %d15 fmt.Printf("Address of a = %x16 fmt.Printf("ptr = %x17 fmt.Printf("*ptr = %d18 b = int32(a)19 /* int32(a) converts integer into integer32 */20 fmt.Printf("b = %d21 c = float32(a)22 /* float32(a) converts integer into float32 */23 fmt.Printf("c = %f24}25import "fmt"26func main() {27 fmt.Printf("a = %d28 fmt.Printf("Address of a = %x29 fmt.Printf("ptr = %x

Full Screen

Full Screen

complexPtrs

Using AI Code Generation

copy

Full Screen

1import "fmt"2type complex struct {3}4type prog struct{}5func (p *prog) complexPtrs(c *complex) *complex {6 return &complex{c.real + 1, c.imaginary + 1}7}8func main() {9 c1 := complex{1, 2}10 c2 := p.complexPtrs(&c1)11}12import "fmt"13type complex struct {14}15type prog struct{}16func (p *prog) complexPtrs(c *complex) *complex {17 return &complex{c.real + 1, c.imaginary + 1}18}19func main() {20 c1 := complex{1, 2}21 c2 := p.complexPtrs(&c1)22}23import "fmt"24type complex struct {25}26type prog struct{}27func (p *prog) complexPtrs(c *complex) *complex {28 return &complex{c.real + 1,

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful