<p dir="ltr">Try checking if name is nullptr:</p>
<p dir="ltr">ns3::ndn::Name name = entry-> GetPrefix();</p>
<p dir="ltr">if(name != nullptr)<br>
  name.toUri();<br>
else<br>
  cout<<"ooops!"<<endl;</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Nov 21, 2016 1:18 AM, "Alex Afanasyev" <<a href="mailto:aa@cs.ucla.edu">aa@cs.ucla.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On Nov 20, 2016, at 10:15 PM, ZHANG, Lu <<a href="mailto:lu.zhang@fuji.waseda.jp">lu.zhang@fuji.waseda.jp</a>> wrote:<br>
><br>
> Hi all,<br>
><br>
> I would like to print out the prefix name in PIT on to screen by using the toUri() function in Name class. The topology is simple as below:<br>
><br>
><br>
>  *      +----------+     10Mbps      +--------+     10Mbps    +----------+<br>
>  *      | consumer | <------------> | router | <------------> | producer |<br>
>  *      +----------+         10ms      +--------+          10ms   +----------+<br>
>  *<br>
><br>
><br>
> Part of my program is like below:<br>
><br>
>   Ptr<ndn::Pit> pit = nodes.Get(1)->GetObject<ndn::<wbr>Pit> ();<br>
>   Ptr<ndn::pit::Entry> entry = pit->Find(ns3::ndn::Name("/<wbr>prefix"));<br>
>   ns3::ndn::Name name = entry-> GetPrefix();<br>
>   name.toUri();<br>
><br>
> When executing compile command ./waf --run 1 --vis I got below output:<br>
><br>
> Command ['/home/11/ndnSIM/ns-3/build/<wbr>scratch/1', '--<wbr>SimulatorImplementationType=<wbr>ns3::VisualSimulatorImpl'] terminated with signal SIGSEGV. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>").<br>
><br>
> Any one have clue on why this happens or how should I use the toUri() function?<br>
<br>
You can check to run the scenario in the debugger using the suggested command, but I would suspect that you're simply getting a segfault because there is no "/prefix" entry in the PIT (Find returns NULL and then you're dereferencing NULL).<br>
<br>
---<br>
Alex<br>
<br>
<br>
______________________________<wbr>_________________<br>
ndnSIM mailing list<br>
<a href="mailto:ndnSIM@lists.cs.ucla.edu">ndnSIM@lists.cs.ucla.edu</a><br>
<a href="http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim" rel="noreferrer" target="_blank">http://www.lists.cs.ucla.edu/<wbr>mailman/listinfo/ndnsim</a><br>
</blockquote></div></div>