Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge conflict #55

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bc6781f
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Jul 22, 2022
9539cf8
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Jul 23, 2022
a5b57a9
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Jul 25, 2022
296fdc4
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Jul 26, 2022
ad741fa
Merge remote-tracking branch 'origin/6.0/stage'
Jul 28, 2022
ccf7dab
Merge pull request #35 from delphix/projects/merge-upstream/master
delphix-devops-bot Jul 28, 2022
355333a
Merge remote-tracking branch 'origin/6.0/stage'
Aug 2, 2022
550d1ec
Merge pull request #36 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 3, 2022
4a120e3
Merge remote-tracking branch 'origin/6.0/stage'
Aug 10, 2022
320fbfc
Merge pull request #37 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 10, 2022
38af167
Merge remote-tracking branch 'origin/6.0/stage'
Aug 12, 2022
833a79e
Merge pull request #38 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 12, 2022
de8237d
Merge remote-tracking branch 'origin/6.0/stage'
Aug 16, 2022
4ba62b3
Merge pull request #39 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 16, 2022
aed3660
Merge remote-tracking branch 'origin/6.0/stage'
Aug 17, 2022
deff5eb
Merge pull request #40 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 17, 2022
1bee6d2
Merge remote-tracking branch 'origin/6.0/stage'
Aug 18, 2022
a71f094
Merge pull request #41 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 18, 2022
eec33ce
Merge remote-tracking branch 'origin/6.0/stage'
Aug 20, 2022
cab7ecb
Merge pull request #42 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 20, 2022
1c778a4
Merge remote-tracking branch 'origin/6.0/stage'
Aug 26, 2022
7622cd5
Merge pull request #43 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 26, 2022
56927cf
Merge remote-tracking branch 'origin/6.0/stage'
Aug 27, 2022
a5e67ec
Merge pull request #44 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 27, 2022
9a28faa
Merge remote-tracking branch 'origin/6.0/stage'
Aug 30, 2022
0aa50b6
Merge pull request #45 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 30, 2022
76c1752
Merge remote-tracking branch 'origin/6.0/stage'
Aug 31, 2022
e0db712
Merge pull request #46 from delphix/projects/merge-upstream/master
delphix-devops-bot Aug 31, 2022
b83f5be
Merge remote-tracking branch 'origin/6.0/stage'
Sep 10, 2022
ca23e16
Merge pull request #47 from delphix/projects/merge-upstream/master
delphix-devops-bot Sep 10, 2022
babdb01
Merge remote-tracking branch 'origin/6.0/stage'
Sep 13, 2022
3eb8ff2
Merge pull request #48 from delphix/projects/merge-upstream/master
delphix-devops-bot Sep 13, 2022
266d0d8
Merge remote-tracking branch 'origin/6.0/stage'
Sep 15, 2022
2374f1a
Merge pull request #49 from delphix/projects/merge-upstream/master
delphix-devops-bot Sep 15, 2022
87cc818
Merge remote-tracking branch 'origin/6.0/stage'
Sep 16, 2022
519f006
Merge pull request #50 from delphix/projects/merge-upstream/master
delphix-devops-bot Sep 16, 2022
e349b9e
Add more pre-commit hooks
brenns10 Sep 5, 2023
aa851c8
contrib: Add ptdrgn.py script to run interactively via ptpython
brenns10 Jun 26, 2023
535563b
contrib: ptdrgn: Improve Object completion
brenns10 Jun 26, 2023
9d7f70a
pre-commit: include vmtest/rootfsbuild.py in vermin
osandov Sep 7, 2023
49978c5
docs: add new required options to .readthedocs.yaml
osandov Sep 7, 2023
5e0dd56
docs: try fixing invalid build.tools.python in .readthedocs.yaml
osandov Sep 7, 2023
70cca90
libdrgn: dwarf_info: fix qsort() undefined behavior
osandov Sep 7, 2023
af2dffc
docs: add 0.0.24 release highlights
osandov Sep 8, 2023
38aa7f3
drgn 0.0.24
osandov Sep 8, 2023
5c41050
Merge remote-tracking branch 'origin/upstreams/develop' into merge
grwilson Sep 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/sync-with-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
push:
branches:
- master
schedule:
- cron: '0 0 * * *'

