How can I debug my code effectivelly?

282 views
Skip to first unread message

alceubissoto

unread,
Nov 15, 2016, 7:10:14 PM11/15/16
to Sniper simulator
Hi guys, I'm trying to code a new cache replacement policy, but it would be great if I could debug the code. I tried using LOG_PRINT and enabling the logs, but it didn't work. I tried writing to a file, and also didn't work. Also tried using gdb, but wasn't really successful since i've never used it... 
I would like to be able to see the contents of the cache, and the arrays that are being used in the files cache_set_mypolicy.cc, to make sure i'm implementing it right.

Any suggestions?
Thanks in advance guys =)

Alanoud Alsalman

unread,
Mar 19, 2017, 4:56:50 PM3/19/17
to Sniper simulator
I wish someone would answer to this post as I too have the same questions.

Thank you,
Alan

Wim Heirman

unread,
Mar 20, 2017, 4:57:29 AM3/20/17
to snip...@googlegroups.com
Hi,

printf() debugging is still the easiest way... Logging to a file should also work, but try using an absolute path if you can't find the output file -- with a relative path name it will be written to the simulator's current working directory which isn't necessarily the same as where your prompt is. Using GDB should also work (just add --gdb to the run-sniper command).

Regards,
Wim


--
--
--
You received this message because you are subscribed to the Google
Groups "Sniper simulator" group.
To post to this group, send email to snip...@googlegroups.com
To unsubscribe from this group, send email to
snipersim+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/snipersim?hl=en

---
You received this message because you are subscribed to the Google Groups "Sniper simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snipersim+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

naveed ul Mustafa

unread,
Jan 4, 2018, 2:50:39 AM1/4/18
to Sniper simulator
Hi Wim,

When I run the fft example by putting --gdb option, the workload (that is fft) execution completes with gdb letting me set the breakpoint. How can I set the break point on the source code of sniper?

Following is the output of running the "fft" example with "--gdb" option.

