* [multiprocess] Linux-nat multiprocess switch
@ 2008-11-27 9:44 teawater
2008-11-27 9:54 ` Stan Shebs
0 siblings, 1 reply; 3+ messages in thread
From: teawater @ 2008-11-27 9:44 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1524 bytes --]
Hi,
I got and test the multiprocess branch. And can't find a interface to
switch the process.
So I make this example patch make multiprocess be switched in
linux-nat. It still have a lot of bugs.
I will make it better if you guys like it.
Example:
(gdb) list
During symbol reading, DW_AT_name missing from DW_TAG_base_type.
5 #include <unistd.h>
6 #include <errno.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include <stdint.h>
10
11 int
12 main(int argc,char *argv[],char *envp[])
13 {
14 pid_t pid = fork ();
(gdb)
15
16 if (pid == 0) {
17 while (1) {
18 printf ("%d: C\n", getpid ());
19 sleep (2);
20 }
21 }
22 else {
23 while (1) {
24 printf ("%d: F\n", getpid ());
(gdb)
25 sleep (2);
26 }
27 }
28
29 return (0);
30 }
31
(gdb) set detach-on-fork off
(gdb) set follow-fork-mode child
(gdb) r
Starting program: /home/teawater/multiprocess/a.out
9004: C
9001: F
9004: C
9001: F
9004: C
9001: F
Program received signal SIGINT, Interrupt.
0xb7fe3410 in __kernel_vsyscall ()
(gdb) info inferiors
3 9004 a.out
* 2 9001 a.out
1 0 #a.out# /home/teawater/multiprocess/a.out
(gdb) b 18
Breakpoint 1 at 0x8048433: file 1.c, line 18.
(gdb) c
Continuing.
9004: C
9001: F
9004: C
9001: F
Program received signal SIGINT, Interrupt.
0xb7fe3410 in __kernel_vsyscall ()
(gdb) switch-inferior 3
(gdb) c
Continuing.
9001: F
Breakpoint 1, main (argc=<value optimized out>, argv=<value optimized out>,
envp=<value optimized out>) at 1.c:18
18 printf ("%d: C\n", getpid ());
Thanks,
Hui
[-- Attachment #2: inferior-switch.txt --]
[-- Type: text/plain, Size: 1421 bytes --]
--- gdb.orig/inferior.c
+++ gdb/inferior.c
@@ -26,6 +26,7 @@
#include "gdbthread.h"
#include "ui-out.h"
#include "observer.h"
+#include "regcache.h"
void _initialize_inferiors (void);
@@ -1124,6 +1125,29 @@
}
void
+switch_inferior_command (char *args, int from_tty)
+{
+ struct inferior *inf;
+ int pid;
+ ptid_t ptid;
+
+ /* Get ptid. */
+ get_inferior_or_pid (args, &inf, &pid);
+ if (pid <= 0)
+ {
+ printf_unfiltered (_("Can't switch to inferior %s\n"), args);
+ }
+ ptid = ptid_build (pid, pid, 0);
+
+ if (ptid_equal (ptid, inferior_ptid))
+ return;
+
+ inferior_ptid = ptid;
+ reinit_frame_cache ();
+ registers_changed ();
+}
+
+void
_initialize_inferiors (void)
{
add_com ("add-inferior", no_class, add_inferior_command, _("\
@@ -1132,6 +1156,9 @@
add_com ("remove-inferior", no_class, remove_inferior_command, _("\
Remove the inferiors in ITSET."));
+ add_com ("switch-inferior", no_class, switch_inferior_command, _("\
+Switch the inferiors in ITSET."));
+
add_com ("name-inferior", no_class, name_inferior_command, _("\
Change the name of inferior OLDNAME to NEWNAME."));
--- gdb.orig/linux-nat.c
+++ gdb/linux-nat.c
@@ -1127,11 +1127,11 @@
{
struct lwp_info *lp;
- init_lwp_list ();
+ //init_lwp_list ();
lp = add_lwp (new_ptid);
lp->stopped = 1;
- init_thread_list ();
+ //init_thread_list ();
add_thread_silent (new_ptid);
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [multiprocess] Linux-nat multiprocess switch
2008-11-27 9:44 [multiprocess] Linux-nat multiprocess switch teawater
@ 2008-11-27 9:54 ` Stan Shebs
2008-11-27 17:27 ` teawater
0 siblings, 1 reply; 3+ messages in thread
From: Stan Shebs @ 2008-11-27 9:54 UTC (permalink / raw)
To: teawater; +Cc: gdb-patches
teawater wrote:
> Hi,
>
> I got and test the multiprocess branch. And can't find a interface to
> switch the process.
> So I make this example patch make multiprocess be switched in
> linux-nat. It still have a lot of bugs.
>
Try the "focus" command. If you have inferiors 3 and 4, then "focus 3",
"focus 4", "focus 3", etc should give you the equivalent switching
effect. (And if it doesn't, it needs to be fixed. :-) )
Stan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [multiprocess] Linux-nat multiprocess switch
2008-11-27 9:54 ` Stan Shebs
@ 2008-11-27 17:27 ` teawater
0 siblings, 0 replies; 3+ messages in thread
From: teawater @ 2008-11-27 17:27 UTC (permalink / raw)
To: Stan Shebs; +Cc: gdb-patches
Thanks Stan.
I tried "focus" with linux-nat and found process didn't switch. Maybe
I can do something with it.
Hui
On Wed, Nov 26, 2008 at 23:54, Stan Shebs <stan@codesourcery.com> wrote:
> teawater wrote:
>>
>> Hi,
>>
>> I got and test the multiprocess branch. And can't find a interface to
>> switch the process.
>> So I make this example patch make multiprocess be switched in
>> linux-nat. It still have a lot of bugs.
>>
>
> Try the "focus" command. If you have inferiors 3 and 4, then "focus 3",
> "focus 4", "focus 3", etc should give you the equivalent switching effect.
> (And if it doesn't, it needs to be fixed. :-) )
>
> Stan
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-27 2:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-27 9:44 [multiprocess] Linux-nat multiprocess switch teawater
2008-11-27 9:54 ` Stan Shebs
2008-11-27 17:27 ` teawater
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox