Bug 27120 - Step will skip subsequent statements for some libc functions (bug or feature?)
Summary: Step will skip subsequent statements for some libc functions (bug or feature?)
Status: RESOLVED DUPLICATE of bug 27151
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-28 08:31 UTC by Yanyan Jiang
Modified: 2021-01-06 12:25 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yanyan Jiang 2020-12-28 08:31:34 UTC
int main () {
  int res = 0;
  res = (intptr_t)malloc(sizeof(1000)); // L1
  printf("res = %d\n", res);            // L2
  return res;
}

Compiled with -g, optionally -ffreestanding -fno-builtin.

Break point on L1 and step (command: s)
- program ends (with res printed).
- this is also observed for memmove, memcpy (on -ffreestanding -fno-builtin)

Break point on L2 and step (command: s)
- goes into printf.


Looks like a (somewhat tricky) feature tuned (whitelist) for libc? LLDB behaves like my expectation: step on L1 will stop at L2. DWARF debug info (lines) looks correct. 


Affects many versions of gdb/gcc. Reproduced on:

- 11.0.50.20201224-git (GCC 10.2.0)
- Ubuntu 9.2-0ubuntu1~20.04 (GCC 9.3)

Seems duplicate with #25565.
Comment 1 Anonymous 2020-12-28 08:56:42 UTC
In old version of GDB (GNU gdb (GDB) 9.0.50.20191210-git), it behaves as correct. (see PR#25565)

Thus, I think this should be a bug rather than a feature.
Comment 2 Tom de Vries 2021-01-06 12:25:57 UTC
Duplicate.

*** This bug has been marked as a duplicate of bug 27151 ***