This is the mail archive of the 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: [patch/cygwin] Remove dependency on __COPY_CONTEXT_SIZE

On Mar 31 13:34, Pedro Alves wrote:
> On 03/30/2015 11:04 AM, Corinna Vinschen wrote:
> > @@ -820,7 +819,7 @@ handle_output_debug_string (struct target_waitstatus *ourstatus)
> >  #endif
> >  	warning (("%s"), s);
> >      }
> > -#ifdef __COPY_CONTEXT_SIZE
> > +#ifdef __CYGWIN__
> >    else
> >      {
> >        /* Got a cygwin signal marker.  A cygwin signal is followed by
> > @@ -847,8 +846,8 @@ handle_output_debug_string (struct target_waitstatus *ourstatus)
> >  	  else if ((x = (LPCVOID) (uintptr_t) strtoull (p, NULL, 0))
> >  		   && ReadProcessMemory (current_process_handle, x,
> >  					 &saved_context,
> > -					 __COPY_CONTEXT_SIZE, &n)
> > -		   && n == __COPY_CONTEXT_SIZE)
> > +					 sizeof (CONTEXT), &n)
> Is that really wise?  AFAIK, the size of the CONTEXT structure can
> grow as MSFT adds more registers to support newer machines.

No, that's not possible.  The CONTEXT structure matches the platform.
It doesn't even contain a version number.  Consider that the structure
is available in user space.  If Microsoft changes the size on a given
platform, applications built for this platform might crash due to
overwritten memory.  They wouldn't do that.

> It seems to me that the gdb and cygwin.dll builds can disagree
> on the size of that structure.

No.  The size is constant for the platform.  If Cygwin and GDB disagree,
they hgaven't been built for the same platform, or one of them is using
a broken CONTEXT definition.  However, if Cygwin and GDB disagree,
wouldn't GDB and the Microsoft DLLs have the same problem?   That's really
not a problem.

> Seems to me that this mechanism should
> have a way to let GDB know the size of the context structure.  Or maybe
> read just saved_context.ContextFlags first, and infer the size from
> that, reading in the most we understand?

Again, the context structure is a user-space exported per-platform
structure.  The only party here which could change it is Microsoft,
and Microsoft would never do this because it would break the ABI
for existing application.


Corinna Vinschen
Cygwin Maintainer
Red Hat

Attachment: pgpuS13ChlldC.pgp
Description: PGP signature

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