naveed@naveedVM:~/repos/GraphProc/BaseSniper/sniper/test/fft$ make run
cc -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-sse4a -mno-avx -mno-avx2 -I/home/naveed/repos/GraphProc/BaseSniper/sniper/include    -c -o fft.o fft.c
In file included from fft.c:67:0:
/home/naveed/repos/GraphProc/BaseSniper/sniper/include/sim_api.h:79:47: warning: backslash and newline separated by space [enabled by default]
     __asm__ __volatile__ (                    \   
 ^
cc fft.o -lm -static -L/home/naveed/repos/GraphProc/BaseSniper/sniper/lib -pthread  -o fft
../../run-sniper --gdb -n 2 -c gainestown --roi --viz -- ./fft -p 2
[SNIPER] Start
Running /home/naveed/repos/GraphProc/BaseSniper/sniper/pin_kit/intel64/bin/pinbin -mt -injection child -xyzzy -enable_vsm 0 -pause_tool 1 -t /home/naveed/repos/GraphProc/BaseSniper/sniper/lib/pin_sim -c /home/naveed/repos/GraphProc/BaseSniper/sniper/config/base.cfg --general/total_cores=2 --general/output_dir=/home/naveed/repos/GraphProc/BaseSniper/sniper/test/fft --config=/home/naveed/repos/GraphProc/BaseSniper/sniper/config/nehalem.cfg --config=/home/naveed/repos/GraphProc/BaseSniper/sniper/config/gainestown.cfg -g --general/magic=true -g --traceinput/stop_with_first_app=true -g --traceinput/restart_apps=false -g --hooks/numscripts=1 -g --hooks/script0name=/home/naveed/repos/GraphProc/BaseSniper/sniper/test/fft/sim.scripts.py -g --hooks/script0args= -- ./fft -p 2
Reading symbols from /home/naveed/repos/GraphProc/BaseSniper/sniper/pin_kit/intel64/bin/pinbin...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00002b386d7e8d30 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
81    ../sysdeps/unix/syscall-template.S: No such file or directory.
add symbol table from file "/home/naveed/repos/GraphProc/BaseSniper/sniper/lib/pin_sim.so" at
    .text_addr = 0x2b386dc34dc0
    .data_addr = 0x2b386e68caa0
    .bss_addr = 0x2b386e68ea60
Resuming
Executing Python script /home/naveed/repos/GraphProc/BaseSniper/sniper/test/fft/sim.scripts.py
[SNIPER] --------------------------------------------------------------------------------
[SNIPER] Sniper using Pin frontend
[SNIPER] Running pre-ROI region in  CACHE_ONLY mode
[SNIPER] Running application ROI in DETAILED mode
[SNIPER] Running post-ROI region in FAST_FORWARD mode
[SNIPER] --------------------------------------------------------------------------------
[SNIPER] Enabling performance models
[SNIPER] Setting instrumentation mode to DETAILED
[SNIPER] Disabling performance models
[SNIPER] Leaving ROI after 3.57 seconds
[SNIPER] Simulated 1.1M instructions, 0.9M cycles, 1.28 IPC
[SNIPER] Simulation speed 318.3 KIPS (159.2 KIPS / target core - 6283.2ns/instr)
[SNIPER] Sampling: executed 50.23% of simulated time in detailed mode
[SNIPER] Setting instrumentation mode to FAST_FORWARD

FFT with Blocking Transpose
   1024 Complex Doubles
   2 Processors
   65536 Cache lines
   16 Byte line size
   4096 Bytes per page


                 PROCESS STATISTICS
            Computation      Transpose     Transpose
 Proc          Time            Time        Fraction
    0               149             18       0.12081

                 TIMING INFORMATION
Start time                        :      -1844408316
Initialization finish time        :      -1844408135
Overall finish time               :      -1844407986
Total time with initialization    :              330
Total time without initialization :              149
Overall transpose time            :               18
Overall transpose fraction        :          0.12081

[Inferior 1 (process 23854) exited normally]
(gdb)

Thanks for your guidance.


On Monday, March 20, 2017 at 11:57:29 AM UTC+3, Wim Heirman wrote:
Hi,

printf() debugging is still the easiest way... Logging to a file should also work, but try using an absolute path if you can't find the output file -- with a relative path name it will be written to the simulator's current working directory which isn't necessarily the same as where your prompt is. Using GDB should also work (just add --gdb to the run-sniper command).

Regards,
Wim

On 19 March 2017 at 21:56, Alanoud Alsalman <alanoudi...@gmail.com> wrote:
I wish someone would answer to this post as I too have the same questions.

Thank you,
Alan


On Tuesday, November 15, 2016 at 5:10:14 PM UTC-7, alceubissoto wrote:
Hi guys, I'm trying to code a new cache replacement policy, but it would be great if I could debug the code. I tried using LOG_PRINT and enabling the logs, but it didn't work. I tried writing to a file, and also didn't work. Also tried using gdb, but wasn't really successful since i've never used it... 
I would like to be able to see the contents of the cache, and the arrays that are being used in the files cache_set_mypolicy.cc, to make sure i'm implementing it right.

Any suggestions?
Thanks in advance guys =)

--
--
--
You received this message because you are subscribed to the Google
Groups "Sniper simulator" group.
To post to this group, send email to snip...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/snipersim?hl=en

---
You received this message because you are subscribed to the Google Groups "Sniper simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snipersim+...@googlegroups.com.

naveed ul Mustafa

unread,
Jan 4, 2018, 3:05:39 AM1/4/18
to Sniper simulator
Hi Wim and all,

I can set the break point (as a regular gdb usage) by following command.

(gdb) b magic_server.cc:178
Breakpoint 1 at 0x2b7a3077bdc3: file /home/naveed/repos/GraphProc/BaseSniper/sniper/common/system/magic_server.cc, line 178.

However, when issue the "r" command for gdb, I see the following error.

(gdb) r
Starting program: /home/naveed/repos/GraphProc/BaseSniper/sniper/pin_kit/intel64/bin/pinbin
Error in re-setting breakpoint 1: Cannot access memory at address 0x2b7a3077bce0
Error in re-setting breakpoint 1: Cannot access memory at address 0x2b7a3077bce0
Error in re-setting breakpoint 1: Cannot access memory at address 0x2b7a3077bce0
Error in re-setting breakpoint 1: Cannot access memory at address 0x2b7a3077bce0
Error in re-setting breakpoint 1: Cannot access memory at address 0x2b7a3077bce0
E: 4.4 is not a supported linux release
[Inferior 1 (process 24092) exited with code 0377]

Can you please let me know how can I resolve the error?

Thanks
Reply all
Reply to author
Forward
0 new messages