gdbserver gets conditionals wrong on ppc64le

Bug #1367832 reported by bugproxy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gdb (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

---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

Revision history for this message
bugproxy (bugproxy) wrote : patch for gdbserver

Default Comment by Bridge

tags: added: architecture-ppc64le bugnameltc-115779 severity-high targetmilestone-inin---
Luciano Chavez (lnx1138)
affects: ubuntu → gdb (Ubuntu)
bugproxy (bugproxy)
tags: added: targetmilestone-inin1410
removed: targetmilestone-inin---
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gdb - 7.8-0ubuntu2

---------------
gdb (7.8-0ubuntu2) utopic; urgency=medium

  * Update gdb from the 7.8 release branch.
    - Fix regression for Linux vDSO in GDB (PR gdb/17407).
    - Fix regression, GDB stopped on run with attached process (PR gdb/17347).
    - Fix PR guile/17367, PR guile/17247.
    - Fix crash on Python frame filters with unreadable arg.
    - Fix xmethod Python so that it works with Python3.
    - Fix 'gcore' with exited threads.
    - Fix Fix build/17104, build configured with --with-babeltrace.
    - Aarch64: Make CPSR a 32-bit register again in the target description.
  * Build-depend on binutils 2.24.51.20141001 for running the tests.
    LP: #1365664.
  * Fix gdbserver conditionals on ppc64le. LP: #1367832.
  * Fix attaching to a java process on ppc64el.
 -- Matthias Klose <email address hidden> Wed, 01 Oct 2014 22:41:51 +0200

Changed in gdb (Ubuntu):
status: New → Fix Released
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2014-10-20 13:05 EDT-------
Tested and verified as fixed with gdb 7.8-1ubuntu4.
Thanks.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.