Advanced operating system experiment 2-process scheduling and switching analysis

First, write the application program to make it contain three processes, output three letters respectively. I don't know where to start. First, study the example that the teacher in class says. The code is as follows

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <pthread.h>
 4 
 5 void loop(){
 6   while(1);
 7 }
 8 
 9 void *p1(){
10   printf("thread-1 starting\n");
11   loop();
12 }
13 
14 void *p2(){
15   printf("thread-2 starting\n");
16   loop();
17 }
18 
19 void main(){
20   int pid1, pid2;
21   pthread_t t1,t2;
22   void *thread_result;
23 
24   printf("main starting\n");
25 
26   if (!(pid1 = fork())){
27     printf("child-1 starting\n");
28     loop();
29     exit(0);
30   }
31 
32   if (!(pid2 = fork())){
33     printf("child-2 starting\n");
34     loop();
35     exit(0);
36   }
37 
38   pthread_create(&t1, NULL, p1, NULL);
39   pthread_create(&t2, NULL, p2, NULL);
40   
41   pthread_join(t1, &thread_result);
42   pthread_join(t2, &thread_result);
43 
44   int status;
45   waitpid(pid1, &status, 0);
46   waitpid(pid2, &status, 0);
47   printf("main exiting\n");
48   exit(0);
49 }

The operation results are as follows

1 / # tmp/do-fork &
2 main starting
3 child-1 starting
4 child-2 starting
5 thread-1 starting
6 thread-2 starting
7 / #

All kinds of questions come up:

The grammar in C language can't be understood completely. The place of pointer is blurred. Review it and feel * and & just like inverse operation.

Pthread? Is used to declare the thread ID.

! (pid1 = fork()) what do you mean? According to the context, create a child process and return 0 to execute the if statement, but if fork() is executed successfully, it returns two values. The child process returns 0 and the parent process returns the ID of the child process. In addition, how can the assignment expression be reversed? Because it doesn't affect the meaning, skip

Fork returns the process id of the newly created sub process. We can judge whether the current process is a child process or a parent process by the value returned by fork. Quote a netizen to explain why the value of fpid is different in the parent-child process. "In fact, it is equivalent to a linked list. The process forms a linked list. The fpid of the parent process (P means point) points to the process id of the child process. Because the child process has no child process, its fpid is 0

Pthread_create is a function of creating threads for Unix like operating systems (Unix, Linux, Mac OS X, etc.). Its function is to create a thread (in fact, to determine the entry point to call the thread function). After the thread is created, it starts to run the relevant thread function. The return value of pthread_create indicates success and returns 0; it indicates error and returns - 1. The first parameter is to point to a thread identifier Of Pointer . The second parameter is used to set the thread properties. The third parameter is the starting address of the thread run function. The last parameter is the one that runs the function.
Pthread ou join() function, which waits in a blocking manner for the thread specified by thread to end. When the function returns, resources that are waiting for the thread are reclaimed. If the thread has ended, the function returns immediately. And the thread specified by thread must be joinable. Parameters: Thread: thread identifier , that is, thread ID, which identifies the unique thread. retval: a user-defined pointer used to store the return value of the waiting thread. Return value: 0 for success. Failed. The error number is returned. If there is no pthread "join in the code Main thread It will end soon so that the whole process ends, so that the created thread ends without the opportunity to start execution. After joining pthread ﹣ join, the main thread will wait until the waiting thread finishes itself, so that the created thread has the opportunity to execute.

waitpid will temporarily stop the current process Until a signal arrives or the subprocess ends.

How can I jump out if I execute loop and loop all the time?

At this point, I still don't know the sequence of program flow. I won't imitate it. It's hard to make progress

But I had no choice but to ask others for help. With his help, I wrote abc.c

The next step is to compile and test the above programs in Ubuntu. How to compile and test them? I don't know. Let's run it

[

7. Start gcc to compile the code.
gcc helloworld.c -o execFile (this step will generate a file of execFlie, which can be viewed with ls)
8. If there is an error, the system will prompt, press the direction key to retrieve the command of gedit helloworld.c, press enter, pop up the text box, modify the code according to the system prompt, and remember to save after completion,
Close the text box.
9. operation
. / execFlie will start running

]

When using putty to connect to the virtual machine with ssh, there is always a problem. It can't be connected. After the test, it seems that after a terminal prompts the information after the connection fails, you can connect again

