Tuesday, June 25, 2013

Extract Path and Symbols from Chromium to index Eclipse CDT

Eclipse CDT can analysis build message and extract Path and Symbols.
I use Ubuntu 13.04. Other OS I don't care. I hate both Mac and Window.

There is not one way to do that. However, I prefer what I describe here, because I don't like build chromium in Eclipse.

If you like to build chromium in Eclipse, refer to https://code.google.com/p/chromium/wiki/LinuxEclipseDev
For more information, refer to https://developer.mozilla.org/en-US/docs/Eclipse_CDT

My way consists of 2 step.
1. record build message
2. extract Path and Symbols using power of CDT.

1. record build message

> ninja -C out/Debug -j 80 -v -n chrome content_shell > build-message
> sed -i "s/g++/gcc/g" build-message
> sed -i "s/\[\S* gcc/gcc/g" build-message
> sed -i "s/-I\.\.\/\./-I/g" build-message

2. extract Path and Symbols using power of CDT.

1. open project Properties window
2. go "C/C++ Build > Discovery Options"
3. Select "Configuration-wide" in "Discovery profiles scope"
 a. check "Automate discovery of paths and symbols"
 b. check Report path deltection problems"
 c. "GCC per file scanner infor profile" in Discovery profile
 d. check Enable build output scanner info discovery
4. select "build-message" file via Browse... button.
5. click Load button

6. Refresh project
7. Rebuild index

build message for WebKit

QT
make -B -n make_default > build-message

GTK
make -B -n all-am > build-message



expand your Eclipse memory

CDT indexing needs so much memory


change your eclipse.ini file, my settings


org.eclipse.platform
--launcher.XXMaxPermSize
2G
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-XX:MaxPermSize=2G
-Xms2G
-Xmx7G

increase your index memory

1. open Window>Preferences
2. go C/C++ > Indexer
3. change Cache limits : in my settings, 70%, 6144MB, 6144MB



trouble shooting

You will feel that indexing is gradually slow with repeated updating index.

It it time to rebuild index. Don't assume that clicking rebuild is fine. Real rebuild is a bit more complicated.

go to indexing directory
> cd [workspace]/.metadata/.plugins/org.eclipse.cdt.core
> rm [project name]*

Indexing is not free, it is stored in your persistent storage. Chromium indexing consume about 1GB.

And click rebuild.




Thursday, June 20, 2013

GPU Process analysis: hello_triangle_exe (GPU Process on single process and single thread)

GPU Process has demo project for example. There is hello_triangle_exe. I analysis hellow_triangle_exe to understand GPU Process.

How to build

> export GYP_GENERATORS='ninja'
> export GYP_GENERATOR_FLAGS="output_dir=out_gpu"
> export CHROMIUM_GYP_FILE="gpu/demos/demos.gyp"
> ./build/gyp_chromium
> ninja -C out_gpu/Release -j 6 hello_triangle_exe


Overview (seq. diagram)

origin: http://www.diagrammr.com/edit?key=dQ65fKDGRSz

demo does not launch gpu process or thread. However if we create GLES2SmdHelper with CommandBufferProxy instead of CommandBufferService, it would be possible to launch gpu process. How? I don't know yet.

callstack

