def run_gdb(*args, **env_vars):
 if env_vars:
  env = os.environ.copy()
  env.update(env_vars)
 else:
  env = None
 base_cmd = ('gdb', '--batch', '-nx')
 if ((gdb_major_version, gdb_minor_version) >= (7, 4)):
  base_cmd += ('-iex', ('add-auto-load-safe-path ' + checkout_hook_path))
 (out, err) = subprocess.Popen((base_cmd + args), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env).communicate()
 return (out.decode('utf-8', 'replace'), err.decode('utf-8', 'replace'))

def run_gdb ( * args , ** env_vars ) : if env_vars : env = os . environ . copy ( ) env . update ( env_vars ) else : env = None base_cmd = ( 'gdb' , '--batch' , '-nx' ) if ( ( gdb_major_version , gdb_minor_version ) >= ( 7 , 4 ) ) : base_cmd += ( '-iex' , ( 'add-auto-load-safe-path ' + checkout_hook_path ) ) ( out , err ) = subprocess . Popen ( ( base_cmd + args ) , stdout = subprocess . PIPE , stderr = subprocess . PIPE , env = env ) . communicate ( ) return ( out . decode ( 'utf-8' , 'replace' ) , err . decode ( 'utf-8' , 'replace' ) )
runs gdb in --batch mode with the additional arguments given by *args .