Wednesday, July 15, 2015

Basic Yum Commands

Basic Yum Commands and how to use them

All the information here is taken from this page for my reference: http://yum.baseurl.org/wiki/YumCommands

This is not an exhaustive list of all yum commands but it is a list of the basic/common/important ones. For a complete list see the yum man page.
   yum list [available|installed|extras|updates|obsoletes|all|recent] [pkgspec] 
This command lets you list packages in any repository enabled on your system or installed. It also lets you list specific types of packages as well as refine your list with a package specification of any of the package's name, arch, version, release, epoch.

   yum list
By default 'yum list' without any options will list all packages in all the repositories and all the packages installed on your system. Note: 'yum list all' and 'yum list' give the same output.
   yum list available
Lists all the packages available to be installed in any enabled repository on your system.
   yum list installed
This is equivalent to rpm -qa. It lists all the packages installed on the system.
   yum list extras
This command lists any installed package which no longer appears in any of your enabled repositories. Useful for finding packages which linger between upgrades or things installed not from a repo.
   yum list obsoletes
This command lists any obsoleting relationships between any available package and any installed package.
   yum list updates
This command lists any package in an enabled repository which is an update for any installed package.
   yum list recent
This command lists any package added to any enabled repository in the last seven(7) days.
   yum list pkgspec
This command allows you to refine your listing for particular packages.

Examples of pkgspecs:
      yum list zsh 
      yum list joe\* 
      yum list \*.i386 
      yum list dovecot-1.0.15 

   yum install/remove/update
....

   yum check-update
Exactly like yum list updates but returns an exit code of 100 if there are updates available. Handy for shell scripting.

   yum grouplist
   yum groupinfo
   yum groupinstall
   yum groupupdate
   yum groupremove
Please see the YumGroups page on this wiki for information about the above commands.

   yum info
This displays more information about any package installed or available. It takes the same arguments as yum list but it is best run with a specific package name or glob. Example:
     $ yum info yum
     Installed Packages
     Name       : yum
     Arch       : noarch
     Version    : 3.2.20
     Release    : 3.fc10
     Size       : 2.5 M
     Repo       : installed
     Summary    : RPM installer/updater
     URL        : http://yum.baseurl.org/
     License    : GPLv2+
     Description: Yum is a utility that can check for and automatically download and
                : install updated RPM packages. Dependencies are obtained and downloaded
                : automatically prompting the user as necessary.

  yum search
This allows you to search for information from the various metadata available about packages. It can accept multiple arguments. It will output the packages which match the most terms first followed by the next highest number of matches, etc. Specifically yum search looks at the following fields: name, summary, description, url. If you're searching for what package provides a certain command try yum provides instead.
Search example:
$ yum search python rsync ssh
========================= Matched: python, rsync, ssh ==========================
rdiff-backup.i386 : Convenient and transparent local/remote incremental
                  : mirror/backup

============================ Matched: python, rsync ============================
cobbler.noarch : Boot server configurator

============================= Matched: python, ssh =============================
denyhosts.noarch : A script to help thwart ssh server attacks
pexpect.noarch : Pure Python Expect-like module
python-paramiko.noarch : A SSH2 protocol library for python
python-twisted-conch.i386 : Twisted SSHv2 implementation

============================= Matched: rsync, ssh ==============================
duplicity.i386 : Encrypted bandwidth-efficient backup using rsync algorithm
pssh.noarch : Parallel SSH tools
   yum provides/yum whatprovides
This command searches for which packages provide the requested dependency of file. This also takes wildcards for files. Examples:
$ yum provides MTA
2:postfix-2.5.5-1.fc10.i386 : Postfix Mail Transport Agent
Matched from:
Other       : MTA

exim-4.69-7.fc10.i386 : The exim mail transfer agent
Matched from:
Other       : MTA

sendmail-8.14.3-1.fc10.i386 : A widely used Mail Transport Agent (MTA)
Matched from:
Other       : Provides-match: MTA


$ yum provides \*bin/ls
coreutils-6.12-17.fc10.i386 : The GNU core utilities: a set of tools commonly
                            : used in shell scripts
Matched from:
Filename    : /bin/ls

   yum shell
....

   yum makecache
Is used to download and make usable all the metadata for the currently enabled yum repos. This is useful if you want to make sure the cache is fully current with all metadata before continuing.

   yum clean
During its normal use yum creates a cache of metadata and packages. This cache can take up a lot of space. The yum clean command allows you to clean up these files. All the files yum clean will act on are normally stored in /var/cache/yum.
Example commands and what they do:

        yum clean packages