jobs:
sync:
strategy:
matrix:
branch:
- 6.0/stage
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: delphix/actions/sync-with-master@master
with:
branch-to-sync: ${{ matrix.branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 0 additions & 23 deletions .pre-commit-config.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions .readthedocs.yml → .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
version: 2
build:
os: ubuntu-22.04
tools:
python: "3"
sphinx:
configuration: docs/conf.py
python:
Expand Down
210 changes: 210 additions & 0 deletions contrib/ptdrgn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
#!/usr/bin/python3
# Copyright (c) 2023, Oracle and/or its affiliates.
# Copyright (c) Meta Platforms, Inc. and affiliates.
# SPDX-License-Identifier: LGPL-2.1-or-later
"""
Drgn CLI, but using ptpython rather than the standard code.interact()

NOTE: this is definitely a bit of a hack, using implementation details of Drgn
*and* ptpython. It may break at any time, but it is also quite useful, and this
makes it worth sharing.

Requires: "pip install ptpython" which brings in pygments and prompt_toolkit
"""
import functools
import importlib
import os
import shutil
import sys
from typing import Any, Callable, Dict, Optional, Set

from prompt_toolkit.completion import Completion, Completer
from prompt_toolkit.formatted_text import PygmentsTokens
from prompt_toolkit.formatted_text import fragment_list_to_text, to_formatted_text
from ptpython import embed
from ptpython.completer import DictionaryCompleter
from ptpython.repl import run_config
from pygments.lexers.c_cpp import CLexer

import drgn
import drgn.cli


class DummyForRepr:
"""
A dummy class to pass back to _format_result_output() that pretends to have
the given repr()
"""

def __init__(self, s):
self.s = s

def __repr__(self):
return self.s


class DummyForPtRepr:
"""A similar dummy class for the __pt_repr__() method."""

def __init__(self, s):
self.s = s

def __pt_repr__(self):
return self.s


def _maybe_c_format(s):
"""Given a string, try to use pygments to highlight it it as a C string."""
try:
tokens = CLexer().get_tokens_unprocessed(s)
formatted = PygmentsTokens([(tokentype, value) for index, tokentype, value in tokens])
to_format = DummyForPtRepr(formatted)
except Exception as e:
to_format = DummyForRepr(s)
return to_format


@functools.lru_cache(maxsize=1)
def _object_fields() -> Set[str]:
return set(dir(drgn.Object))


class ReorderDrgnObjectCompleter(Completer):
"""A completer which puts Object member fields above Object defaults"""

def __init__(self, c: Completer):
self.c = c

def get_completions(self, document, complete_event):
completions = list(self.c.get_completions(document, complete_event))
if not completions:
return completions
text = completions[0].text
member_fields = []
# If the first completion is "absent_", it is *very likely* that we are
# now looking at the completion of on Object. Move the default Object
# attributes to the end of the list so that we get the struct attributes
if text == "absent_":
fields = _object_fields()
for i in reversed(range(len(completions))):
text = completions[i].text
if text not in fields:
member_fields.append(completions[i])
del completions[i]
return list(reversed(member_fields)) + completions
return completions


def configure(repl) -> None:
"""
Muck around with the internals of PythonRepl so that we will special case the
drgn data structures, similar to how drgn messes with sys.displayhook. We can
do C syntax highlighting too, which is really nice.

This also automatically runs the default config file:
~/.config/ptpython/config.py
"""
_format_result_output_orig = repl._format_result_output

def _format_result_output(result: object):
if isinstance(result, drgn.Object):
s = result.format_(columns=shutil.get_terminal_size((0, 0)).columns)
to_format = _maybe_c_format(s)
elif isinstance(result, (drgn.StackFrame, drgn.StackTrace)):
to_format = DummyForRepr(str(result))
elif isinstance(result, drgn.Type):
to_format = _maybe_c_format(str(result))
else:
to_format = result
return _format_result_output_orig(to_format)

repl._format_result_output = _format_result_output
run_config(repl)
repl._completer = ReorderDrgnObjectCompleter(repl._completer)
repl.completer = ReorderDrgnObjectCompleter(repl.completer)


def run_interactive(
prog: drgn.Program,
banner_func: Optional[Callable[[str], str]] = None,
globals_func: Optional[Callable[[Dict[str, Any]], Dict[str, Any]]] = None,
quiet: bool = False,
) -> None:
"""
Run drgn's :ref:`interactive-mode` via ptpython

:param prog: Pre-configured program to run against. Available as a global
named ``prog`` in the CLI.
:param banner_func: Optional function to modify the printed banner. Called
with the default banner, and must return a string to use as the new
banner. The default banner does not include the drgn version, which can
be retrieved via :func:`version_header()`.
:param globals_func: Optional function to modify globals provided to the
session. Called with a dictionary of default globals, and must return a
dictionary to use instead.
:param quiet: Whether to suppress non-fatal warnings.
"""
init_globals: Dict[str, Any] = {
"prog": prog,
"drgn": drgn,
"__name__": "__main__",
"__doc__": None,
}
drgn_globals = [
"NULL",
"Object",
"cast",
"container_of",
"execscript",
"offsetof",
"reinterpret",
"sizeof",
]
for attr in drgn_globals:
init_globals[attr] = getattr(drgn, attr)

banner = f"""\
For help, type help(drgn).
>>> import drgn
>>> from drgn import {", ".join(drgn_globals)}
>>> from drgn.helpers.common import *"""

module = importlib.import_module("drgn.helpers.common")
for name in module.__dict__["__all__"]:
init_globals[name] = getattr(module, name)
if prog.flags & drgn.ProgramFlags.IS_LINUX_KERNEL:
banner += "\n>>> from drgn.helpers.linux import *"
module = importlib.import_module("drgn.helpers.linux")
for name in module.__dict__["__all__"]:
init_globals[name] = getattr(module, name)

if banner_func:
banner = banner_func(banner)
if globals_func:
init_globals = globals_func(init_globals)

old_path = list(sys.path)
# The ptpython history file format is different from a standard readline
# history file since it must handle multi-line input, and it includes some
# metadata as well. Use a separate history format, even though it would be
# nice to share.
histfile = os.path.expanduser("~/.drgn_history.ptpython")
try:
sys.path.insert(0, "")

print(banner)
embed(
globals=init_globals,
history_filename=histfile,
title="drgn",
configure=configure,
)
finally:
sys.path[:] = old_path


if __name__ == "__main__":
# Muck around with the internals of drgn: swap out run_interactive() with our
# ptpython version, and then call main as if nothing happened.
drgn.cli.run_interactive = run_interactive
drgn.cli._main()
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
34 changes: 34 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Source: drgn
Section: misc
Priority: optional
Maintainer: Delphix Engineering <[email protected]>
Standards-Version: 4.1.2
Build-Depends: autoconf,
automake,
bison,
dh-python,
elfutils,
flex,
gawk,
git,
gcc,
libbz2-dev,
libdw1,
libdw-dev,
libelf1,
libelf-dev,
libkdumpfile,
liblzma-dev,
liblzo2-dev,
libtool,
make,
pkg-config,
python3,
python3-distutils,
python3-dev,
zlib1g-dev

Package: drgn
Architecture: any
Depends: ${shlibs:Depends}, ${python3:Depends}
Description: Scriptable debugger library
23 changes: 23 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: drgn
Source: https://github.com/osandov/drgn

Files: *
Copyright: Copyright (c) Facebook, Inc. and its affiliates.
License: GPL v3.0

License: GPL-3
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, as
published by the Free Software Foundation.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
The complete text of the GPL version 3 can be seen in
/usr/share/common-licenses/GPL-3.
18 changes: 18 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/make -f

%:
dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_test:
#
# Don't run drgn's tests during the build step; The repo comes
# with its own testing that takes place elsewhere ->
# https://travis-ci.org/github/delphix/drgn/branches
#
# Ideally it wouldn't hurt having them run here too but due to
# drgn's testing setup, we'd have to override pybuild's default
# behavior. Since drgn is not a project that is owned by us,
# disabling tests here makes even more sense as we won't have
# to adjust the setup here every time a change in the test
# framework of drgn is applied upstream.
#
1 change: 1 addition & 0 deletions docs/release_highlights.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ from the full `release notes <https://github.com/osandov/drgn/releases>`_.

.. toctree::

release_highlights/0.0.24.rst
release_highlights/0.0.23.rst
release_highlights/0.0.22.rst
Loading
Loading