After execution, I found that there was no problem with the program. My question is how the undefined function like fork() can be executed. I can try the teacher's program and abc.c with vscode in windows environment

 

Reload the expansion package, it's not solved (sprawling, I'm afraid of difficulties in this situation at home)

I searched the Internet. It seems that there are some methods, but I don't want to try them. Now the experiment is important

Enter the gcc command as follows

 

What's the long string after gcc? Check, - o: specify the generated output file

We can't find anything else, so we have to stop

Patience is often worn away in this way, but it is precisely to overcome this point and bear to grasp the key points in various uncertain and unknown environments

Next, put abc into qemu

Unzip the file "install.tgz" in rootfs directory. Where is this directory? [root file system in Linux system, referred to as rootfs] but I found the rootfs of qume again. It seems that this is what I used this time

What are the parameters behind the decompression file? [

-x or -- extract or -- get: restore files from backup files;
-v or -- verbose: display the instruction execution process;
-z or -- gzip or -- ungzip: process the backup file through the gzip instruction;
-F < backup file > or-- file =< backup file >: Specifies the backup file;
-C < Directory >: this option is used for decompression. To decompress in a specific directory, you can use this option.

]Not fully understood, but a little improved

Repackage the root file system for generating qume, and put the generated root file system in the image file rootfs.img.gz

Run the qume virtual machine, run and test the application abc in the command interpreter of the virtual machine. Because the loop execution cannot exit, the CTRL C cannot, the esc cannot, and the enter cannot. I don't know how to do anything else

Reopen a terminal. It's strange that you can't see the process that just ran abc. Turn off the terminal. It may be that you turn off all the processes running in it, as shown in the following figure

 

Due to the lesson just learned, all scripts are not saved. Change the settings of putty

 

 

Try to know, do not change, the default copy paste the fastest. You can change the number of saved lines in the window

abc no problem, move on to the next step

Start debugging and set all required kernel breakpoints

In view of the reset of the breakpoint, it is planned to slightly modify the 0.gbd used last time. First, copy a file, name it a new name, and check[

-The i and f options are the opposite. You will be prompted for confirmation before overwriting the target file. When you answer y, the target file will be overwritten. It is an interactive copy.

-r if the given source file is a directory file, then cp will recursively copy all subdirectories and files under the directory. The target file must be a directory name at this time.

mv dir1 newdir / / dir1 moves to the current directory and changes its name to newdir

]

Just a few lines from the start

1 1 target remote localhost:1234 
2 2 dir ~/aos/lab/busybox 
3 3 add-symbol-file ~/aos/lab/busybox/busybox_unstripped 0x8048400 

 

Start up

 1 nudt@ubuntu:~/aos/lab/cur$ gdb vmlinux -x ~/aos/lab/1.gdb
 2 GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
 3 Copyright (C) 2014 Free Software Foundation, Inc.
 4 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 5 This is free software: you are free to change and redistribute it.
 6 There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
 7 and "show warranty" for details.
 8 This GDB was configured as "x86_64-linux-gnu".
 9 Type "show configuration" for configuration details.
10 For bug reporting instructions, please see:
11 <http://www.gnu.org/software/gdb/bugs/>.
12 Find the GDB manual and other documentation resources online at:
13 <http://www.gnu.org/software/gdb/documentation/>.
14 For help, type "help".
15 Type "apropos word" to search for commands related to "word"...
16 Reading symbols from vmlinux...done.
17 /home/nudt/aos/lab/1.gdb: No such file or directory.
18 (gdb)

 

To execute an executable file, you only need to trace the call of the ordinary process to this function, how to reflect the ordinary process, and find the last experiment [the mm value of the members of the task struct structure of all kernel threads is 0, if the value is not 0, it means that it is an ordinary process]

Start and end of scheduling: how does the entry and exit of the function ﹣ schedule reflect? b. file name of the function: the line number of the last line of the function. The last line refers to the line number of}. How can I know the file name and the line number of the last line? I can't find them on the Internet. Please consult others. [the original file name can be seen when setting the breakpoint, so I can find the line number by going to the corresponding directory]. One. / run s has been run. This terminal should not look good, because there are more and more breakpoints set, or you need to open another terminal. / run. Go to the new one to see if there is any problem with running twice? Ask the God, go to the outer virtual machine and don't need to look in the qume. It's said that nothing can be seen in the qume, which needs to be practiced. Where is the kernel folder? [ linux kernel By default, it is stored in / boot, and the kernel information can be viewed in / usr/src. However, when you go to the boot, you will not see files such as "vmlinux" or "vmlinuz" in the boot folder (/ boot). Both are compiled Linux kernels. What ends with "z" is compressed. "vm" represents virtual memory. On the SPARC processor system, the user can see a zImage file. A small number of users can find a bzImage file, which is also a compressed Linux kernel. No matter which file the user has, these boot files cannot be changed unless the user knows what they are doing. Otherwise, the system will become unable to boot, that is to say, the system will not start. ]

 

 

 

 

 