This cleans up any cached packages in any enabled repository cache directory.

        yum clean metadata
This cleans up any xml metadata that may have been cached from any enabled repository.
        yum clean dbcache
Yum will create or download some sqlite database files as part of its normal operation. This command clean up the cached copies of those from any enabled repository cache.
        yum clean all
Clean all cached files from any enabled repository. Useful to run from time to time to make sure there is nothing using unnecessary space.

If you cannot install certain extra packages, it means your current Yum repositories do not have them. You can add another repository accessible to Yum. Just download the repo file and put it under /etc/yum.repo.d/. To find the repository that would contain your package, just google for "packagename yum repository". Usually there should be a link to download the repo file.

Run  >yum listrepo     will list all the repositories installed on your system.

To find out which repository contain the package you want to install, you can run
>yum list available | grep packagename

Example of downloading a yum repo:
wget -O /etc/yum.repos.d/bigtop.repo http://archive.apache.org/dist/bigtop/bigtop-0.5.0/repos/[centos5|centos6|fedora17]/bigtop.repo

Saturday, March 28, 2015

how to stream your computer desktop to your TV using VLC and Serviio?

What you need to have?

1. WIFI or internet enabled TV. This TV must be connected to you local network.
2. Install VLC media player and Serviio media server on your computer. You can Google for these programs. They are free programs.


Standard frame or field rates
ATSC table 3 defines the following frame rates for digital high-definition television.[23]
23.976 Hz (film-looking frame rate compatible with NTSC clock speed standards)
24 Hz (international film and ATSC high-definition material)
25 Hz (PAL, SECAM film, standard-definition, and high-definition material)
29.97 HZ (NTSC standard-definition material)
59.94 HZ (ATSC high-definition material)
60 Hz (ATSC high-definition material)
The optimum format for a broadcast depends upon the type of videographic recording medium used and the image's characteristics. For best fidelity to the source the transmitted field ratio, lines, and frame rate should match those of the source.
Although PAL, SECAM and NTSC frame rates technically apply only to standard definition television, not HD, with the roll out of HD, countries maintained the heritage of their former systems. HDTV in former PAL countries operates at a frame rate of 50 Hz and HDTV in former NTSC countries operates at 60 Hz.[24]


Use the information above as a reference to tell VLC what frame rate to use.
Higher rate will have better quality and require more computing resources. This information will make more sense once you have looked at the sample batch file I have created below. If you looked at it, you will see that I stream the desktop at 24 frames per second. You can tweak this number around depending on the computing power of your computer.

After you have installed the VLC media player, you need to install the following components to help capture and send both audio and desktop screenshots to your TV in real time.

1. install the screen capturer recorder
2. install virtual-audio-capturer as well if it is not installed




3. Create a batch file using the sample batch content mentioned below.
This batch file will launch the VLC program with the appropriate parameters to stream your desktop to your TV.


4. After running the batch file  created in previous step,  paste the HTTP address of your computer to the Serviio media server under the online sources tab. Notice you have to use the ip address of the local machine in order for the DLNA devices on your network to see the online source. Running the batch file should launch VLC program. Notice the port number has to be the same as the one you specified in the patch file.




How does all of this work? In summary, your TV is actually connecting to the Serviio media server, and the content streamed to your TV is created by the VLC media player in conjunction with the related components mentioned above. How does your TV connect to the Serviio media server? If you have setup correctly, your TV should be able to detect the media server in your local network. There should be an option to connect to a media server in your TV settings.


Batch File:
Copy the content below the dash line to a batch file.
This bat is used to stream the desktop with VLC using HTTP.
A corresponding player must be started using HTTP.
Use Serviio to stream the content of your desktop to your TV. Most players will recognize Serviio as a media server.
In the example below, VLC will capture and stream the desktop at port 8081. You need to put this url localhost:8081 as online stream source in your Serviio setting. Once you have setup your Serviio media server, you can run this batch file to stream the desktop content.
Notice in the batch, I have various samples. One of the differences is the height and width of the image sent to the TV. You may want to adjust these two settings to match the size of your TV.
---------------------------
@echo off





"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv dshow:// --sout=#transcode{venc=ffmpeg,vcodec=mp2v,vb=10000,fps=24,scale=0.5,width=1280,acodec=mp3,ab=192,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=:8081} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep   :dshow-vdev=screen-capture-recorder :dshow-adev="virtual-audio-capturer"  :dshow-caching=2000


