31. May 2017

How to debug C/C++ code in Android Studio

Android Studio has support for debugging Java and also C/C++ code. The problem is that in default configuration the debugger might not work. There is a quick way how to fix the issue.

Go to your application and select Edit Configurations…

Select tab Debugger and change Debug type to value Dual. Press Ok.

Android Studio will check installed packages and in the case of missing debugger it will prompt you to confirm the fix. Just click Yes.

After installation of necessary packages, the debugger will start and you’ll be able to debug even C/C++ code.

14. May 2013

How to debug :hover pseudo class in Google Chrome Developer tool

Google Chrome developer tool is simply one of the best tools available for debugging of HTML5 applications.

It has one neat feature: possibility to inspect CSS of element and editing it on the fly.

That works fine for normal styles, but what about :hover state?

There is one “hidden” option which allows to switch element to :hover state.

Inspect element of HTML. You should see Styles on the right hand side. There are 3 icons. Click the middle one with arrow sign. It will pop up menu with checkboxes. You can select here CSS pseudo classes like :active, :focus, :hover or :visited.

google-chrome-dev-hover

To learn more about capabilities of Google Chrome developer tools I recommend to go through free course Discover Dev Tools from Codeschool.com.

4. February 2013

Useful Django package: django-debug-toolbar

django-debug-toolbar is simply must have tool for Django development.

It adds powerfull toolbar which allows detailed diagnostic and debugging of Django site.

django-debug-toolbarQuick install:

pip install django-debug-toolbar

Open settings.py and add:

MIDDLEWARE_CLASSES = (
    # ...
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    # ...
)
INTERNAL_IPS = ('127.0.0.1',)
INSTALLED_APPS = (
    ...
    'debug_toolbar',
)

Make sure that DEBUG is set to True

DEBUG = True

22. December 2011

How to disable stealing of focus by Console in Eclipse

There is one very annoying issue in Eclipse: stealing of focus by Console window.

Console window is displayed when you run application.

When you set focus to some other window like Search results and application prints something on output then Eclipse will automatically switch to Console window. Your search results are gone.

There is simple way how to get rid of such a behavior.

Go to Window -> Preferences -> Run/Debug -> Console. Uncheck options:

  • Show when program writes to standard out
  • Show when program writes to standard error

28. October 2011

Mutextrace – simple tool for detecting problems with mutexes

Debugging multithread apps is not easy task. Some problems never occur in debugging mode and it could be discovered only when application is running for long time. One of problematic issues in multithread apps are mutexes.

There is very simple tool in Debian distribution that could help you with identifying problems mutexes. The tools is mutextrace.

Quote from package description:

This tool displays mutexes locked and unlocked during execution of a program, and can provide hints for debugging multithreaded applications. As it is fairly lightweight and easy to use, it is ideal at the start of a debugging session or when only limited resources are available.

It cannot detect data races as it only looks at the synchronization primitives themselves; if you need that, use helgrind (in the valgrind package) instead.

How to use mutextrace? Like strace. Just add mutextrace before your application in the shell:

mutextrace ./mutex-tester-app param1 param2

Result:

lock #1, free -> thread 1
init #2
lock #2, free -> thread 1
unlock #1
lock #1, free -> thread 1
init #3
lock #3, free -> thread 1
unlock #1
unlock #3

Simple 🙂

I couldn’t find reference to original source of mutextrace. It seems that it does not exist.