当前位置:网站首页>[chromium] location information kernel debugging

[chromium] location information kernel debugging

2022-06-12 10:03:00 Lindo

Chromium Location Information kernel debugging

  • edition :Chromium80
  • background : be based on Chromium When developing the browser kernel . Sometimes the kernel Crash, The analysis of the tombstone is only PoskTask Execute its corresponding CallBack Collapse . And positioning problems , You need to know what the specific task is .
# base/callback.h
class OnceCallback<R(Args...)> : public internal::CallbackBase {
    
  // Run When Crash 了 .
  R Run(Args... args) && {
    
  	//  Omit 
  }
}
  • First , Just to understand Chromium Of Looper( It has been simplified according to personal understanding ).
Caller Executor Looper PostTask Scheduling Job? loop [ Healthcheck ] ALooper or libevent Run Task Run Call Back! If have callback. Caller Executor Looper
  • From above , We can see that . When analyzing the problem again ( Such as analyzing tombstones ), We need to know Caller And Exccutor Information about . how , Know the information of both ? Use Location You can know .

Location

  • In general PostTask when , take Location The information is transmitted to the corresponding interface . Such as
// FROM_HERE  by Location type 
PostTaskOnThread(FROM_HERE, content::BrowserThread::UI,
    base::Bind(&xxxx::func, ptr, args));
  • Location Is defined as follows : Can get call PostTask The function name of 、 Row number 、 File names and so on . such , Then we can know CallBack Executive Task The specific content of .
// base/location.h

// Location provides basic info where of an object was constructed, or was
// significantly brought to life.
class BASE_EXPORT Location {
    
   //  Omit 
   // Will be nullptr for default initialized Location objects and when source
  // names are disabled.
  const char* function_name() const {
     return function_name_; }

  // Will be nullptr for default initialized Location objects and when source
  // names are disabled.
  const char* file_name() const {
     return file_name_; }

  // Will be -1 for default initialized Location objects and when source names
  // are disabled.
  int line_number() const {
     return line_number_; }

  // The address of the code generating this Location object. Should always be
  // valid except for default initialized Location objects, which will be
  // nullptr.
  const void* program_counter() const {
     return program_counter_; }

  // Converts to the most user-readable form possible. If function and filename
  // are not available, this will return "pc:<hex address>".
  std::string ToString() const;

}
  • If you use ? Examples are as follows
// xxx.cc
//  stay Chromium Add the following information to the source code 
// task->posted_from  by Location type , It is assumed that this object has been defined in this file .
LOG(INFO) << "HelpInfo:"<< task->posted_from.ToString();
  • Output information
[INFO:xxx.cc(99)] HelpInfo:[email protected]../../../../../xxxx/chromium/src/mojo/public/cpp/bindings/lib/connector.cc:560
原网站

版权声明
本文为[Lindo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203010528239577.html