REM "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv dshow:// --sout=#transcode{venc=ffmpeg,vcodec=mp2v,vb=10000,fps=24,width=1366,height=768,acodec=mp3,ab=192,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=:8081} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep   :dshow-vdev=screen-capture-recorder :dshow-adev="virtual-audio-capturer"  :dshow-caching=2000
REM "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv dshow:// --sout=#transcode{venc=ffmpeg,vcodec=mp2v,vb=10000,fps=30,width=1440,height=960,acodec=mp3,ab=192,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=:8081} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep   :dshow-vdev=screen-capture-recorder :dshow-adev="virtual-audio-capturer"  :dshow-caching=1000
REM "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv dshow:// --sout=#transcode{venc=ffmpeg,vcodec=mp2v,vb=10000,fps=30,width=1660,height=900,acodec=mp3,ab=192,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=:8081} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep   :dshow-vdev=screen-capture-recorder :dshow-adev="virtual-audio-capturer"  :dshow-caching=100
REM "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv dshow:// --sout=#transcode{venc=ffmpeg,vcodec=mp2v,vb=10000,fps=30,width=1600,height=900,acodec=mp3,ab=192,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=:8081} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep   :dshow-vdev=screen-capture-recorder :dshow-adev="virtual-audio-capturer"  :dshow-caching=100
REM "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv dshow:// --sout=#transcode{venc=ffmpeg,vcodec=mp2v,vb=10000,fps=30,width=1680,height=1050,acodec=mp3,ab=192,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=:8081} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep   :dshow-vdev=screen-capture-recorder :dshow-adev="virtual-audio-capturer"  :dshow-caching=100
REM NOT WORKING
REM "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv dshow:// --sout=#transcode{venc=ffmpeg,vcodec=mp2v,vb=10000,fps=30,width=1600,height=1200,acodec=mp3,ab=192,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=:8081} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep   :dshow-vdev=screen-capture-recorder :dshow-adev="virtual-audio-capturer"  :dshow-caching=100
REM Best resolution for my Sony TV
REM 1) "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv dshow:// --sout=#transcode{venc=ffmpeg,vcodec=mp2v,vb=10000,fps=30,width=1440,height=1080,acodec=mp3,ab=192,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=:8081} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep   :dshow-vdev=screen-capture-recorder :dshow-adev="virtual-audio-capturer"  :dshow-caching=100
REM 2) "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv dshow:// --sout=#transcode{venc=ffmpeg,vcodec=mp2v,vb=10000,fps=30,width=1440,height=960,acodec=mp3,ab=192,channels=2,samplerate=44100}:std{access=http,mux=ts,dst=:8081} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep   :dshow-vdev=screen-capture-recorder :dshow-adev="virtual-audio-capturer"  :dshow-caching=100
:Exit


Thursday, March 5, 2015

How to debug segfaults and exceptions using gdb?

This article is intended for advanced users or developers. Before we go into the details of troubleshooting  using gdb, I will talk about some basic stuff first.


When a program segfaults in Linux, a core dump file will be created.

If you are not sure if your program is segfault, you can run

>dmesg | tail

dmesg will mention about your segfault program at the end if it does segfault.


If no core file is generated, you need to tell the system to generated the core file.

>ulimit -u  -- set the size of the crash dump file.

>ulimit -c unlimited  -- if core file is not generated, run this command.


If this is done correctly and your program does crash, you can use gdb to load the crash or core dump file to see what's causing the crash.

gdb -c crashdumpfile program.exe

//-args use this if program.exe has parameters

 [ -args program.exe args1 args2 ... ]



Some handy programs to know:

>ldd programname  //check and list all the dependencies files (*.so).

>objdump programname   //dump the whole binary

>objdump -p programname | grep NEEDED  //list all libraries dependencies

>sudo pldd 1234  //will list all the library dependencies of a running process id 1234

>pmap 1234 -p //will list all the dependencies and their actual paths


I will talk in more details on how to troubleshoot using these programs in another article.


Moving on to the case where the program does not segfault.

The program may mysteriously exit or return none-zero exit code.

Now you want to know what is causing the problem.

You may not know where to start or sometimes it is nearly impossible to go line by line to find the issue. The program can be so huge and take a long time to run that it can be very frustrating if you have to run gdb more than once to reproduce or troubleshoot the issue.

The first thing to think about is if there are any exceptions being thrown in the code. Normally this would cause a crash if the exception is not being handled, but since the program does not crash it means that the exception is being handled and a non zero exit code is returned.

The next question is how do I know what exception to catch or what function to break?

You don't need to.

