Sorry, because in previous posts, it seems code was not exactly the same as source code.
I now came to the following conclusion:
main (argc=2, argv=0x1032e24) at pgrep.c:935
935 procs = select_procs (&num);
select_procs (num=0x1032d60) at pgrep.c:489
494 pid_t saved_pid = 0; /* for new/old support */
495 int matches = 0;
496 int size = 0;
498 pid_t myself = getpid();
499 struct el *list = NULL;
(gdb) p myself
$1 = 19024
500 long cmdlen = sysconf(_SC_ARG_MAX) * sizeof(char);
(gdb) p _SC_ARG_MAX
$2 = _SC_ARG_MAX
(gdb) p sizeof(char)
$3 = 1
(gdb) p sysconf(_SC_ARG_MAX)
'sysconf' has unknown return type; cast the call to its declared return type
501 char *cmdline = xmalloc(cmdlen);
(gdb) p cmdlen
$4 = -1
I am convinced sysconf(_SC_ARG_MAX) returned -1 (I believe in unsigned value 4294967295)... and it try to allocate that value.
So -1 surely means error for sysconf.
Need to figure out what sysconf(_SC_ARG_MAX) is....
Maximum length of arguments for the exec*() functions,
in bytes, including environment data.
Now... for the details how I was able to get there... And I feel I may not have been doing it the most effective way.
did something like:
#DEB_BUILD_OPTIONS="nostrip noopt" apt -b source procps
root@kibar:~/procps-3.3.16# file /usr/bin/pgrep
/usr/bin/pgrep: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld.so, BuildID[sha1]=d8ba18308f63edfc63d24003d9dda11fcfa8e75e, for GNU/Hurd 0.0.0, with debug_info, not stripped
[made sure with debug_info, not stripped is there]
#cd some new (empty) directory
#apt-get source procps
# cd procps-3.3.16/
(gdb) set args something_not_existing
(gdb) break main
s [for step] repeated many times until I get on the right line, as shown in beginning of this message