It is not clear from your question what you have tried, and what isn't working. Using your hello and world examples, here's my GDB session doing what I think you want to do:
$ gdb ./hello
GDB Version: 17.1
Reading symbols from ./hello...
(gdb) tbreak 5
Temporary breakpoint 1 at 0x401135: file hello.c, line 5.
(gdb) run
Starting program: /tmp/exec-test/hello
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffa3e8) at hello.c:5
5 system("/tmp/exec-test/world");
(gdb) set follow-fork-mode child
(gdb) break main if (strcmp (basename (argv[0]), "world") == 0)
Breakpoint 2 at 0x401135: file hello.c, line 5.
(gdb) continue
Continuing.
[Attaching after process 3719461 vfork to child process 3719507]
[New inferior 2 (process 3719507)]
[Detaching vfork parent process 3719461 after child exec]
[Inferior 1 (process 3719461) detached]
process 3719507 is executing new program: /usr/bin/bash
process 3719507 is executing new program: /tmp/exec-test/world
Thread 2.1 "world" hit Breakpoint 2, main (argc=1, argv=0x7fffffffa3f8) at world.c:5
5 printf("Hello World\n");
(gdb) info inferiors
Num Description Connection Executable
1 <null> /tmp/exec-test/world
* 2 process 3719507 1 (native) /tmp/exec-test/world
(gdb)
I use set follow-fork-mode child so GDB will follow the child process in a fork rather than the parent. The execve calls will automatically be followed within the same inferior. I think the inferior 2 comes about due to the vfork() call in the shell, but I'm not 100% sure on that.
I use break main if (strcmp (basename (argv[0]), "world") == 0) to create a breakpoint that will only be hit in the world executable. You can do just break main but you'll also hit this in the shell, but just continue to keep going and eventually you'll stop in the correct main function. The conditional breakpoint just means GDB does the check for me. Of course, this relies on basename and strcmp being linked into your executable.
What I don't know is how you'd do this in VS Code, but hopefully they provide a GDB console where you could input the above commands directly.
set fork-follow-mode childandset follow-exec-mode newshould in theory follow the child process. But here's one older question documenting problems: stackoverflow.com/questions/10671229/…/path/to/worldwithout runninghello. If you have more interaction betweenhelloandworld, describe this in your question. I wrote an answer based on a use case I had in the past.worldyou want to run.