You can tell gdb to break at all exceptions being thrown and at the callers throwing the exceptions.

Below is an example showing the useful commands in gdb along with the case on how to find where the exception is being thrown. I highlighted the ones related to catching exceptions.


Debug using gdb

----------------------------------

gdb -c crashdumpfile program.exe

//-args use this if program.exe has parameters

 [ -args program.exe args1 args2 ... ]


>b programname_methodname --break at method name

>bt -- backtrace, works ok in release build as well.

>p variable name

>n -- next

>s -- step into

>list - --print lines just before the lines last printed

>list linenum -print lines centered around linenumber

>b __raise_exception  -- break at the code where the exception is thrown, notice sometimes catch catch won't give you this information

this is the step just before an exception handler is called.

>info break -- list the current catchpoints

>delete //delete all breakpoints

>disable //disable all breakpoints

>enable breakpoint#  //enable given breakpoint number

>continue



When running the program via gdb, the output will also tell you the path to the libraries the program is depending on too.


(gdb) break TestClass::testFunc(int)

Breakpoint 1 at 0x80485b2: file cpptest.cpp, line 16.

(gdb) break test.c:19

Breakpoint 2 at 0x80483f8: file test.c, line 19

Show the next statement that will be executed.

(gdb) where

#0  mystrcpy (copyto=0x259fc6c "*", copyfrom=0x259fddc "ABC") at printch.cpp:27

#1  0x4010c8 in main (argc=3, argv=0x25b0cb8) at printch.cpp:40

The statement at line 27 of the function mystrcpy is the next statement and the function mystrcpy was called by main.


Execute the rest of the current function; that is, step out of the function.

(gdb) finish

(gdb) info variables -- show all global and static variables

(gdb) info local - local variables of the current stack frame

(gdb) info args  -- arguments of the current stack frame


(gdb) show verbose // set verbose on   /// show logging  //set log file filename.txt


>catch catch  -- catch all exceptions -- this will not tell you where the exception is thrown. It will show you the catch line


Example of stack trace :


#0  0x000000359a0bbc40 in __cxa_begin_catch () from /usr/lib64/libstdc++.so.6

#1  0x0000000000407424 in main (argc=8, arguments=0x7fffffffcc38)

    at server/Metadata/XUDML/TestXUDMLParser/TestXUDMLParser.cpp:101


Here line 101 is just a catch(...) statement. It may tell you what the exception is but it won't tell you where the exception is thrown.


>catch throw --- will help tell you where the exception is thrown

Example: Here the exception is being thrown in ::removeChild method. Wala!

(gdb) bt

#0  0x000000359a0bccb0 in __cxa_throw () from /usr/lib64/libstdc++.so.6

#1  0x00007fffea279824 in obixercesc_2_8::DOMParentNode::removeChild (

    this=0x7fff3551ff80, oldChild=0x7fff3551ff68) at DOMParentNode.cpp:282

#2  0x00007fffea263c3b in obixercesc_2_8::DOMElementImpl::removeChild (

    this=0x7fff3551ff68, oldChild=0x7fff3551ff68) at DOMElementImpl.cpp:534

#3  0x00007fffecc5cee4 in XmlElement::RemoveChild (this=0x7fffffff8320,

    child=...) at server/Metadata/XUDML/Src/SMFineGrainedUtil.cpp:947

#4  0x00007fffecc6cea5 in LogicalTableSourceOperations::UpdateParentOnDeletion

    (this=0xa7fe20, element=..., delXmlElements=..., residueDeleteSet=...)

    at server/Metadata/XUDML/Src/SMFineGrainedXMLHandler.cpp:1158

#5  0x00007fffecc6a5e3 in ElementTypeOperations::ApplyDeleteCommand (

    this=0xa7fe20, element=..., deleteSet=..., delXmlElements=...,

    residueDeleteSet=...)

    at server/Metadata/XUDML/Src/SMFineGrainedXMLHandler.cpp:865

#6  0x00007fffecc6a695 in ElementTypeOperations::ApplyDeleteCommand (

    this=0xa7fe20, element=..., deleteSet=..., delXmlElements=...,

    residueDeleteSet=...)

    at server/Metadata/XUDML/Src/SMFineGrainedXMLHandler.cpp:872

#7  0x00007fffecc6a695 in ElementTypeOperations::ApplyDeleteCommand (

    this=0xa7fe20, element=..., deleteSet=..., delXmlElements=...,

    residueDeleteSet=...)

    at server/Metadata/XUDML/Src/SMFineGrainedXMLHandler.cpp:872

