GDB info locals does not work

310 views
Skip to first unread message

Ali Idrizi

unread,
Feb 5, 2019, 12:10:27 PM2/5/19
to Chromium-dev
I followed the guide on how to debug native code while running the browser on an Android device using gdb. It seems to be working fine, the breakpoints also work, but whenever I run info locals I always get nothing back. I tried a couple of functions and it's always the same result, one of them being: chrome/browser/net/chrome_network_delegate.cc at line 235 which is the method OnBeforeURLRequest, the program stops every time before a request is made, but no local variables are shown even though there is 2 of them.

int ChromeNetworkDelegate::OnBeforeURLRequest(
    net::URLRequest* request,
    net::CompletionOnceCallback callback,
    GURL* new_url) {
  extensions_delegate_->ForwardStartRequestStatus(request);

  // The non-redirect case is handled in GoogleURLLoaderThrottle.
  bool force_safe_search =
      (force_google_safe_search_ && force_google_safe_search_->GetValue() &&
       request->is_redirecting());

  net::CompletionOnceCallback wrapped_callback = std::move(callback);

  if (force_safe_search) {
    wrapped_callback = base::BindOnce(
        &ForceGoogleSafeSearchCallbackWrapper, std::move(wrapped_callback),
        base::Unretained(request), base::Unretained(new_url));
  }

  int rv = extensions_delegate_->NotifyBeforeURLRequest(
      request, std::move(wrapped_callback), new_url);

  if (force_safe_search && rv == net::OK && new_url->is_empty())
    safe_search_util::ForceGoogleSafeSearch(request->url(), new_url);

  return rv; // line 235
}

Is this behavior expected or am I doing something wrong?

dmca...@chromium.org

unread,
Feb 5, 2019, 2:30:09 PM2/5/19
to Chromium-dev
[Disclaimer: I haven't followed the guide myself.]

I'm guessing that these variables have been "optimized out". I would consider compiling without optimizations (-Og) and trying again.

Alternatively, if you're comfortable reading the optimized assembly, you can run layout asm to get a nice assembly printout on your screen. Use the stepi/nexti commands to step into or over each instruction. When you want to see a register's value, you can use print $regname.

Ali Idrizi

unread,
Feb 6, 2019, 11:58:49 AM2/6/19
to Chromium-dev
Thanks for the reply. What do you exactly mean by compile without optimization? Should I add the -Og in the ninja command?

dmca...@chromium.org

unread,
Feb 6, 2019, 1:26:43 PM2/6/19
to Chromium-dev
Hmm, I did some digging. Unless you've explicitly disabled the debug build (setting is_debug = false in your gn args), optimizations should already be disabled. Forget about -Og; it's a clang arg and the build system takes care of that for us.

Let's back up.
  • What are you actually seeing when you run info locals?
  • If it was empty, what do you get after stepping a few lines into the function with next?
  • If it's still empty, can you print the variables by name, e.g. print request?

Ali Idrizi

unread,
Feb 6, 2019, 2:36:22 PM2/6/19
to Chromium-dev
Whenever I run info locals I get back "No locals". Stepping using next does not change the outcome, if I try the print command it says No symbol "request" in context.

Christian Biesinger

unread,
Feb 6, 2019, 2:40:18 PM2/6/19
to ali.idr...@gmail.com, Chromium-dev
What does our args.gn file look like?

Christian
> --
> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev
> ---
> You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
> To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/d2d4ce92-4afc-4bba-8eca-caa2f2731229%40chromium.org.

Ali Idrizi

unread,
Feb 6, 2019, 2:49:54 PM2/6/19
to Chromium-dev, ali.idr...@gmail.com
target_os = "android"
target_cpu = "arm"
is_debug = true

is_component_build = false
is_clang = true
symbol_level = 1
enable_incremental_javac = true
v8_use_external_startup_data = true
fieldtrial_testing_like_official_build = true
icu_use_data_file = false

Nico Weber

unread,
Feb 6, 2019, 2:53:40 PM2/6/19
to ali.idr...@gmail.com, Chromium-dev
On Wed, Feb 6, 2019 at 2:50 PM Ali Idrizi <ali.idr...@gmail.com> wrote:
target_os = "android"
target_cpu = "arm"
is_debug = true

is_component_build = false

Non-component debug builds take a very long time to link. You can keep using this, but it's somewhat discouraged to do debug non-component builds. (That's unrelated to your problem though.)
 