[not here, but the directory corresponding to qume] it means that I didn't understand. When I followed the tutorial, I did my own operation

After entering core.c, I saw that it's not the code, but the following. I'm blind. It looks like a version of the update log [you can turn down the page], and I feel a little lack of exploration spirit. I'll know if I try, and I have to ask others

 

 

Jump to the specified line number [: set nu plus line number,: number line number jump, / xxx search]

 

 

The preliminary work of adding a breakpoint to the end of a function is finally finished. There are two ways to write a file directory: one is to imitate what he wrote on it, the other is to complete it. I wrote it all first and reported an error

 

 

Another expression, still the same mistake

 

 

Go to check the problem of Make breakpoint pending on future shared library load?. I dare not try the online tutorial because I don't know what I'm doing. I'm afraid it's messy. It suddenly occurred to me that the sentence was wrong

 

 

Finally, I succeeded. I started from abc to qume in the morning, only now. Take a rest

In the afternoon, continue to add breakpoints and start process switching. It seems that the scripting language does not support comments

 

 

The start of interrupt processing, clock interrupt and other interrupts, SMP APIC timer interrupt is a function with few data on the Internet.

The end of interrupt and exception starts from the preparation of two functions. The real end is the last, but it may also be the end of system call.

The beginning and end of soft interrupt processing, the entry and exit of functions, are more experienced in how to set the exit.

 

 

 

 

 

Start of page missing exception.

The device does not have an unexpected start.

The start and end of the system call exception are recorded in the parameter regs - > Orig ﹤ ax. Sometimes the end of the system call is in restore ﹐ all. Before the end of the system call, the function prepare ﹐ exit ﹐ to ﹐ usermode is usually executed. What is a system call? [system call application program Request to kernel , call the corresponding kernel function Complete the required processing and return the results to the application. ]The do ﹣ fast ﹣ syscall ﹣ 32 function is not in the kernel, but the corresponding entry folder cannot be found in the upper directory, and it cannot be found on the Internet. They said that they could use source insight, but also found that the kernel and arch are the same directory, not to mention the weak foundation, even carelessness has become a pit.

 

 

End position found successfully

 

 

To view the system call number, enter display reg - > ax directly. I don't know if it's OK. Let's continue

 

 

 

 

 

Add and delete nodes in CFS queue

Update the vruntime of the current process. At the end of this function, the clock has been updated, so a breakpoint is added at the end

 

 

Prepare to enter user mode from core

Set the rescheduling flag that needs to deprive the current process

Up to the site, the breakpoint is set

