This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 11/11] Change python_run_simple_file to use gdbpy_ref


On 11/16/2016 08:10 PM, Pedro Alves wrote:
> On 11/16/2016 06:22 PM, Tom Tromey wrote:
>>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>>
>> Pedro> Actually, you don't really need that -- that WIN32 code should work
>> Pedro> on Unix as well, it's just not as efficient as the other branch.
>> Pedro> So you can just hack/invert the #ifndef _WIN32 locally for testing.
>>
>> What if I just remove the non-win32 code here?
>> It might be slightly less efficient, but only slightly; with the upside
>> being that we'd have just a single code path to test.
> 
> That's fine with me.
> 

BTW, for completeness, a middle ground solution would be to change
the #ifndef to an if ().  


#ifdef _WIN32
# define GDB_PYTHON_OPENS_FILE 1
#else
# define GDB_PYTHON_OPENS_FILE 0
#endif

static void
python_run_simple_file (FILE *file, const char *filename)
{
  if (!GDB_PYTHON_OPENS_FILE)
    {
      PyRun_SimpleFile (file, filename);
    }
  else
    {
      ... longer path here ...
    }
}

That'd get us compile-time testing of both branches everywhere,
without run time penalty (the compiler optimizes out the dead branch).

But as said, making the longer branch the only branch is also
fine with me.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]