#8  0x00007fffecc6a695 in ElementTypeOperations::ApplyDeleteCommand (

    this=0xa7fe20, element=..., deleteSet=..., delXmlElements=...,

    residueDeleteSet=...)

    at server/Metadata/XUDML/Src/SMFineGrainedXMLHandler.cpp:872

#9  0x00007fffecc71935 in FineGrainedXML::XmlSection::ApplyDelete (

    this=0x7fffffffba78, deleteSet=..., residueDeleteSet=...)

    at server/Metadata/XUDML/Src/SMFineGrainedXMLHandler.cpp:1818

#10 0x00007fffec79793d in TransformXml (pGateway=0x7fff9cbe9008, fgxml=...)

    at server/Metadata/XUDML/Src/SMXUDMLParser.cpp:520

#11 0x00007fffec797bea in GeneratePatchedXML (pGateway=0x7fff9cbe9008,

    fgXmlfileOrText=..., bIsFile=true, pObjManager=0xa7e060, errorMsg=...,

    bIsPureFGXml=@0x7fffffffc09f, bIsTransformation=true, mergedXML=...)

    at server/Metadata/XUDML/Src/SMXUDMLParser.cpp:543

#12 0x00007fffec7988f8 in XUDMLParser::ExecuteTransactionalXMLforXUDML (

    pGateway=0x7fff9cbe9008, inputs=..., inputPasswords=..., errorMsg=...,

    warningMsg=..., createdObjIds=..., modifiedObjIds=..., delIds=...,



Useful commands when troubleshooting multithreaded program:


(gdb) info threads //list all the threads in the program

  5 Thread 0x7fffe0988700 (LWP 9729)  0x0000003b5180c6ad in pthread_getspecific () from /lib64/libpthread.so.0

* 4 Thread 0x7fffe0a89700 (LWP 9728)  0x00007ffff456b869 in _SASSTL::_Rb_global<bool>::_M_decrement (_M_node=0x7fffe12f02b0) at thirdparty/include/stlport/stl/_tree.c:269

  3 Thread 0x7fffe2b66700 (LWP 9727)  0x0000003b5180b98e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0

  2 Thread 0x7fffe2c67700 (LWP 9726)  0x0000003b5180b5bc in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0

  1 Thread 0x7fffe9c7b720 (LWP 9716)  0x0000003b5180b98e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0

//* is the current thread


(gdb) thread apply all bt 5   //print the first 5 lines from each stack trace for all the threads.

Thread 5 (Thread 0x7fffe0988700 (LWP 9729)):

#0  0x0000003b5180c6ad in pthread_getspecific () from /lib64/libpthread.so.0

#1  0x00007ffff3f4a23c in samem_details_800::Manager::Allocate (this=0x7ffff417f140, Bytes=16, pFile=0x7ffff5c0e8c0 "void _SASSTL::vector<_Tp, _Alloc>::_M_insert_overflow(_Tp*, const _Tp&, const _SASSTL::__false_type&, size_t, bool) [with _Tp = Ref<ALevelToLevel, NonConstPointer<ALevelToLevel> >, _Alloc = _SASSTL::a"..., nLine=130) at manager.cpp:1202

#2  0x00007ffff45b4a09 in NQNodeAlloc::allocate (__n=<value optimized out>, pFile=<value optimized out>, nLine=<value optimized out>) at thirdpartysource/STLport-4.5/src/nqnodealloc.cpp:37

#3  0x00007ffff5b996b1 in allocate (this=<value optimized out>, parentLinks=...) at thirdparty/include/stlport/stl/_alloc.h:372

#4  _M_insert_overflow (this=<value optimized out>, parentLinks=...) at thirdparty/include/stlport/stl/_vector.h:130


Thread 4 (Thread 0x7fffe0a89700 (LWP 9728)):

#0  0x00007ffff456b869 in _SASSTL::_Rb_global<bool>::_M_decrement (_M_node=0x7fffe12f02b0) at thirdparty/include/stlport/stl/_tree.c:269

#1  0x00007ffff5607b8d in operator-- (this=0x7fffe12dd090, __v=...) at thirdparty/include/stlport/stl/_tree.h:185

#2  _SASSTL::_Rb_tree<RefCnt<RelInstance, RefCountable>, RefCnt<RelInstance, RefCountable>, _SASSTL::_Identity<RefCnt<RelInstance, RefCountable> >, LessRelInstance, _SASSTL::allocator<RefCnt<RelInstance, RefCountable> > >::insert_unique (this=0x7fffe12dd090, __v=...) at thirdparty/include/stlport/stl/_tree.c:410

