Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Add a check after generating random code in 'src/randomcode.py' #2

Open
lawyer61 opened this issue Oct 23, 2019 · 0 comments

Comments

@lawyer61
Copy link

Sometimes the csmith will generate a code without 'main' function (This may because of too many args ). When this happens, delay*.o will not have a 'slp' symbol and bring failure when linking it with test.o

change the function ch_main_arg to this:

def ch_main_arg(pn, argname, funcname):  
  # change main function name with random_string name 
  modify_flag = 0
  for line in fileinput.input(pn, inplace=True):
    if "int main" in line:
      line = line.replace("void", "%s" % argname)
      line = line.replace("main", "%s" % funcname)
      modify_flag = 1
    if "int print_hash_value = 0;" in line:
      #line = line.replace("0", "1")
      continue
    if "print_hash_value" in line:
      continue

    sys.stdout.write(line)
  
  return modify_flag

and change line 116 to :

      if not ch_main_arg(var[1], argname, funcname):
        continue

That works for me when fail running python randomcode.py for the first time. Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant