Can I debug more finely in gem5? - gem5

In gem5, can I step through my code? Like gdb instead of using DPRINTF to print out certain statements in some places?
1、Now,I found I can debug the gem5 through the command like gdb --args gem5.debug --debug-break = 1000. but I still cann't look the code in the real time. When I use the option of -tui,the error occured as "Cannot enable the TUI when output is not a terminal". but when I use the gdb to debug my Hello_world program like gdb -tui hello_world,The error didn't appear. and I can look the code in the real time.
2、moreover,I cann't set the breakpoint in my hello_world program when debug the gem5. when I use the command like b src/cpu/o3/cpu.cc:567,it works. but if I set the breakpoint in my own hello_world program,the error occurred as "No source file named cleanupspec/hello_world".

For the first question, I have known the answer. Via layout next command, I can look the code in the real time. But command like layout, layout src, etc. didn't work.

Related

Intellij and vscode doesn't run a Hello World java program

like this the program seementer image description here
after i setup intellij i tried to run my first java program but it doesn't work and always shows the message of "Abnormal build process termination"
and i tried to work on vscode but it also doesn't work
Looks like from your output that you named a folder with a ? at the beginning (C:\Users\?...) and apparently Java doesn't like that. Try moving the project in another folder or try renaming it.
(Post the whole output if you can, it's filled with useful info)

Stop command prompt from getting closed after executing a batch file

I used Shell command from Excel VBA to run a certain .bat file. The CMD appears but exits automatically after all lines were executed. I've added the PAUSE command a the end of the bat. file but it's not working. How to stop command prompt from getting automatically closed?
Try using the /K switch to prevent exiting after running the batch file like this:
cmd /K "path to batch file including file name and extension"
e.g.
cmd /K "C:\FOLDER\BATCH FILE.BAT"
or
cmd /K "C:\FOLDER\BATCH FILE.CMD"
Obviously that won't reveal any faults with your batch code, but it won't exit after running - much the same as running the batch file from the command line.
Definitely add some ECHO output lines to indicate progress as it runs and troubleshoot. Perhaps post the file here for more help.
Try opening the command prompt and running the batch file. It is possible that the the dos shell is encountering an error and closing. If the error comes before the execution reaches Pause command, it will not pause for you to read the error and it immediately closes off.
If that doesn't work out, check if you have any exit commands in any of the branches. Alternatively, place echo statements at different places and check if the execution control reaches these echos. This way you can find out if your script if ending at some other branch.
While perhaps not actually answering the posted question, I stumbled upon this question in a search to a very related-question. I was also trying to stop a command prompt from closing as it was erroring out and closing immediately. For me, it was sufficient for me to view the output as what I really wanted was to be able to see the error in order to debug it.
The solution I found was to pipe the output of the command prompt into a text file, like so:
MyScript.bat >> text.txt
This allowed me to see the error I was getting.

Skipping over .asm code in Xcode4 debugger

I'm using Xcode4 and the debugger keeps jumping into .asm code when I select jump over. I don't know .asm and just want the next line of ObjC code. Is there some setting to have it not show the .asm code?
Thanks!
Which debugger you are using? LLVM or GDB. (You can find out at the menu product->edit scheme as shown figure below).
If the debugger is LLDB, try to switch it back to GDB and see that fix your problem.

Shouldn't Xcode/gdb load the ~/.gdbinit file on launch?

I have a ~/.gdbinit file which is loosely based on How do I set these break points in ~/.gdbinit?. Allegedly, gdb is supposed to source ~/.gdbinit when it launches. However, it's not loading mine - I have to stop at an existing breakpoint and type in 'source ~/.gdbinit', and then it loads it. Is there a way to have gdb or Xcode do this automatically?
Xcode possibly invokes gdb as gdb -nx ....
There probably is some setting somewhere in Xcode to change that.

Watching variables in Xcode

I'm trying to watch a variable with Xcode. I'm following the instructions in here by pausing at a breakpoint, selecting Run > Variables View > .... but with the exception of "Enable Data Formatters" the rest of the options are all greyed out. Any ideas?
I'm using Xcode version 3.1.3.
I haven't gotten watchpoints created from the Run menu to work for me either, unfortunately. One thing to be aware of is that when a variable goes out of scope, the watchpoint may become invalid.
If you don't mind getting a little more in-depth, you can use some low-level gdb commands to set a watchpoint for the address of the memory itself. For example, in the guide you linked to, they show how to watch the variable path which is a pointer with the value 0xbfffeb70. To manually set a watchpoint for that address, click in the debugger console (where the debugging output is printed) after the "(gdb)" prompt and type something like this:
watch *((int*)0xbfffeb70)
The cryptic syntax is necessary because gdb expects inputs as C expressions. For a little more detail, visit this link and jump to the section titled "Using hardware watchpoints". (I'm testing on an Intel machine, not sure how PowerPC handles it.) When you set watchpoints this way, Xcode will alert you with a drop-down sheet when a watchpoint is reached and tell you how the value was changed, and gdb will print the same info in the console.
I just ran into this problem. Here is a solution: right click on the variable name and select "View variable in window" from the menu which appears. It should be near the bottom.
Add a breakpoint. Right click in the watch list of the debug area and choose "Add expression..."
If you are getting a different menu, you have to click off of the currently highlighted variable so that nothing is highlighted when you right click.
The Answers given here only work if you use the gdb compiler. For those of you who are looking for an option to set a watchpoint with the lldb compiler I have bad news:
It's not working jet (XCode 4.3.2 with lldb 3.1) even though the lldb docs say you can.
Check out this Email. The lldb commands compared to the gdbs can be found here
I was trying to figure this out in XCode 5. I finally found a "Variables view" button at the bottom right of the output console. It's the little rectangle that will be gray on the left, white on the right if it's not enabled. I'm not sure if this is in XCode 3, but I expect most people have upgraded anyway.