The operation process is as follows

  5 Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64)
  6 
  7  * Documentation:  https://help.ubuntu.com/
  8 New release '16.04.6 LTS' available.
  9 Run 'do-release-upgrade' to upgrade to it.
 10 
 11 Last login: Thu Mar 19 18:03:31 2020 from 192.168.91.1
 12 nudt@ubuntu:~$ cd /home/nudt/aos/lab/cur
 13 nudt@ubuntu:~/aos/lab/cur$ ls
 14 0.gdb          fs           modules.builtin  tmp.bp
 15 arch           include      modules.order    tools
 16 block          init         Module.symvers   ubuntu
 17 certs          ipc          net              usr
 18 COPYING        Kbuild       README           virt
 19 CREDITS        Kconfig      REPORTING-BUGS   vmlinux
 20 crypto         kernel       samples          vmlinux-gdb.py
 21 debian.master  lab          scripts          vmlinux.o
 22 Documentation  lib          security         zfs
 23 drivers        MAINTAINERS  sound
 24 dropped.txt    Makefile     spl
 25 firmware       mm           System.map
 26 nudt@ubuntu:~/aos/lab/cur$ vi 0.gdb
 27 nudt@ubuntu:~/aos/lab/cur$ cp 0.gdb 1.gdb
 28 nudt@ubuntu:~/aos/lab/cur$ ls
 29 0.gdb          firmware     mm               System.map
 30 1.gdb          fs           modules.builtin  tmp.bp
 31 arch           include      modules.order    tools
 32 block          init         Module.symvers   ubuntu
 33 certs          ipc          net              usr
 34 COPYING        Kbuild       README           virt
 35 CREDITS        Kconfig      REPORTING-BUGS   vmlinux
 36 crypto         kernel       samples          vmlinux-gdb.py
 37 debian.master  lab          scripts          vmlinux.o
 38 Documentation  lib          security         zfs
 39 drivers        MAINTAINERS  sound
 40 dropped.txt    Makefile     spl
 41 nudt@ubuntu:~/aos/lab/cur$ vi 1.gdb
 42 nudt@ubuntu:~/aos/lab/cur$ ls
 43 0.gdb          firmware     mm               System.map
 44 1.gdb          fs           modules.builtin  tmp.bp
 45 arch           include      modules.order    tools
 46 block          init         Module.symvers   ubuntu
 47 certs          ipc          net              usr
 48 COPYING        Kbuild       README           virt
 49 CREDITS        Kconfig      REPORTING-BUGS   vmlinux
 50 crypto         kernel       samples          vmlinux-gdb.py
 51 debian.master  lab          scripts          vmlinux.o
 52 Documentation  lib          security         zfs
 53 drivers        MAINTAINERS  sound
 54 dropped.txt    Makefile     spl
 55 nudt@ubuntu:~/aos/lab/cur$ gdb vmlinux -x ~/aos/lab/1.gdb
 56 GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
 57 Copyright (C) 2014 Free Software Foundation, Inc.
 58 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 59 This is free software: you are free to change and redistribute it.
 60 There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
 61 and "show warranty" for details.
 62 This GDB was configured as "x86_64-linux-gnu".
 63 Type "show configuration" for configuration details.
 64 For bug reporting instructions, please see:
 65 <http://www.gnu.org/software/gdb/bugs/>.
 66 Find the GDB manual and other documentation resources online at:
 67 <http://www.gnu.org/software/gdb/documentation/>.
 68 For help, type "help".
 69 Type "apropos word" to search for commands related to "word"...
 70 Reading symbols from vmlinux...done.
 71 /home/nudt/aos/lab/1.gdb: No such file or directory.
 72 (gdb) b do_execve if $lx_current().mm==0
 73 Breakpoint 1 at 0xc114771b: file fs/exec.c, line 1643.
 74 (gdb)
 75 Note: breakpoint 1 also set at pc 0xc114771b.
 76 Breakpoint 2 at 0xc114771b: file fs/exec.c, line 1643.
 77 (gdb) break __schedule
 78 Breakpoint 3 at 0xc16d1192: file kernel/sched/core.c, line 3104.
 79 (gdb) b ~/aos/lab/4.4.6-ubuntu1604/ubuntu1604/kernel/sched/core.c 3188
 80 Function "~/aos/lab/4.4.6-ubuntu1604/ubuntu1604/kernel/sched/core.c 3188" not defined.
 81 Make breakpoint pending on future shared library load? (y or [n]) n
 82 (gdb) b kernel/sched/core.c 3188
 83 Function "kernel/sched/core.c 3188" not defined.
 84 Make breakpoint pending on future shared library load? (y or [n]) n
 85 (gdb) b <kernel/sched/core.c>:<3188>
 86 No source file named <kernel/sched/core.c>.
 87 Make breakpoint pending on future shared library load? (y or [n]) n
 88 (gdb) b kernel/sched/core.c:3188
 89 Breakpoint 4 at 0xc16d177b: file kernel/sched/core.c, line 3188.
 90 (gdb) break __switch_to//When scheduling, this function will be called if the process is switched
 91 Function "__switch_to//When scheduling, this function will be called if the process is switched" not defined.
 92 Make breakpoint pending on future shared library load? (y or [n]) n
 93 (gdb) break __switch_to
 94 Breakpoint 5 at 0xc101564a: file arch/x86/kernel/process_32.c, line 243.
 95 (gdb) b smp_apic_timer_interrupt
 96 Breakpoint 6 at 0xc1034cfe: file arch/x86/kernel/apic/apic.c, line 913.
 97 (gdb) b do_IRQ
 98 Breakpoint 7 at 0xc1017a95: file arch/x86/kernel/irq.c, line 215.
 99 (gdb) b ret_from_intr
