Files
Bhuvanendra Kumar N 4bdd1a0620 [gdb/testsuite] Convert multi-line function call into single line.
After this clang backend patch(https://reviews.llvm.org/D91734), 8 test points
    started to FAIL in this test case. As mentioned in this PR, "...this test is
    trying to next over a function call; gcc attributes all parameter evaluation
    to the function name, while clang will attribute each parameter to its own
    location. And when the parameters span across multiple source lines, the
    is_stmt heuristic kicks in, so we stop on each line with actual parameters...".

    gdb.base/foll-exec.c test file snippet :
    . . .
     42   execlp (prog, /* tbreak-execlp */
     43           prog,
     44           "execlp arg1 from foll-exec",
     45           (char *) 0);
     46
     47   printf ("foll-exec is about to execl(execd-prog)...\n");
    . . .

    Line table: (before clang backend patch for the above code snippet) :
    0x000000b0: 84 address += 8,  line += 2
                0x000000000020196a     42      3      1   0             0
    0x000000b1: 08 DW_LNS_const_add_pc (0x0000000000000011)
    0x000000b2: 41 address += 3,  line += 5
                0x000000000020197e     47      3      1   0             0

    Line table: (after clang backend patch for the above code snippet) :
    0x000000b5: 84 address += 8,  line += 2
                0x0000000000201958     42     11      1   0             0
    0x000000b6: 05 DW_LNS_set_column (4)
    0x000000b8: 75 address += 7,  line += 1
                0x000000000020195f     43      4      1   0             0
    0x000000b9: 05 DW_LNS_set_column (3)
    0x000000bb: 73 address += 7,  line += -1
                0x0000000000201966     42      3      1   0             0
    0x000000bc: 08 DW_LNS_const_add_pc (0x0000000000000011)
    0x000000bd: 4f address += 4,  line += 5
                0x000000000020197b     47      3      1   0             0

    Following 8 test points started to fail after the above clang backend patch.

    FAIL: gdb.base/foll-exec.exp: step through execlp call
    FAIL: gdb.base/foll-exec.exp: step after execlp call
    FAIL: gdb.base/foll-exec.exp: print execd-program/global_i (after execlp)
    FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execlp)
    FAIL: gdb.base/foll-exec.exp: print follow-exec/local_k (after execlp)
    FAIL: gdb.base/foll-exec.exp: step through execl call
    FAIL: gdb.base/foll-exec.exp: step after execl call
    FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execl)

    As we can note, reason for these new test failures is due to additional
    .debug_line entries getting created in case of clang compiler, hence to fix
    this issue, test case required either additional next command during
    these multi-line function call or combine these multi-line function call into
    single line. This PR has taken the latter approach and converted the multi-line
    function call into single line in foll-exec.c, thereby there is no change in
    .debug_line entries now and test case works as expected.
2021-06-10 13:09:56 +05:30

69 lines
2.2 KiB
C

/* This test program is part of GDB, the GNU debugger.
Copyright 1997-2021 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
int global_i = 100;
int main (int argc, char ** argv)
{
int local_j = global_i + 1;
int local_k = local_j + 1;
char prog[PATH_MAX];
int len;
printf ("foll-exec is about to execlp(execd-prog)...\n");
strcpy (prog, argv[0]);
len = strlen (prog);
/* Replace "foll-exec" with "execd-prog". */
memcpy (prog + len - 9, "execd-prog", 10);
prog[len + 1] = 0;
/* In the following function call, maximum line length exceed the limit 80.
This is intentional and required for clang compiler such that complete
function call should be in a single line, please do not make it
multi-line. */
execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from foll-exec", (char *) 0);
printf ("foll-exec is about to execl(execd-prog)...\n");
/* In the following function call, maximum line length exceed the limit 80.
This is intentional and required for clang compiler such that complete
function call should be in a single line, please do not make it
multi-line. */
execl (prog, /* tbreak-execl */ prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0);
{
static char * argv[] = {
(char *) "",
(char *) "execv arg1 from foll-exec",
(char *) 0};
argv[0] = prog;
printf ("foll-exec is about to execv(execd-prog)...\n");
execv (prog, argv); /* tbreak-execv */
}
}