← Back to team overview

touch-packages team mailing list archive

[Bug 1367832] [NEW] gdbserver gets conditionals wrong on ppc64le

 

You have been subscribed to a public bug:

---Problem Description---
Single stepping has issues with conditionals when debugging with gdbserver, taking the wrong path through the code.
 
Machine Type = Power8 LE 
 
---Steps to Reproduce---
 ubuntu@ubuntu:~$ cat > test.c
#include <stdio.h>
#include <stdlib.h>

typedef enum {
  Success = 0,
  Failure,
} dev_status_t;

dev_status_t getDeviceCount(int *countp)
{ 
  *countp = 1;
  return Success;
}

int
main(int argc, char **argv)
{ 
  int count = 0;
  dev_status_t status = getDeviceCount(&count);

  if (status != Success)
    { 
      printf("getDeviceCount returned %d\n", (int)status);
      printf("Result = FAIL\n");
      exit(EXIT_FAILURE);
    }

  if (count == 0)
    { 
      printf("There are no devices\n");
    }
  else
    { 
      printf("Detected %d device(s)\n", count);
    }

  exit(EXIT_SUCCESS);
}

ubuntu@ubuntu:~$ gcc -g test.c -o test
ubuntu@ubuntu:~$ gdbserver :9999 ./test
Process ./test created; pid = 25600
Listening on port 9999
Remote debugging from host 127.0.0.1

In another terminal, run gdb:

ubuntu@ubuntu:~$ gdb ./test 
GNU gdb (Ubuntu 7.8-0ubuntu1) 7.8
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "powerpc64le-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./test...done.
(gdb) target remote :9999
Remote debugging using :9999
Reading symbols from /lib64/ld64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld64.so.2
Can't read symbols from system-supplied DSO at 0x3fffb7fa0000: File truncated
0x00003fffb7fc1a60 in ?? () from /lib64/ld64.so.2
(gdb) b main
Breakpoint 1 at 0x100006d4: file test.c, line 17.
(gdb) cont
Continuing.

Breakpoint 1, main (argc=1, argv=0x3ffffffff088) at test.c:17
17      {
(gdb) next
18        int count = 0;
(gdb) next
19        dev_status_t status = getDeviceCount(&count);
(gdb) next
21        if (status != Success)
(gdb) next
23            printf("getDeviceCount returned %d\n", (int)status);
(gdb) print status
$1 = Success

Notice the program took the wrong direction on if() block.
 
---uname output---
Linux ubuntu 3.16.0-14-generic #20-Ubuntu SMP Sat Sep 6 23:45:12 UTC 2014 ppc64le ppc64le ppc64le GNU/Linux
 
Userspace tool common name: gdbserver

The root cause of this issue was a routine that collect/supply ptrace
registers on gdbserver, originally developed for BE only.

The attached patch against gdb 7.8-0ubuntu1 sources fixes this problem
on gdbserver. It was already accepted and committed upstream:

https://sourceware.org/ml/gdb-patches/2014-09/msg00181.html

** Affects: gdb (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: architecture-ppc64le bugnameltc-115779 severity-high targetmilestone-inin---
-- 
gdbserver gets conditionals wrong on ppc64le
https://bugs.launchpad.net/bugs/1367832
You received this bug notification because you are a member of Ubuntu Touch seeded packages, which is subscribed to gdb in Ubuntu.