You can attach gdb to any process. Debug information is not needed unless you want nice things like knowing which lines of code you are stepping through.
You can use 'gcore' (from gdb) to dump the process memory (on Linux) - it tries to create a core file as if it crashed, without crashing it. It's not 100% reliable it sometimes fails - not entirely sure why - but often works.
Then as above you dont really need to understand the memory or variables with debug symbols (though on Linux they generally are available.. and increasingly on the newest distros will automatically be downloaded by debuginfod). You can jsut grep for the text you are looking for and likely it's roughly together in memory.
On macOS most binaries now use the hardened runtime which prevents attaching a debugger by default, so you can only attach to arbitrary processes when SIP is disabled.