100 Breakpoint 8 at 0xc16d4fe0: file arch/x86/entry/entry_32.S, line 254.
101 (gdb) b ret_from_exception
102 Note: breakpoint 8 also set at pc 0xc16d4fe0.
103 Breakpoint 9 at 0xc16d4fe0: file arch/x86/entry/entry_32.S, line 254.
104 (gdb) b restore_all
105 Breakpoint 10 at 0xc16d5096: file arch/x86/entry/entry_32.S, line 362.
106 (gdb) b __do_softirq
107 Breakpoint 11 at 0xc104d9b5: file kernel/softirq.c, line 231.
108 (gdb) b kernel/sched/softirq.c:302
109 No source file named kernel/sched/softirq.c.
110 Make breakpoint pending on future shared library load? (y or [n]) n
111 (gdb) b kernel/softirq.c:302
112 Breakpoint 12 at 0xc104dbf4: file kernel/softirq.c, line 302.
113 (gdb) b do_page_fault
114 Breakpoint 13 at 0xc103f260: file arch/x86/mm/fault.c, line 1295.
115 (gdb) b do_device_not_available
116 Breakpoint 14 at 0xc1016a68: file arch/x86/kernel/traps.c, line 751.
117 (gdb) b do_fast_syscall_32
118 Breakpoint 15 at 0xc100196c: file arch/x86/entry/common.c, line 408.
119 (gdb) b arch/x86/entry/common.c:486
120 Breakpoint 16 at 0xc1001aa9: file arch/x86/entry/common.c, line 486.
121 (gdb) display reg->ax
122 No symbol "reg" in current context.
123 (gdb) commands 15
124 Type commands for breakpoint(s) 15, one per line.
125 End with a line saying just "end".
126 >display reg->ax
127 >end
128 (gdb) commands 16
129 Type commands for breakpoint(s) 16, one per line.
130 End with a line saying just "end".
131 >display reg->ax
132 >end
133 (gdb) b restore_all
134 Note: breakpoint 10 also set at pc 0xc16d5096.
135 Breakpoint 17 at 0xc16d5096: file arch/x86/entry/entry_32.S, line 362.
136 (gdb) b prepare_exit_to_usermode
137 Breakpoint 18 at 0xc1001879: prepare_exit_to_usermode. (4 locations)
138 (gdb) b enqueue_task_fair
139 Breakpoint 19 at 0xc1075feb: file kernel/sched/fair.c, line 4152.
140 (gdb) b dequeue_task_fair
141 Breakpoint 20 at 0xc10748ba: file kernel/sched/fair.c, line 4200.
142 (gdb) b update_curr
143 Breakpoint 21 at 0xc1070ad9: file kernel/sched/fair.c, line 702.
144 (gdb) b kernel/sched/fair.c:734
145 Breakpoint 22 at 0xc1070c81: file kernel/sched/fair.c, line 734.
146 (gdb) b prepare_exit_to_usermode
147 Note: breakpoint 18 also set at pc 0xc1001879.
148 Note: breakpoint 18 also set at pc 0xc10018b7.
149 Note: breakpoint 18 also set at pc 0xc100194d.
150 Note: breakpoint 18 also set at pc 0xc1001a3c.
151 Breakpoint 23 at 0xc1001879: prepare_exit_to_usermode. (4 locations)
152 (gdb) b set_tsk_need_resched
153 Breakpoint 24 at 0xc1069a97: file ./arch/x86/include/asm/bitops.h, line 75.
154 (gdb)

 

 

Close all breakpoints except do_execve[

The variables in gdb are labeled from 1. Different breakpoints are managed by the same variable label. They can be managed by commands such as enable and disable. At the same time, the operation of breakpoint range is supported. For example, some commands accept breakpoint range as parameters.

For example: disable 5-8

]

 

Set breakpoint at the entrance of main function of abc

Create a soft link [create a soft link by adding options – s after ln]

View the starting virtual address of the. test section of abc [objdump command is composed of viewing the target file or executable target file gcc Tools.

--disassemble 
-d 
Disassembles section s of specific instruction machine code from objfile.
-l
--line-numbers 
Mark the corresponding object code with file name and line number, only use with - D, - D or - r- ld The difference between - d and - d is not great. It is useful when debugging at the source level. You need to use debugging and compiling options such as - g when compiling.
--all-headers 
-x 
Displays the available header information, including symbol table, relocation entry. -x is equivalent to - a-f-h-r-t specified at the same time.

]