is_clang = true

(fwiw this is on by default these days, you can remove this)
 
symbol_level = 1

^ this line basically means "I want enough symbol information for stack frames, but not more". If you remove this (then you'll get the debug build default value of 2), things are more likely to work.
 

Christian Biesinger

unread,
Feb 6, 2019, 2:53:51 PM2/6/19
to ali.idr...@gmail.com, Chromium-dev
Fairly sure that symbol_level=1 is your problem; try removing it.
> To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/cbfb977f-fa3c-4dd2-9c28-f3a1e6882303%40chromium.org.

Torne (Richard Coles)

unread,
Feb 6, 2019, 4:18:30 PM2/6/19
to cbies...@chromium.org, ali.idr...@gmail.com, Chromium-dev
Removing it won't help because in a non-component 32-bit build for android the default is 1, because the full debug info is >4gb and doesn't fit into the ELF32 output binary (yes really). You'll need to enable the component build if you want full symbols, so do both "symbol_level=2" *and* "is_component_build=true".


Daniel Bratell

unread,
Feb 7, 2019, 5:40:50 AM2/7/19
to cbies...@chromium.org, Torne (Richard Coles), ali.idr...@gmail.com, Chromium-dev
Not understanding the implication of symbol_level = 0/1/2 seems to be a rather common problem. I'd not be unhappy if the values changed to strings "none"/"function"/"line" (or similar).

/Daniel
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAEV-rjdZDOKR-ZYBTCH0rjqD2ZdDNQX6n9fhh4SRdmEOPwkn9w%40mail.gmail.com.



--
/* Opera Software, Linköping, Sweden: CET (UTC+1) */

Ali Idrizi

unread,
Feb 7, 2019, 8:34:08 AM2/7/19
to Chromium-dev, cbies...@chromium.org, ali.idr...@gmail.com
Okay so I did the build with those changes, and seems like it works now, but partially. When I ran info locals this time I got only 2 variables from the code above. I tried to print some other variable but I kept getting <optimized out>.

Here is the full output

(gdb) i loc
wrapped_callback = {
  <base::internal::CallbackBase> = {
    bind_state_ = scoped_refptr((base::internal::BindStateBase *)0x0)
  }, <No data fields>}
rv = 0
(gdb) print request
$2 = <optimized out>
(gdb) print force_safe_search
$3 = <optimized out>

And the args.gn file:

target_os = "android"
target_cpu = "arm"
is_debug = true

enable_incremental_javac = true
v8_use_external_startup_data = true
fieldtrial_testing_like_official_build = true
icu_use_data_file = false

is_component_build = true
symbol_level = 2

Torne (Richard Coles)

unread,
Feb 7, 2019, 10:53:44 AM2/7/19
to ali.idr...@gmail.com, Chromium-dev, cbies...@chromium.org
Android builds with some optimisations enabled even in debug builds by default: https://cs.chromium.org/chromium/src/build/config/compiler/BUILD.gn?rcl=97ec3202d23cde55bbd267ac6018dd837a20b6c2&l=2006
If you actually want to turn all optimisations off you can set android_full_debug=true.

Daniel Murphy

unread,
Feb 7, 2019, 8:05:35 PM2/7/19
to Chromium-dev, ali.idr...@gmail.com, cbies...@chromium.org
I fixed this problem by sourcing this file in my .gdbinit: tools/gdb/gdbinit
Reply all
Reply to author
Forward
0 new messages