This is the mail archive of the cygwin mailing list for the Cygwin 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: Can't debug bash with gdb 8.2.1-1


On 7/23/2019 2:02 PM, Jon Turney wrote:
> Hmm.... let me clarify what I mean:
> 
> $ cat getpgrp_test.c
> #include <unistd.h>
> #include <stdio.h>
> 
> int main() {
>    printf("getpgrp() = %d\n", getpgrp());
> }
> 
> $ gcc getpgrp_test.c -o getpgrp_test.exe
> 
> $ ./getpgrp_test
> getpgrp() = 1241
> 
> 
> $ gdb ./getpgrp_test
> GNU gdb (GDB) (Cygwin 8.2.1-1) 8.2.1
> [...]
> Reading symbols from ./getpgrp_test...done.
> (gdb) r
> Starting program: /work/getpgrp_test
> getpgrp() = -1
> [Inferior 1 (process 11428) exited normally]

Thanks, I was being dense.  But look at this one:

$ cat getpgrp_test.c
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

int
main ()
{
   pid_t pid = getpid ();
   pid_t pgid = getpgid (0);
   printf ("getpid () = %d, getpgid (0) = %d, errno = %d\n", pid, pgid, errno);
}

$ gcc -o getpgrp_test -Wall -g -O0 getpgrp_test.c

$ ./getpgrp_test.exe
getpid () = 1424, getpgid (0) = 1424, errno = 0

$ gdb ./getpgrp_test.exe
GNU gdb (GDB) (Cygwin 8.2.1-1) 8.2.1
[...]
(gdb) r
Starting program: /home/kbrown/Documents/programming/misc_examples/getpgrp_test.exe
[...]
getpid () = 1427, getpgid (0) = -1, errno = 0
[...]
[Inferior 1 (process 23872) exited normally]

So getpgid (0) returns -1 without setting errno.  I think this means that 
pinfo::init() didn't fail, but for some reason myself->pgid == -1.

Ken

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