#3  0x00007ffff5607026 in insert (this=0x7fffe12dd088, pSharedInstance=<value optimized out>) at thirdparty/include/stlport/stl/_set.h:137

#4  Relation::SetRelInstance (this=0x7fffe12dd088, pSharedInstance=<value optimized out>) at server/Metadata/Networker/Src/SMRelation.cpp:334


Thread 3 (Thread 0x7fffe2b66700 (LWP 9727)):

#0  0x0000003b5180b98e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0

#1  0x00007ffff4af71b9 in NQConditionWait::Wait (this=0x7ffff4dd84c8, milliseconds=1000) at server/Utility/Generic/NQThreads/SUGConditionWait.cpp:273

#2  0x00007ffff4b70aff in PeriodicTasksExecutor::schedulingThreadMain (this=0x7ffff4dd83c0) at server/Utility/Generic/Src/PeriodicTasksExecutor.cpp:123

#3  0x00007ffff4b207c9 in NQExecutionState::ExecuteSystemMain (this=0x7fffe9a3d538) at server/Utility/Generic/NQThreads/SUGExecutionState.cpp:91

#4  0x00007ffff4b5c3bc in NQThreadJobBase::ExecuteSystemMain (this=0x7fffe9a3d538) at server/Utility/Generic/NQThreads/SUGThreadJob.cpp:179


Thread 2 (Thread 0x7fffe2c67700 (LWP 9726)):

#0  0x0000003b5180b5bc in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0

#1  0x00007ffff4af72be in NQConditionWait::Wait (this=0x7fffe96d9688) at server/Utility/Generic/NQThreads/SUGConditionWait.cpp:156

#2  0x00007ffff4b432f8 in NQSemaphore::Acquire (this=0x7fffe96d9580) at server/Utility/Generic/NQThreads/SUGSemaphore.cpp:100

#3  0x00007ffff4af8cb9 in NQConditionWaitLIFO::Wait (this=0x7fffe9a131f0, signalSemaphore=..., startTime=...) at server/Utility/Generic/NQThreads/SUGConditionWaitLIFO.cpp:128

#4  0x00007ffff4af8de9 in NQConditionWaitLIFO::Wait (this=0x7fffe9a131f0) at server/Utility/Generic/NQThreads/SUGConditionWaitLIFO.cpp:104


Thread 1 (Thread 0x7fffe9c7b720 (LWP 9716)):

#0  0x0000003b5180b98e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0

#1  0x00007ffff4af71b9 in NQConditionWait::Wait (this=0x7fffffff9d68, milliseconds=200) at server/Utility/Generic/NQThreads/SUGConditionWait.cpp:273

#2  0x00007ffff4b43157 in NQSemaphore::Acquire (this=0x7fffffff9c60, milliseconds=<value optimized out>) at server/Utility/Generic/NQThreads/SUGSemaphore.cpp:130

#3  0x00007ffff4b1f5e8 in Acquire (this=0x7fffe96db808, stateMask=<value optimized out>, milliseconds=200, actualState=@0x7fffffff9f8c) at server/include/Utility/Generic/SUGExecutionState.h:160

#4  NQExecutionState::WaitForStateNoLock (this=0x7fffe96db808, stateMask=<value optimized out>, milliseconds=200, actualState=@0x7fffffff9f8c) at server/Utility/Generic/NQThreads/SUGExecutionState.cpp:228


 Some other useful commands

(gdb) frame

(gdb) list *$pc

Both of these will list the source code around the current execution line.



checking the function I am interested to debug in gdb:

(gdb) info functions libafd_traj_quality
All functions matching regular expression "libafd_traj_quality":

File ../libAFD/libafd.cpp:
Datum libafd_traj_quality(FunctionCallInfo);
const Pg_finfo_record *pg_finfo_libafd_traj_quality();
Datum libafd_traj_quality(FunctionCallInfo);
const Pg_finfo_record *pg_finfo_libafd_traj_quality();
(gdb) 

Trying to set up the breakpoint and getting the error:

(gdb) b libafd_traj_quality
Cannot access memory at address 0x26c01f
(gdb)

How can I set a breakpoint on my function???

Additional Info:

# cat /proc/22648/maps  | grep libafd
2b3b2556e000-2b3b25a82000 r-xp 00000000 08:01 5379086                    /usr/lib/postgresql/9.1/lib/libafd.so
2b3b25a82000-2b3b25c82000 ---p 00514000 08:01 5379086                    /usr/lib/postgresql/9.1/lib/libafd.so
2b3b25c82000-2b3b25c88000 r--p 00514000 08:01 5379086                    /usr/lib/postgresql/9.1/lib/libafd.so
2b3b25c88000-2b3b25c9a000 rw-p 0051a000 08:01 5379086                    /usr/lib/postgresql/9.1/lib/libafd.so