give the result as follows

 1 abc:     file format elf32-i386
 2 abc
 3 architecture: i386, flags 0x00000112:
 4 EXEC_P, HAS_SYMS, D_PAGED
 5 start address 0x08048d0a
 6 
 7 Program Header:
 8     LOAD off    0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
 9          filesz 0x000a0457 memsz 0x000a0457 flags r-x
10     LOAD off    0x000a0f40 vaddr 0x080e9f40 paddr 0x080e9f40 align 2**12
11          filesz 0x00001040 memsz 0x000023e4 flags rw-
12     NOTE off    0x000000f4 vaddr 0x080480f4 paddr 0x080480f4 align 2**2
13          filesz 0x00000044 memsz 0x00000044 flags r--
14      TLS off    0x000a0f40 vaddr 0x080e9f40 paddr 0x080e9f40 align 2**2
15          filesz 0x00000010 memsz 0x00000028 flags r--
16    STACK off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**4
17          filesz 0x00000000 memsz 0x00000000 flags rw-
18    RELRO off    0x000a0f40 vaddr 0x080e9f40 paddr 0x080e9f40 align 2**0
19          filesz 0x000000c0 memsz 0x000000c0 flags r--
20 
21 Sections:
22 Idx Name          Size      VMA       LMA       File off  Algn
23   0 .note.ABI-tag 00000020  080480f4  080480f4  000000f4  2**2
24                   CONTENTS, ALLOC, LOAD, READONLY, DATA
25   1 .note.gnu.build-id 00000024  08048114  08048114  00000114  2**2
26                   CONTENTS, ALLOC, LOAD, READONLY, DATA
27   2 .rel.plt      00000070  08048138  08048138  00000138  2**2
28                   CONTENTS, ALLOC, LOAD, READONLY, DATA
29   3 .init         00000023  080481a8  080481a8  000001a8  2**2
30                   CONTENTS, ALLOC, LOAD, READONLY, CODE
31   4 .plt          000000e0  080481d0  080481d0  000001d0  2**4
32                   CONTENTS, ALLOC, LOAD, READONLY, CODE
33   5 .text         000753e4  080482b0  080482b0  000002b0  2**4
34 :

 

 

There is a problem, as follows, the address is invalid, please consult the God [hexadecimal, add 0x in front, I took a long time, he solved it in a word]

Set breakpoint

 

Trace to the main function entry

Something went wrong, so we had to restart it

 

 

After finishing the script, we found that there was a problem in the operation, as follows. So we went to breakpoints 5 and 16 respectively. There was nothing special about breakpoints 5 and 16. Two statements displaying the system call number were deleted in 16

 

 

 

 

 

As shown in the figure above, there is another breakpoint. Compare one by one. Previously, press enter more, resulting in another breakpoint. Correct it again. I just don't know how to add commands 14 and 15

As follows,

Why only do_execve is left when the breakpoint is temporarily closed? I'm running now. There are so many breakpoints. It's really troublesome

 

 

Clean up the script

 1 target remote localhost:1234
 2 dir ~/aos/lab/busybox
 3 add-symbol-file ~/aos/lab/busybox/busybox_unstripped 0x8048400
 4 b do_execve if $lx_current().mm==0
 5 break __schedule
 6 b kernel/sched/core.c:3188
 7 break __switch_to
 8 b smp_apic_timer_interrupt
 9 b do_IRQ
10 b ret_from_intr
11 b ret_from_exception
12 b restore_all
13 b __do_softirq
14 b kernel/softirq.c:302
15 b do_page_fault
16 b do_device_not_available
17 b do_fast_syscall_32
18 b arch/x86/entry/common.c:486
19 b restore_all
20 b prepare_exit_to_usermode
21 b enqueue_task_fair
22 b dequeue_task_fair
23 b update_curr
24 b kernel/sched/fair.c:734
25 b prepare_exit_to_usermode
26 b set_tsk_need_resched
27 disable 2-23
28 dir abc
29 add-symbol-file abc/abc 0x080482b0
30 b abc.c:main

 

Here, the breakpoint is set

Start debugging next

Tags: Linux Ubuntu Makefile Unix

Posted on Fri, 20 Mar 2020 10:49:24 -0700 by Fallen_angel