Liyichao, > It is pretty if you would like to give some use guidance or an example with > this patch.
If your question is, "How do I apply the patch", first you need to fetch it to your local Git clone: git fetch https://gem5.googlesource.com/public/gem5 refs/changes/85/44685/3 and then switch to the new branch with it: git checkout -b change-44685 FETCH_HEAD Now you can build it whatever way you normally do it. Just for one example (assuming ARM, obviously yours can be different): $ scons build/ARM/gem5.debug If your question is, how to start using it, well suppose you have this very simple buggy program demo.c: int *x; int g(void) { return *x; } int f(void) { return g() + 1; } int _start() { x = (int*) 1; return f(); } For our example of ARM, compile it like so: $ arm-linux-gnueabi-gcc -O0 -ggdb -c demo.c $ arm-linux-gnueabi-ld -static -o demo demo.o Now, supposing your gem5 directory is pointed to by $G5DIR, start gem5: $G5DIR/build/ARM/gem5.debug $G5DIR/configs/example/se.py -c demo --wait-gdb=1 This is going to block, waiting for a connection on port 7000. In another terminal start GDB, load the binary program and connect to gem5: $ gdb GNU gdb (GDB) 11.0.50.20210225-git Copyright (C) 2021 Free Software Foundation, Inc. ... (gdb) file demo Reading symbols from demo... (gdb) target remote localhost:7000 Remote debugging using localhost:7000 _start () at demo.c:4 4 int _start() { Now it's sitting at the first instruciton; if you try to continue it will nicely tell you where the SIGSEGV is: (gdb) c Continuing. Program received signal SIGSEGV, Segmentation fault. 0x000100a4 in g () at demo.c:2 2 int g(void) { return *x; } (gdb) bt #0 0x000100a4 in g () at demo.c:2 #1 0x000100c8 in f () at demo.c:3 #2 0x000100f0 in _start () at demo.c:6 Obviously other debuggers work well with this, I gave the example of GDB simply because that's standard reference, but the only limit here is your imagination. I use my own custom debugger I wrote for my [admittedly weird] needs (github://shingarov/SmallRSP if you are curious), a lot of people like Eclipse, etc etc. Hope this helps. Boris -----"Liyichao via gem5-users" <gem5-users@gem5.org> wrote: ----- To: "Boris Shingarov" <shinga...@labware.com>, "gem5 users mailing list" <gem5-users@gem5.org> From: "Liyichao via gem5-users" <gem5-users@gem5.org> Date: 04/21/2021 04:42AM Cc: "Gabe Black" <gabe.bl...@gmail.com>, "Liyichao" <liyic...@huawei.com> Subject: [gem5-users] 答复: Re: How to debug a program in GEM5 FS mode. Thank for reply, I will try to use it. It is pretty if you would like to give some use guidance or an example with this patch.  -----邮件原件----- 发件人: Boris Shingarov [mailto:shinga...@labware.com] 发送时间: 2021年4月21日 16:39 收件人: gem5 users mailing list <gem5-users@gem5.org> 抄送: Liyichao <liyic...@huawei.com>; Gabe Black <gabe.bl...@gmail.com> 主题: Re: [gem5-users] Re: How to debug a program in GEM5 FS mode. Liyichao, In fact, our group have been using that change since at least 2014 and it holds up in pretty complex debugging scenarios. I hope it will be merged soon. I would be really interested to hear whether it will help in your scenario. Boris -----"Gabe Black via gem5-users" <gem5-users@gem5.org> wrote: ----- To: "Liyichao" <liyic...@huawei.com> From: "Gabe Black via gem5-users" <gem5-users@gem5.org> Date: 04/21/2021 02:27AM Cc: "gem5 users mailing list" <gem5-users@gem5.org>, "Gabe Black" <gabe.bl...@gmail.com> Subject: [gem5-users] Re: How to debug a program in GEM5 FS mode. Yeah, I don't think gdb in SE mode handles page faults well, but there was actually a change proposed very recently which should help improve that. You can probably cherry-pick that change locally if you want to try it out. https://urldefense.proofpoint.com/v2/url?u=https-3A__gem5-2Dreview.googlesource.com_c_public_gem5_-2B_44685&d=DwIGaQ&c=sPZ6DeHLiehUHQWKIrsNwWp3t7snrE-az24ztT0w7Jc&r=ecC5uu6ubGhPt6qQ8xWcSQh1QUJ8B1-CG4B9kRM0nd4&m=xGCMssfB_BUGfSEEKV79FCUDjr9ITBsAG0uN2ZjHsFc&s=-MUfR7cD0QU9XSD39_UGYJxOY87eIk_--U4M9pAaCP8&e= Gabe On Tue, Apr 20, 2021 at 11:16 PM Liyichao <liyic...@huawei.com> wrote: Thanks Gabe. I think run gdb inside gem5 is of course a better method but slow speed. In se mode,I also have tried it,but my program in se mode has a page fault panic before segment fault.I think se mode cannot process page fault. 李翼超 charlie Mobile:+86-15858232899 Email:liyic...@huawei.com 发件人: Gabe Black<gabe.bl...@gmail.com> 收件人: gem5 users mailing list<gem5-users@gem5.org> 抄送: Liyichao<liyic...@huawei.com> 主题: Re: [gem5-users] How to debug a program in GEM5 FS mode. 时间: 2021-04-21 14:06:58 Hello, Liyichao. While gdb debugging in gem5 is a great tool, it's a bit limited as far as the sort of debugging you're talking about. It can see the CPU state when you're in user space programs, but it doesn't understand that different user space programs are different things, or know how to look up their symbols, etc. It's intended primarily for debugging the kernel, since that's frankly a more tractable problem. It would be possible to extend that support to give it more insight into what's going on inside the kernel so it can do more in that regard, and while I'd like to do that at some point, that's not anything that will happen soon. If you want to debug a user space program inside gem5, I think your best bet is to debug it in SE mode where the only thing running is your program. SE mode is more approximate than FS mode and can't run every program, but if it can run yours that's probably what you'll want to do. Another option would be to run gdb *inside* gem5, as part of the simulation. I don't know if anybody has tried that, but then gdb should work like it would on a real ARM host, more or less. Gabe On Tue, Apr 20, 2021 at 7:27 PM Liyichao via gem5-users <gem5-users@gem5.org> wrote: Hi All: I am currently debugging a program with an SVE instruction in the FS mode of GEM5. However, a segment error occurs in the program. Therefore, I want to locate which instruction is causing the error and check the contents of the register of the error instruction. What are the debugging methods of GEM5 for applications in FS mode? Because programs with SVE instructions cannot be debugged directly on the ARM server, I want to debug in FS mode of GEM5. Does the Remote GDB support the preceding operations? Are there detailed instructions for REMOTE GDB? The Remote GDB guidance on the GEM5 website is a little brief. TKS. _______________________________________________ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s _______________________________________________ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s _______________________________________________ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s _______________________________________________ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s