Final glcall's callstack in above fig.
gfx::GLApiBase::glShaderSourceFn - gl_bindings_autogen_gl.cc, line 3817
gpu::gles2::ProgramManager::ForceCompileShader - program_manager.cc, line 489
gpu::gles2::ProgramManager::DoCompileShader - program_manager.cc, line 461
gpu::gles2::GLES2DecoderImpl::DoCompileShader - gles2_cmd_decoder.cc, line 6258
gpu::gles2::GLES2DecoderImpl::HandleCompileShader - gles2_cmd_decoder_autogen.h, line 330
gpu::gles2::GLES2DecoderImpl::DoCommand - gles2_cmd_decoder.cc, line 3490
gpu::CommandParser::ProcessCommand - cmd_parser.cc, line 72
gpu::GpuScheduler::PutChanged - gpu_scheduler.cc, line 78
base::internal::RunnableAdapter{void (gpu::GpuScheduler::*)()}::Run - bind_internal.h, line 134
base::internal::InvokeHelper{fals - bind_internal.h, line 871
base::internal::Invoker{ - bind_internal.h, line 1169
base::Callback{void ()}::Run() const - callback.h, line 396
gpu::CommandBufferService::FlushSync - command_buffer_service.cc, line 78
gpu::CommandBufferHelper::FlushSync - cmd_buffer_helper.cc, line 109
gpu::CommandBufferHelper::Finish - cmd_buffer_helper.cc, line 136
gpu::gles2::GLES2Implementation::WaitForCmd - gles2_implementation.cc, line 317
gpu::gles2::GLES2Implementation::GetShaderiv - gles2_implementation_impl_autogen.h, line 711
GLES2GetShaderiv - gles2_c_lib_autogen.h, line 254
esLoadShader - esShader.c, line 61
esLoadProgram - esShader.c, line 104
htInit - Hello_Triangle.c, line 47
gpu::demos::gles2_book::Example{HTUserData}::InitGL - example.h, line 54
gpu::demos::Window::Init - window.cc, line 63
main - main_exe.cc, line 34

How to control which call either GLES2Impl or GLApi


use GLES2Impl
It means using GPU Process.

  • #include <GLES2/gl2.h> 
  • #include "gpu/command_buffer/client/gles2_lib.h" and call like ::gles2::GetGLContext()->SwapBuffers() 
use GLApi
It means calling gl directly.
  • #include "ui/gl/gl_gl_api_implementation.h"




Tuesday, June 18, 2013

backtrace of creating root window and focus handling of chromium aura

It is not well-defined article. It is just note to help me remember something.

1. backtrace when web contents get focus by pushing tab key.

views::corewm::FocusController::FocusWindow() at focus_controller.cc:128 0x555559ed281a 
aura::Window::Focus() at window.cc:579 0x5555577648a8 
content::RenderWidgetHostViewAura::Focus() at render_widget_host_view_aura.cc:937 0x555558b07b4a 
content::WebContentsViewAura::Focus() at web_contents_view_aura.cc:907 0x555558b84699 
views::WebView::OnFocus() at webview.cc:129 0x55555968fee0 
views::View::Focus() at view.cc:1,527 0x555559e8631c 
views::FocusManager::SetFocusedViewWithReason() at focus_manager.cc:335 0x555559e6b1d2 
views::FocusManager::AdvanceFocus() at focus_manager.cc:154 0x555559e6a8d0 
views::FocusManager::OnKeyEvent() at focus_manager.cc:87 0x555559e6a43f 
views::DesktopNativeWidgetAura::OnKeyEvent() at desktop_native_widget_aura.cc:713 0x555559e91405 
ui::EventHandler::OnEvent() at event_handler.cc:25 0x55555a91db90 
ui::EventTarget::OnEvent() at event_target.cc:54 0x55555a91f021 
ui::EventDispatcher::DispatchEvent() at event_dispatcher.cc:145 0x55555a91cb62 
ui::EventDispatcher::ProcessEvent() at event_dispatcher.cc:93 0x55555a91c6e3 
ui::EventDispatcherDelegate::DispatchEvent() at event_dispatcher.cc:48 0x55555a91c415 
aura::RootWindow::ProcessEvent() at root_window.cc:761 0x555557773d84 
aura::RootWindow::OnHostKeyEvent() at root_window.cc:896 0x555557774670 
views::corewm::InputMethodEventFilter::DispatchKeyEventPostIME() at input_method_event_filter.cc:72 0x555559ed7771 
ui::FakeInputMethod::DispatchKeyEvent() at fake_input_method.cc:82 0x55555a9a2f2e 
views::corewm::InputMethodEventFilter::OnKeyEvent() at input_method_event_filter.cc:54 0x555559ed76c5 
views::corewm::CompoundEventFilter::FilterKeyEvent() at compound_event_filter.cc:147 0x555559ecd1ab 
views::corewm::CompoundEventFilter::OnKeyEvent() at compound_event_filter.cc:213 0x555559ecd53e 
ui::EventHandler::OnEvent() at event_handler.cc:25 0x55555a91db90 
ui::EventDispatcher::DispatchEvent() at event_dispatcher.cc:145 0x55555a91cb62 
ui::EventDispatcher::DispatchEventToEventHandlers() at event_dispatcher.cc:124 0x55555a91c947 
ui::EventDispatcher::ProcessEvent() at event_dispatcher.cc:82 0x55555a91c656 
ui::EventDispatcherDelegate::DispatchEvent() at event_dispatcher.cc:48 0x55555a91c415 
aura::RootWindow::ProcessEvent() at root_window.cc:761 0x555557773d84 
aura::RootWindow::OnHostKeyEvent() at root_window.cc:896 0x555557774670 
views::DesktopRootWindowHostX11::Dispatch() at desktop_root_window_host_x11.cc:940 0x555559e976d3 
base::MessagePumpAuraX11::Dispatch() at message_pump_aurax11.cc:304 0x55555a04920b 
base::MessagePumpAuraX11::ProcessXEvent() at message_pump_aurax11.cc:249 0x55555a048e49 
base::MessagePumpAuraX11::DispatchXEvents() at message_pump_aurax11.cc:191 0x55555a0487b6 
() at message_pump_aurax11.cc:33 0x55555a047f42 
g_main_dispatch() at gmain.c:2,715 0x7ffff6d80ab5 
g_main_context_dispatch() at gmain.c:3,219 0x7ffff6d80ab5 
g_main_context_iterate() at gmain.c:3,290 0x7ffff6d80de8 
g_main_context_iteration() at gmain.c:3,351 0x7ffff6d80ea4 
base::MessagePumpGlib::RunWithDispatcher() at message_pump_glib.cc:199 0x55555a0461c2 
base::MessagePumpGlib::Run() at message_pump_glib.cc:296 0x55555a0466fe 
base::MessageLoop::RunInternal() at message_loop.cc:441 0x55555a096fa2 
base::MessageLoop::RunHandler() at message_loop.cc:414 0x55555a096e4c 
base::RunLoop::Run() at run_loop.cc:45 0x55555a0c891c 
ChromeBrowserMainParts::MainMessageLoopRun() at chrome_browser_main.cc:1,620 0x55555656d0c0 
content::BrowserMainLoop::RunMainMessageLoopParts() at browser_main_loop.cc:620 0x555558937bb0 
content::BrowserMainRunnerImpl::Run() at browser_main_runner.cc:113 0x555558bc4704 
content::BrowserMain() at browser_main.cc:22 0x55555bc8301c 
content::RunNamedProcessTypeMain() at content_main_runner.cc:433 0x55555a48c2b0 
content::ContentMainRunnerImpl::Run() at content_main_runner.cc:756 0x55555a48d307 
content::ContentMain() at content_main.cc:35 0x55555a48b677 
ChromeMain() at chrome_main.cc:32 0x555555e6f535 
main() at chrome_exe_main_aura.cc:17 0x555555e6f500 

2. backtrace when web contents loses focus.

views::FocusManager::AdvanceFocus() at focus_manager.cc:142 0x555559e6a857 
ChromeWebContentsViewDelegateViews::TakeFocus() at chrome_web_contents_view_delegate_views.cc:90 0x555558ee8494 
content::WebContentsViewAura::TakeFocus() at web_contents_view_aura.cc:1,149 0x555558b85688 
content::RenderViewHostImpl::OnTakeFocus() at render_view_host_impl.cc:1,521 0x555558ad3cca 
DispatchToMethod{content::RenderViewHostImpl, void () at tuple.h:546 0x555558adb26f 
ViewHostMsg_TakeFocus::Dispatch{content::RenderViewHostImpl, content::RenderViewHostImpl, void () at view_messages.h:1,942 0x555558ad8e3e 
content::RenderViewHostImpl::OnMessageReceived() at render_view_host_impl.cc:979 0x555558ad10e1 
content::RenderProcessHostImpl::OnMessageReceived() at render_process_host_impl.cc:1,224 0x555558ab992e 
IPC::ChannelProxy::Context::OnDispatchMessage() at ipc_channel_proxy.cc:261 0x5555569ee4c3 
base::internal::RunnableAdapter{void () at bind_internal.h:190 0x5555569f1e9d 
base::internal::InvokeHelper{false, void, base::internal::RunnableAdapter{void () at bind_internal.h:898 0x5555569f1982 
base::internal::Invoker{2, base::internal::BindState{base::internal::RunnableAdapter{void () at bind_internal.h:1,253 0x5555569f11c0 
base::Callback{void () at callback.h:396 0x555555efcb8a 
base::MessageLoop::RunTask() at message_loop.cc:484 0x55555a097407 
base::MessageLoop::DeferOrRunPendingTask() at message_loop.cc:496 0x55555a097536 
base::MessageLoop::DoWork() at message_loop.cc:688 0x55555a097e77 
base::MessagePumpGlib::HandleDispatch() at message_pump_glib.cc:273 0x55555a046625 
() at message_pump_glib.cc:105 0x55555a045ded 


3. backtrace when creating rootwindow by dragging TabStrip.

views::DesktopRootWindowHostX11::Init() at desktop_root_window_host_x11.cc:343 0x555559e94c8f 
views::DesktopNativeWidgetAura::InitNativeWidget() at desktop_native_widget_aura.cc:240 0x555559e8f775 
DesktopBrowserFrameAura::InitNativeWidget() at desktop_browser_frame_aura.cc:54 0x55555904bb69 
views::Widget::Init() at widget.cc:374 0x555559ea73e1 
BrowserFrame::InitBrowserFrame() at browser_frame.cc:78 0x555559049423 
BrowserWindow::CreateBrowserWindow() at browser_view.cc:2,618 0x555558e9df6d 
() at browser.cc:235 0x555558db983c 
Browser::Browser() at browser.cc:402 0x555558dba8a8 
TabDragController::CreateBrowserForDrag() at tab_drag_controller.cc:2,037 0x5555590780a8 
TabDragController::DetachIntoNewBrowserAndRunMoveLoop() at tab_drag_controller.cc:1,320 0x555559074cb3 
TabDragController::DragBrowserToNewTabStrip() at tab_drag_controller.cc:827 0x555559072325 
TabDragController::ContinueDragging() at tab_drag_controller.cc:785 0x555559072072 
TabDragController::Drag() at tab_drag_controller.cc:510 0x555559070c28 
TabStrip::ContinueDrag() at tab_strip.cc:1,150 0x555558ef93ed 
TabStrip::OnMouseDragged() at tab_strip.cc:1,527 0x555558efab67 
views::View::ProcessMouseDragged() at view.cc:2,146 0x555559e88f94 
views::View::OnMouseEvent() at view.cc:973 0x555559e8401e 
ui::EventHandler::OnEvent() at event_handler.cc:27 0x55555a91dbc3 
ui::EventTarget::OnEvent() at event_target.cc:56 0x55555a91f03c 
ui::EventDispatcher::DispatchEvent() at event_dispatcher.cc:145 0x55555a91cb62 
ui::EventDispatcher::ProcessEvent() at event_dispatcher.cc:93 0x55555a91c6e3 
ui::EventDispatcherDelegate::DispatchEvent() at event_dispatcher.cc:48 0x55555a91c415 
views::internal::RootView::DispatchEventToTarget() at root_view.cc:666 0x555559e9fb84 
views::internal::RootView::OnMouseDragged() at root_view.cc:468 0x555559e9ed44 
views::Widget::OnMouseEvent() at widget.cc:1,160 0x555559ea9ed6 
views::DesktopNativeWidgetAura::OnMouseEvent() at desktop_native_widget_aura.cc:721 0x555559e9157c 
ui::EventHandler::OnEvent() at event_handler.cc:27 0x55555a91dbc3 
ui::EventTarget::OnEvent() at event_target.cc:54 0x55555a91f021 
ui::EventDispatcher::DispatchEvent() at event_dispatcher.cc:145 0x55555a91cb62 
ui::EventDispatcher::ProcessEvent() at event_dispatcher.cc:93 0x55555a91c6e3 
ui::EventDispatcherDelegate::DispatchEvent() at event_dispatcher.cc:48 0x55555a91c415 
aura::RootWindow::ProcessEvent() at root_window.cc:761 0x555557773d84 
aura::RootWindow::DispatchMouseEventToTarget() at root_window.cc:1,079 0x55555777511e 
aura::RootWindow::DispatchMouseEventImpl() at root_window.cc:1,023 0x555557774dfc 
aura::RootWindow::OnHostMouseEvent() at root_window.cc:916 0x55555777475d 
views::DesktopRootWindowHostX11::DispatchMouseEvent() at desktop_root_window_host_x11.cc:559 0x555559e95bbd 
views::DesktopRootWindowHostX11::Dispatch() at desktop_root_window_host_x11.cc:1,062 0x555559e97dfa 
base::MessagePumpAuraX11::Dispatch() at message_pump_aurax11.cc:304 0x55555a04920b 
base::MessagePumpAuraX11::ProcessXEvent() at message_pump_aurax11.cc:249 0x55555a048e49 
base::MessagePumpAuraX11::DispatchXEvents() at message_pump_aurax11.cc:191 0x55555a0487b6 
() at message_pump_aurax11.cc:33 0x55555a047f42 
g_main_dispatch() at gmain.c:2,715 0x7ffff6d80ab5 

4. backtrace when creating rootwindow by popping up context menu.

views::DesktopRootWindowHostX11::Init() at desktop_root_window_host_x11.cc:343 0x555559e94c8f 
views::DesktopNativeWidgetAura::InitNativeWidget() at desktop_native_widget_aura.cc:240 0x555559e8f775 
views::Widget::Init() at widget.cc:374 0x555559ea73e1 
views::MenuHost::InitMenuHost() at menu_host.cc:53 0x555559ec6fc4 
views::SubmenuView::ShowAt() at submenu_view.cc:312 0x555559e36167 
views::MenuController::OpenMenuImpl() at menu_controller.cc:1,529 0x555559ebf240 
views::MenuController::OpenMenu() at menu_controller.cc:1,504 0x555559ebf067 
views::MenuController::CommitPendingSelection() at menu_controller.cc:1,468 0x555559ebebcf 
views::MenuController::SetSelection() at menu_controller.cc:811 0x555559ebc4de 
views::MenuController::Run() at menu_controller.cc:333 0x555559eba633 
views::internal::MenuRunnerImpl::RunMenuAt() at menu_runner.cc:225 0x555559e327a9 
views::MenuRunner::RunMenuAt() at menu_runner.cc:351 0x555559e32e32 
RenderViewContextMenuViews::RunMenuAt() at render_view_context_menu_views.cc:52 0x555558ee8faa 
ChromeWebContentsViewDelegateViews::ShowContextMenu() at chrome_web_contents_view_delegate_views.cc:169 0x555558ee8783 
content::WebContentsViewAura::ShowContextMenu() at web_contents_view_aura.cc:1,061 0x555558b85076 
content::WebContentsImpl::ShowContextMenu() at web_contents_impl.cc:1,695 0x555558b6943b 
content::RenderViewHostImpl::OnContextMenu() at render_view_host_impl.cc:1,364 0x555558ad324d 
DispatchToMethod{content::RenderViewHostImpl, void () at tuple.h:546 0x555558adb202 
ViewHostMsg_ContextMenu::Dispatch{content::RenderViewHostImpl, content::RenderViewHostImpl, void () at view_messages.h:1,435 0x555558ad8747 
content::RenderViewHostImpl::OnMessageReceived() at render_view_host_impl.cc:956 0x555558ad07b3 
content::RenderProcessHostImpl::OnMessageReceived() at render_process_host_impl.cc:1,224 0x555558ab992e 
IPC::ChannelProxy::Context::OnDispatchMessage() at ipc_channel_proxy.cc:261 0x5555569ee4c3 
base::internal::RunnableAdapter{void () at bind_internal.h:190 0x5555569f1e9d 
base::internal::InvokeHelper{false, void, base::internal::RunnableAdapter{void () at bind_internal.h:898 0x5555569f1982 
base::internal::Invoker{2, base::internal::BindState{base::internal::RunnableAdapter{void () at bind_internal.h:1,253 0x5555569f11c0 
base::Callback{void () at callback.h:396 0x555555efcb8a 
base::MessageLoop::RunTask() at message_loop.cc:484 0x55555a097407 
base::MessageLoop::DeferOrRunPendingTask() at message_loop.cc:496 0x55555a097536 
base::MessageLoop::DoWork() at message_loop.cc:688 0x55555a097e77 
base::MessagePumpGlib::HandleDispatch() at message_pump_glib.cc:273 0x55555a046625 
() at message_pump_glib.cc:105 0x55555a045ded 
g_main_dispatch() at gmain.c:2,715 0x7ffff6d80ab5