Multiprogram teaser

Stan Shebs
Tue Jul 29 02:29:00 GMT 2008

Here's a little teaser showing the results of me flogging GDB's source 
code. In addition to the fun aspect of listing the main()s of two 
different programs, it points up the the potential confusion of having 
several programs in a session. What I've got so far in my prototype is 
the ability to collect multiple execs from the command line, the 
creation of "exec" objects from which you can select one as "current", 
and some symbol table hacking to restrict lookups to the current executable.

stan@adell:~/mpgdb/linux/gdb$ ./gdb -nx ~/hello ~/goodbye
GNU gdb (GDB)
Attaching objfile /home/stan/hello to exec /home/stan/hello
Attaching objfile /home/stan/goodbye to exec /home/stan/goodbye
(gdb) list main
1    int glob = 45;
3    main() {
4     mailand();
5      foo(glob);
6    printf("goodbye cruel world\n");
7    }
9    foo(int x) {
10      return x + 92;
(gdb) exec /home/stan/hello
Setting current exec to /home/stan/hello.
(gdb) list main
3      if (bar == 0)
4        exit(1);
5    }
7    main()
8    {
9      bar();
10      printf("hello world\n");
11    }


More information about the Gdb mailing list