//This only returns something if libafd.so is compiled with symbols# nm -as /usr/lib/postgresql/9.1/lib/libafd.so | grep libafd_traj_quality
00000000003d4788 r _ZZ28pg_finfo_libafd_traj_qualityE8my_finfo
000000000026c01f T libafd_traj_quality
000000000026c012 T pg_finfo_libafd_traj_quality

Real remote debugging example

setup on the target is running on 10.140 node:
gdbserver --multi :2345 //gdbserver is running with port 2345 opened
target machine also run the app we are trying to debug
1. build debug version of the app and launch gdb with the debug app (having debug symbols) on the host machine to connect to the target.
Assuming this py program will build a debug version of the app we are going to debug and run gdb with it.
$ ./build/gdb_coredump.py app
gdb> target extended-remote 10.140:2345
gdb> attach app_processid // get the process id on the target machine. The program will pause here.
gdb> bt
gdb> b app_main.cpp:42 //break at the line
gdb> b .... //set any break points you want to troubleshoot before continue running the program
(gdb) c
Continuing.

Thread 1 "app" hit Breakpoint 1, main (argc=<optimized out>, argv=0x7fd6924fd8)
at _app/src/app_main.cpp:42
42 sleep(10);
(gdb) list
37 StdMessageUi msg_handler; // Standard Message handling including a time field
38 PrometheusUiApplication app(argc, argv);
39 volatile bool bFakeDelay = true; //need to be volatile so the compiler does not optimize it out.
40 while (bFakeDelay)
41 {
42 sleep(10);
43 }
44 QCoreApplication::setApplicationName("Prometheus UI");
45 QCoreApplication::setApplicationVersion("0.1");
46
(gdb) p bFakeDelay
$1 = true
gdb> set bFakeDelay=false //to break the loop
gdb> continue


##### example on how to print something at the breakpoint
(gdb) b app_main.cpp:42
Breakpoint 4 at 0x43ff98: file app_main.cpp, line 42.
(gdb) commands
Type commands for breakpoint(s) 4, one per line.
End with a line saying just "end".
>printf "breaking at sleep(10) bFakeDelay=%d\n", bFakeDelay
>cont
>end
(gdb)c //you have to wait for 10 seconds to see it breaks
Continuing.
//do something to trigger the crash and pause gdb
[New Thread 4285.4622]
[New Thread 4285.4625]
[New Thread 4285.4626]
[New Thread 4285.4629]
[New Thread 4285.4630]
[New Thread 4285.4631]
[New Thread 4285.4632]
[New Thread 4285.4662]
[New Thread 4285.4663]
[New Thread 4285.4664]
[New Thread 4285.4665]

Thread 1 "prometheus_app" received signal SIGSEGV, Segmentation fault.
0x0000007f78340a80 in tcache_init () at malloc.c:3129
3129 malloc.c: No such file or directory.
(gdb) bt
....
#12 ISI::AlertUiProcessingManager::trackSessionAlertMessage (this=this@entry=0x17a7e4f0, id=id@entry=ID::Alert::CHECK_ENERGY_CORD_CONNECTION) at _prometheus/lib/ui/alerts/src/alert_ui_processing_manager.cpp:48
#13 0x00000000004f22a0 in ISI::AlertUiProcessingManager::updateAlertContext (this=this@entry=0x17a7e4f0, id=id@entry=ID::Alert::CHECK_ENERGY_CORD_CONNECTION, newContextVal=...) at _prometheus/lib/ui/alerts/src/alert_ui_processing_manager.cpp:75
#14 0x00000000004f0230 in ISI::AlertUiDataValueDelegate::changed (this=0x17a91f10) at _prometheus/lib/ui/alerts/src/alert_ui_data_value_delegate.cpp:23
#15 0x00000000007363c4 in DmUiDataValue::syncValue (this=0x177c9110) at framework/lib/ui/datamodel/src/dm_ui_datamodel.cpp:440
#16 0x0000000000736098 in DmUiDataValue::syncValue (this=0x17679b78) at framework/lib/ui/datamodel/src/dm_ui_datamodel.cpp:456
#17 0x0000000000516d2c in BaseUiScreen::dataManagerSync (this=this@entry=0x176edbc0) at _prometheus/lib/ui/base_domain/src/base_ui_screen.cpp:46
#18 0x00000000004d9060 in PrometheusUiMainScreen::paint (this=0x176edbc0, painter=0x1710d1b0) at _prometheus/lib/ui/prometheus_standalone/src/prometheus_ui_mainscreen.cpp:78
#19 0x0000007f7923f0e0 in ?? ()
#20 0x0000000016916e40 in ?? ()
Backtrace stopped: not enough registers or memory available to unwind further
(gdb) list alert_ui_processing_manager.cpp:48
43 {
44 alertMessage += "\n" + thirdMessage;
45 }
46 if(m_sessionAlerts.size() == SESSION_ALERTS_TRACK_SIZE )
47 {
48 m_sessionAlerts.erase(m_sessionAlerts.end());//pop_back();
49 }
50 m_sessionAlerts.push_front(std::pair<string,string>(alertMessage, string(buffer)));
51 std::stringstream ss;
52 ss << "trackSessionAlert called: " << alertMessage << " " << buffer << " " << m_sessionAlerts.size();
(gdb)

