Eclipse를 쓰다보니 디버깅도 Eclipse로 하고 싶어졌다. 

문제는 로그인한 유저와 디버깅 대상 프로세스가 실행되고 있는 유저가 다르다는 것. 

"C/C++ Attach to Application"을 사용하려 해도, 해당 프로세스에 대한 권한이 없어서 안된다. 


이를 해결하기 위해 첫 번째 해야 될 일은 "sudo gdb"이다. 

이렇게 하면, gdb를 실행할 때 root로 실행하기 때문에 다른 프로세스에 접근할 수 있게 된다.

그러나 실제로 위를 실행하면 실행이 안 되는데,  sudo를 할 때 패스워드를 입력해야 되어 프롬프트에서 멈추게 되는데, eclipse에서는 이를 입력할 수 있는 방법이 없다. 

그래서 두번째로 해야 될 일은 현재 유저가 gdb에 대해서는 root로 실행할 때 패스워드를 입력하지 않아도 되게 하는 것이다. 이는 root로 접속하여 visudo를 실행하여 아래와 같이 수정한다. 

<users> ALL=(root) NOPASSWD:<program>



이제 root 권한으로 이클립스에서 타 유저의 프로세스를 디버깅할 수 있게 된다. 


출처:http://stackoverflow.com/questions/2891356/how-to-debug-application-as-root-in-eclipse-in-ubuntu


' > 개발' 카테고리의 다른 글

VIM - 여러 파일 편집  (0) 2013.04.08
Eclipse에서 다른 유저의 프로세스 debug  (0) 2013.04.05
GDB에서 특정 쓰레드만 멈추게 하는 법  (0) 2013.03.27
vi 설정  (0) 2013.02.22
Difftool  (0) 2012.12.17
No repository found in Eclipse  (0) 2012.11.27
Posted by 라판

http://sourceware.org/gdb/onlinedocs/gdb/Non_002dStop-Mode.html#Non_002dStop-Mode

In non-stop mode, when a thread stops to report a debugging event, only that thread is stopped; gdb does not stop other threads as well, in contrast to the all-stop mode behavior. Additionally, execution commands such as continue and step apply by default only to the current thread in non-stop mode, rather than all threads as in all-stop mode. This allows you to control threads explicitly in ways that are not possible in all-stop mode — for example, stepping one thread while allowing others to run freely, stepping one thread while holding all others stopped, or stepping several threads independently and simultaneously.

To enter non-stop mode, use this sequence of commands before you run or attach to your program:

     # Enable the async interface.
     set target-async 1
     
     # If using the CLI, pagination breaks non-stop.
     set pagination off
     
     # Finally, turn it on!
     set non-stop on

You can use these commands to manipulate the non-stop mode setting:

set non-stop on
Enable selection of non-stop mode. 
set non-stop off
Disable selection of non-stop mode. 
show non-stop
Show the current non-stop enablement setting.

Note these commands only reflect whether non-stop mode is enabled, not whether the currently-executing program is being run in non-stop mode. In particular, the set non-stop preference is only consulted when gdb starts or connects to the target program, and it is generally not possible to switch modes once debugging has started. Furthermore, since not all targets support non-stop mode, even when you have enabled non-stop mode, gdb may still fall back to all-stop operation by default.

In non-stop mode, all execution commands apply only to the current thread by default. That is, continue only continues one thread. To continue all threads, issue continue -a or c -a.

You can use gdb's background execution commands (see Background Execution) to run some threads in the background while you continue to examine or step others from gdb. The MI execution commands (see GDB/MI Program Execution) are always executed asynchronously in non-stop mode.

Suspending execution is done with the interrupt command when running in the background, or Ctrl-c during foreground execution. In all-stop mode, this stops the whole process; but in non-stop mode the interrupt applies only to the current thread. To stop the whole program, use interrupt -a.

Other execution commands do not currently support the -a option.

In non-stop mode, when a thread stops, gdb doesn't automatically make that thread current, as it does in all-stop mode. This is because the thread stop notifications are asynchronous with respect to gdb's command interpreter, and it would be confusing if gdbunexpectedly changed to a different thread just as you entered a command to operate on the previously current thread.

' > 개발' 카테고리의 다른 글

VIM - 여러 파일 편집  (0) 2013.04.08
Eclipse에서 다른 유저의 프로세스 debug  (0) 2013.04.05
GDB에서 특정 쓰레드만 멈추게 하는 법  (0) 2013.03.27
vi 설정  (0) 2013.02.22
Difftool  (0) 2012.12.17
No repository found in Eclipse  (0) 2012.11.27
Posted by 라판
TAG GDB