Thread 1 "prometheus_app" hit Breakpoint 4, main (argc=<optimized out>, argv=0x7fe6ab5d78)
at _prometheus/app/ui/prometheus_app/src/prometheus_ui_app_main.cpp:42
42 sleep(10);
breaking at sleep(10) bFakeDelay=value has been optimized out
(gdb)

Saturday, February 21, 2015

How to stream music to your network enabled AVR using Foobar2000?



There are many ways to stream the music on your computer to your receiver.
If you are using Windows, you can use Windows Media Player to stream music to your network enabled AVR. Why do you want to do this?
The sound produced from your home theater is a lot better than the sound coming out from your laptop or computer speakers.

Here I will show you how to use Foobar2000 to stream music to your network enabled receiver.

1. Download Foobar2000

2.Download and install the plugin or UnPn component from the same website




3. Turn on your network enabled receiver. Make sure it is connected to your local network.

4.  Run Foobar2000! You should see the UPnP controller menu item if everything is installed correctly.




5. Select the UPnP controller menu item to launch the UPnP controller dialog.
From this dialog, you can select a variety of devices available on your network that you can stream
your music to. Here I have two devices, and I will select my Denon AVR receiver.
Notice the program will detect the devices for you automatically. You just need to make sure they are on and connected to your local network.








6. Select the device you want to stream and click on the play button. When you click the play button, it will play the music on your current play list so make sure your playlist is not empty.

Friday, January 2, 2015

How to stream live feed from your security camera to your smart phone?

In order to stream live content from your security camera to your smart phone, you need to know your IP address, the model of your camera, and configure your router to allow you to access your camera remotely.
I am assuming that you have basic networking knowledge and have everything working already so I will only talk about configuring your router so that you can access your camera remotely.

Each camera you have will have a unique internal IP address assigned to it.
Since it is an internal IP address, most IP address will start with 192.168.*.*.

You cannot access the camera from the internet  using these internal IP addresses.
These IP addresses are valid only from within your private wireless or wire network.

In order to access your camera from the outside, you need to access the IP address assigned to your cable modem by your internet service provider.
Assuming that this IP address is 24.145.239.234, you will  have to access all your cameras inside your network using this IP address. Even though you access all the cameras using the same IP address, the port number will be different for each camera.

The first thing you need to do is to assign a static IP address for each camera inside your network. This will prevent the IP address of the camera from changing when you reboot the device or the router. Here is an example on how it would look like:




If you have Netgear router, then you can just go the same place shown in the screenshot to assign static IP address to your device. If you have a different router, you can go to similar pages or settings.

Once you have assigned static IP addresses to your devices, you will need to assign a unique external port number to each device. Remember we have to access all the devices using the same unique IP address assigned to you from your ISP; therefore, the only way to distinguish each device is through the port number you assigned to each device. This is concept is called port forwarding.


As you can see from the above screenshot, the port numbers listed in the external start port column are the ones we will use to associate with each camera inside our internal network from the outside. Please check the relationship between this screenshot and the one above it.
After you have done all the steps correctly, you should be able to access one of your camera from the browser via this URL:

http://24.145.239.234:8000

What happens is the request will come to your router first, then it will forward the request using the port number to the appropriate camera inside your network. Notice the external port number is associated with an internal IP address.

You are set. Now the same information can be used to configure a smart phone app so that you can view live content of your camera from any smartphones.
IP Cam Viewer is an IOS app that you can use for iPhone. Similar Android apps can be found for your Android devices as well.